From f0f7cebb9efdd897ee8f1d1dde0bdf6952cc1f00 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 23 Aug 2022 13:36:33 +0300 Subject: [PATCH] chore(tests): Use more standard paths to avoid unexpected test behaviour --- .github/workflows/busted.yml | 4 ++-- say-scm-1.rockspec | 4 +++- spec/say_spec.lua | 8 ++++++-- src/{ => say}/init.lua | 0 4 files changed, 11 insertions(+), 5 deletions(-) rename src/{ => say}/init.lua (100%) diff --git a/.github/workflows/busted.yml b/.github/workflows/busted.yml index 9a8ae57..ab7c3e9 100644 --- a/.github/workflows/busted.yml +++ b/.github/workflows/busted.yml @@ -33,8 +33,8 @@ jobs: luarocks make - name: Run regression tests - # disable the paths to force use of installed rockspec - run: busted -c -v --lpath="" --cpath="" --Xoutput "--color" + # disable project-local path prefixes to force use of system installation + run: busted --coverage --lpath="" --cpath="" -Xoutput --color - name: Report test coverage if: ${{ success() && github.repository == 'lunarmodules/say' }} diff --git a/say-scm-1.rockspec b/say-scm-1.rockspec index 8a37210..09c8bc3 100644 --- a/say-scm-1.rockspec +++ b/say-scm-1.rockspec @@ -13,6 +13,7 @@ source = { url = "git+https://github.com/"..github_account_name.."/"..github_repo_name..".git", branch = git_checkout } + description = { summary = "Lua string hashing/indexing library", detailed = [[ @@ -21,6 +22,7 @@ description = { homepage = "https://lunarmodules.github.io/busted/", license = "MIT " } + dependencies = { "lua >= 5.1" } @@ -36,6 +38,6 @@ test = { build = { type = "builtin", modules = { - ["say.init"] = "src/init.lua" + ["say.init"] = "src/say/init.lua" } } diff --git a/spec/say_spec.lua b/spec/say_spec.lua index 80dd9f8..989a846 100644 --- a/spec/say_spec.lua +++ b/spec/say_spec.lua @@ -1,9 +1,12 @@ local s describe("Tests to make sure the say library is functional", function() + setup(function() - package.loaded['say'] = false -- busted uses it, must force to reload - s = require('init') -- devcode is in /src/init.lua not in /src/say/init.lua + -- busted loads say internally, force reload in case the sources we're + -- expected to test (via LUA_PATH) aren't the ones busted found earlier + package.loaded['say'] = false + s = require('say') end) it("tests the set function metamethod", function() @@ -53,4 +56,5 @@ describe("Tests to make sure the say library is functional", function() it("tests missing elements returns nil", function() assert(s('this does not exist') == nil) end) + end) diff --git a/src/init.lua b/src/say/init.lua similarity index 100% rename from src/init.lua rename to src/say/init.lua