From b53fe7db712d5240341565782df1fa826ec505e5 Mon Sep 17 00:00:00 2001 From: Vasiliy Stelmachenok <92667539+ventureoo@users.noreply.github.com> Date: Tue, 18 Jun 2024 09:57:03 +0000 Subject: [PATCH] tests/chwd: Add package availability checking in profiles (#116) * tests/chwd: Add package availability checking in profiles * tests/chwd: Remove Luarocks from CI * test/chwd: Run busted inside cachyos container --- .github/workflows/lua.yml | 8 +++++--- tests/chwd_spec.lua | 40 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lua.yml b/.github/workflows/lua.yml index b9268a6..72e29f4 100644 --- a/.github/workflows/lua.yml +++ b/.github/workflows/lua.yml @@ -15,10 +15,12 @@ on: jobs: sile: runs-on: ubuntu-latest + container: cachyos/cachyos:latest steps: - name: Checkout uses: actions/checkout@v3 + - name: Install dependencies + run: | + pacman -Syu --noconfirm lua lua-filesystem busted lua-busted - name: Run Busted - uses: lunarmodules/busted@v2.2.0 - with: - args: --no-keep-going . + run: busted . --no-keep-going diff --git a/tests/chwd_spec.lua b/tests/chwd_spec.lua index f577811..38b17bc 100644 --- a/tests/chwd_spec.lua +++ b/tests/chwd_spec.lua @@ -69,17 +69,53 @@ EOF describe("Inheritance", function() local packages, hooks = chwd.get_profile(profiles, child_name) - it("Inherit parent packages", function () + it("Inherit parent packages", function() assert.are.equals(packages, "nvidia-utils egl-wayland nvidia-settings opencl-nvidia lib32-opencl-nvidia lib32-nvidia-utils libva-nvidia-driver vulkan-icd-loader lib32-vulkan-icd-loader") end) - it("Inherit some parent hook", function () + it("Inherit some parent hook", function() assert.are.equals(hooks['post_remove'], [[ rm -f /etc/mkinitcpio.conf.d/10-chwd.conf mkinitcpio -P ]]) end) end) + + describe("Packages inspection", function() + local lfs = require("lfs") + + local function search(path, t) + for file in lfs.dir(path) do + if file ~= "." and file ~= ".." then + local f = path .. '/' .. file + local attr = lfs.attributes(f) + assert(type(attr) == "table") + if attr.mode == "directory" then + search(f, t) + else + if f:match('.toml$') then + t[#t + 1] = f + end + end + end + end + end + + local available_profiles = {} + search("./profiles", available_profiles) + + it("Packages are available in repo", function() + for _, file in ipairs(available_profiles) do + local profiles = chwd.parse_profiles(file) + for pname, _ in pairs(profiles) do + local packages = chwd.get_profile(profiles, pname) + print(string.format("Checking profile %s for available packages: %s...", pname, packages)) + local _, _, exitcode = os.execute("pacman -Sp " .. packages .. " 1>/dev/null") + assert.True(exitcode == 0) + end + end + end) + end) end) describe("Invalid cases", function()