Skip to content

Commit

Permalink
tests/chwd: Add package availability checking in profiles (#116)
Browse files Browse the repository at this point in the history
* tests/chwd: Add package availability checking in profiles

* tests/chwd: Remove Luarocks from CI

* test/chwd: Run busted inside cachyos container
  • Loading branch information
ventureoo authored Jun 18, 2024
1 parent 69cf7de commit b53fe7d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/lua.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
40 changes: 38 additions & 2 deletions tests/chwd_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit b53fe7d

Please sign in to comment.