Skip to content

Commit

Permalink
chore(tests): Use more standard paths to avoid unexpected test behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Aug 23, 2022
1 parent 17d1fbe commit f0f7ceb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/busted.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
Expand Down
4 changes: 3 additions & 1 deletion say-scm-1.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [[
Expand All @@ -21,6 +22,7 @@ description = {
homepage = "https://lunarmodules.github.io/busted/",
license = "MIT <http://opensource.org/licenses/MIT>"
}

dependencies = {
"lua >= 5.1"
}
Expand All @@ -36,6 +38,6 @@ test = {
build = {
type = "builtin",
modules = {
["say.init"] = "src/init.lua"
["say.init"] = "src/say/init.lua"
}
}
8 changes: 6 additions & 2 deletions spec/say_spec.lua
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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)
File renamed without changes.

0 comments on commit f0f7ceb

Please sign in to comment.