diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2024-02-28 11:49:34 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2024-02-29 15:31:46 +0000 |
| commit | 3f0f3028321154cbacecd6690833d0e8c805ccd8 (patch) | |
| tree | 76150d9b8cc50f89fa32d5716a26b6261f4e087e /spec | |
| parent | 6f07395f37459d7e0c2732888a1f7312fea0c67c (diff) | |
| download | luarocks-3f0f3028321154cbacecd6690833d0e8c805ccd8.tar.gz luarocks-3f0f3028321154cbacecd6690833d0e8c805ccd8.tar.bz2 luarocks-3f0f3028321154cbacecd6690833d0e8c805ccd8.zip | |
feat: more informative reports no bad LUA_{INC,LIB}DIR configs
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/cmd_spec.lua | 6 | ||||
| -rw-r--r-- | spec/quick/cmd.q | 36 | ||||
| -rw-r--r-- | spec/quick/config.q | 90 | ||||
| -rw-r--r-- | spec/util/quick.lua | 2 | ||||
| -rw-r--r-- | spec/util/test_env.lua | 17 |
5 files changed, 132 insertions, 19 deletions
diff --git a/spec/cmd_spec.lua b/spec/cmd_spec.lua index 9067a160..20248af7 100644 --- a/spec/cmd_spec.lua +++ b/spec/cmd_spec.lua | |||
| @@ -56,12 +56,6 @@ describe("LuaRocks command line #integration", function() | |||
| 56 | assert.match("malformed", output, 1, true) | 56 | assert.match("malformed", output, 1, true) |
| 57 | end) | 57 | end) |
| 58 | 58 | ||
| 59 | it("warns but continues if given an invalid version", function() | ||
| 60 | local output = run.luarocks("--lua-version=1.0") | ||
| 61 | assert.match("LUA *: %(not found%)", output) | ||
| 62 | assert.match("Version%s*:%s*1.0", output) | ||
| 63 | end) | ||
| 64 | |||
| 65 | it("sets the version independently of project tree", function() | 59 | it("sets the version independently of project tree", function() |
| 66 | test_env.run_in_tmp(function(tmpdir) | 60 | test_env.run_in_tmp(function(tmpdir) |
| 67 | assert.truthy(run.luarocks_bool("init --lua-version=" .. test_env.lua_version .. " --lua-versions=" .. test_env.lua_version)) | 61 | assert.truthy(run.luarocks_bool("init --lua-version=" .. test_env.lua_version .. " --lua-versions=" .. test_env.lua_version)) |
diff --git a/spec/quick/cmd.q b/spec/quick/cmd.q new file mode 100644 index 00000000..acde92b4 --- /dev/null +++ b/spec/quick/cmd.q | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | SUITE: luarocks CLI | ||
| 2 | |||
| 3 | ================================================================================ | ||
| 4 | TEST: warns but continues if given an invalid version | ||
| 5 | |||
| 6 | RUN: luarocks --lua-version 1.0 | ||
| 7 | |||
| 8 | STDOUT: | ||
| 9 | -------------------------------------------------------------------------------- | ||
| 10 | Version : 1.0 | ||
| 11 | LUA : (interpreter not found) | ||
| 12 | -------------------------------------------------------------------------------- | ||
| 13 | |||
| 14 | |||
| 15 | |||
| 16 | ================================================================================ | ||
| 17 | TEST: reports if lua.h header is not found | ||
| 18 | |||
| 19 | RUN: luarocks LUA_INCDIR=/bad/dir | ||
| 20 | |||
| 21 | STDOUT: | ||
| 22 | -------------------------------------------------------------------------------- | ||
| 23 | LUA_INCDIR : /bad/dir (lua.h not found) | ||
| 24 | -------------------------------------------------------------------------------- | ||
| 25 | |||
| 26 | |||
| 27 | |||
| 28 | ================================================================================ | ||
| 29 | TEST: reports if Lua library is not found | ||
| 30 | |||
| 31 | RUN: luarocks LUA_LIBDIR=/bad/dir | ||
| 32 | |||
| 33 | STDOUT: | ||
| 34 | -------------------------------------------------------------------------------- | ||
| 35 | LUA_LIBDIR : /bad/dir (Lua library itself not found) | ||
| 36 | -------------------------------------------------------------------------------- | ||
diff --git a/spec/quick/config.q b/spec/quick/config.q index 3150a9ce..d6230567 100644 --- a/spec/quick/config.q +++ b/spec/quick/config.q | |||
| @@ -1,13 +1,11 @@ | |||
| 1 | ================================================================================ | 1 | SUITE: luarocks config |
| 2 | TEST: luarocks config --system-config shows the path of the system config | ||
| 3 | 2 | ||
| 4 | MKDIR: %{testing_lrprefix}/etc/luarocks | 3 | ================================================================================ |
| 4 | TEST: --system-config shows the path of the system config | ||
| 5 | 5 | ||
| 6 | FILE: %{testing_lrprefix}/etc/luarocks/config-%{LUA_VERSION}.lua | 6 | FILE: %{testing_lrprefix}/etc/luarocks/config-%{LUA_VERSION}.lua |
| 7 | -------------------------------------------------------------------------------- | 7 | -------------------------------------------------------------------------------- |
| 8 | |||
| 9 | -------------------------------------------------------------------------------- | 8 | -------------------------------------------------------------------------------- |
| 10 | |||
| 11 | RUN: luarocks config --system-config | 9 | RUN: luarocks config --system-config |
| 12 | 10 | ||
| 13 | STDOUT: | 11 | STDOUT: |
| @@ -15,3 +13,85 @@ STDOUT: | |||
| 15 | %{path(%{testing_lrprefix}/etc/luarocks/config-%{LUA_VERSION}.lua)} | 13 | %{path(%{testing_lrprefix}/etc/luarocks/config-%{LUA_VERSION}.lua)} |
| 16 | -------------------------------------------------------------------------------- | 14 | -------------------------------------------------------------------------------- |
| 17 | 15 | ||
| 16 | |||
| 17 | |||
| 18 | ================================================================================ | ||
| 19 | TEST: reports when setting a bad LUA_LIBDIR | ||
| 20 | |||
| 21 | RUN: luarocks config variables.LUA_LIBDIR /some/bad/path | ||
| 22 | |||
| 23 | LuaRocks writes configuration values as they are given, without auto-conversion | ||
| 24 | of slashes for Windows: | ||
| 25 | |||
| 26 | STDOUT: | ||
| 27 | -------------------------------------------------------------------------------- | ||
| 28 | Wrote | ||
| 29 | variables.LUA_LIBDIR = "/some/bad/path" | ||
| 30 | -------------------------------------------------------------------------------- | ||
| 31 | |||
| 32 | STDERR: | ||
| 33 | -------------------------------------------------------------------------------- | ||
| 34 | Warning: Failed finding the Lua library. | ||
| 35 | Tried: | ||
| 36 | |||
| 37 | LuaRocks may not work correctly when building C modules using this configuration. | ||
| 38 | -------------------------------------------------------------------------------- | ||
| 39 | |||
| 40 | |||
| 41 | |||
| 42 | ================================================================================ | ||
| 43 | TEST: reports when setting a bad LUA_INCDIR | ||
| 44 | |||
| 45 | RUN: luarocks config variables.LUA_INCDIR /some/bad/path | ||
| 46 | |||
| 47 | STDOUT: | ||
| 48 | -------------------------------------------------------------------------------- | ||
| 49 | Wrote | ||
| 50 | variables.LUA_INCDIR = "/some/bad/path" | ||
| 51 | -------------------------------------------------------------------------------- | ||
| 52 | |||
| 53 | LuaRocks uses configuration values as they are given, without auto-conversion | ||
| 54 | of slashes for Windows: | ||
| 55 | |||
| 56 | STDERR: | ||
| 57 | -------------------------------------------------------------------------------- | ||
| 58 | Warning: Failed finding Lua header lua.h (searched at /some/bad/path). You may need to install Lua development headers. | ||
| 59 | |||
| 60 | LuaRocks may not work correctly when building C modules using this configuration. | ||
| 61 | -------------------------------------------------------------------------------- | ||
| 62 | |||
| 63 | |||
| 64 | |||
| 65 | ================================================================================ | ||
| 66 | TEST: rejects setting bad lua_dir | ||
| 67 | |||
| 68 | RUN: luarocks config lua_dir /some/bad/dir | ||
| 69 | EXIT: 1 | ||
| 70 | |||
| 71 | STDERR: | ||
| 72 | -------------------------------------------------------------------------------- | ||
| 73 | Lua interpreter not found | ||
| 74 | -------------------------------------------------------------------------------- | ||
| 75 | |||
| 76 | |||
| 77 | |||
| 78 | ================================================================================ | ||
| 79 | TEST: reports when setting a bad LUA_INCDIR | ||
| 80 | |||
| 81 | RUN: luarocks config variables.LUA_INCDIR /some/bad/path | ||
| 82 | |||
| 83 | STDOUT: | ||
| 84 | -------------------------------------------------------------------------------- | ||
| 85 | Wrote | ||
| 86 | variables.LUA_INCDIR = "/some/bad/path" | ||
| 87 | -------------------------------------------------------------------------------- | ||
| 88 | |||
| 89 | LuaRocks uses configuration values as they are given, without auto-conversion | ||
| 90 | of slashes for Windows: | ||
| 91 | |||
| 92 | STDERR: | ||
| 93 | -------------------------------------------------------------------------------- | ||
| 94 | Warning: Failed finding Lua header lua.h (searched at /some/bad/path). You may need to install Lua development headers. | ||
| 95 | |||
| 96 | LuaRocks may not work correctly when building C modules using this configuration. | ||
| 97 | -------------------------------------------------------------------------------- | ||
diff --git a/spec/util/quick.lua b/spec/util/quick.lua index cb4bb4cf..c313f575 100644 --- a/spec/util/quick.lua +++ b/spec/util/quick.lua | |||
| @@ -347,7 +347,7 @@ function quick.compile(filename, env) | |||
| 347 | write(([=[ ok, err = make_dir(%q) ]=]):format(op.file)) | 347 | write(([=[ ok, err = make_dir(%q) ]=]):format(op.file)) |
| 348 | write(([=[ assert.truthy((lfs.attributes(%q) or {}).mode == "directory", error_message(%d, "MKDIR failed: " .. %q .. " - " .. (err or "") )) ]=]):format(op.file, op.line, op.file)) | 348 | write(([=[ assert.truthy((lfs.attributes(%q) or {}).mode == "directory", error_message(%d, "MKDIR failed: " .. %q .. " - " .. (err or "") )) ]=]):format(op.file, op.line, op.file)) |
| 349 | elseif op.op == "RUN" then | 349 | elseif op.op == "RUN" then |
| 350 | local cmd_helper = cmd_helpers[op.program] or op.program | 350 | local cmd_helper = cmd_helpers[op.program] or ("%q"):format(op.program) |
| 351 | local redirs = " 1>stdout.txt 2>stderr.txt " | 351 | local redirs = " 1>stdout.txt 2>stderr.txt " |
| 352 | write(([=[ local ok, _, code = os.execute(%s .. " " .. %q .. %q) ]=]):format(cmd_helper, op.args, redirs)) | 352 | write(([=[ local ok, _, code = os.execute(%s .. " " .. %q .. %q) ]=]):format(cmd_helper, op.args, redirs)) |
| 353 | write([=[ if type(ok) == "number" then code = (ok >= 256 and ok / 256 or ok) end ]=]) | 353 | write([=[ if type(ok) == "number" then code = (ok >= 256 and ok / 256 or ok) end ]=]) |
diff --git a/spec/util/test_env.lua b/spec/util/test_env.lua index 24a1de9e..8ccb494b 100644 --- a/spec/util/test_env.lua +++ b/spec/util/test_env.lua | |||
| @@ -207,13 +207,16 @@ function test_env.run_in_tmp(f, finally) | |||
| 207 | end | 207 | end |
| 208 | fs.change_dir(tmpdir) | 208 | fs.change_dir(tmpdir) |
| 209 | 209 | ||
| 210 | if finally then | 210 | local lr_config = test_env.env_variables.LUAROCKS_CONFIG |
| 211 | finally(function() | 211 | |
| 212 | lfs.chdir(olddir) | 212 | test_env.copy(lr_config, lr_config .. ".bak") |
| 213 | lfs.rmdir(tmpdir) | 213 | |
| 214 | fs.change_dir(olddir) | 214 | finally(function() |
| 215 | end) | 215 | test_env.copy(lr_config .. ".bak", lr_config) |
| 216 | end | 216 | lfs.chdir(olddir) |
| 217 | lfs.rmdir(tmpdir) | ||
| 218 | fs.change_dir(olddir) | ||
| 219 | end) | ||
| 217 | 220 | ||
| 218 | f(tmpdir) | 221 | f(tmpdir) |
| 219 | end | 222 | end |
