diff options
Diffstat (limited to 'spec/util_spec.lua')
| -rw-r--r-- | spec/util_spec.lua | 63 |
1 files changed, 8 insertions, 55 deletions
diff --git a/spec/util_spec.lua b/spec/util_spec.lua index 988d8ef0..25cc51d8 100644 --- a/spec/util_spec.lua +++ b/spec/util_spec.lua | |||
| @@ -55,66 +55,19 @@ describe("Basic tests #blackbox #b_util", function() | |||
| 55 | end) | 55 | end) |
| 56 | 56 | ||
| 57 | it("LuaRocks test site config", function() | 57 | it("LuaRocks test site config", function() |
| 58 | assert.is.truthy(os.rename("src/luarocks/site_config.lua", "src/luarocks/site_config.lua.tmp")) | 58 | local scname = "src/luarocks/core/site_config_"..test_env.lua_version:gsub("%.", "_")..".lua" |
| 59 | assert.is.falsy(lfs.attributes("src/luarocks/site_config.lua")) | 59 | |
| 60 | assert.is.truthy(lfs.attributes("src/luarocks/site_config.lua.tmp")) | 60 | assert.is.truthy(os.rename(scname, scname..".tmp")) |
| 61 | assert.is.falsy(lfs.attributes(scname)) | ||
| 62 | assert.is.truthy(lfs.attributes(scname..".tmp")) | ||
| 61 | 63 | ||
| 62 | assert.is.truthy(run.luarocks("")) | 64 | assert.is.truthy(run.luarocks("")) |
| 63 | 65 | ||
| 64 | assert.is.truthy(os.rename("src/luarocks/site_config.lua.tmp", "src/luarocks/site_config.lua")) | 66 | assert.is.truthy(os.rename(scname..".tmp", scname)) |
| 65 | assert.is.falsy(lfs.attributes("src/luarocks/site_config.lua.tmp")) | 67 | assert.is.falsy(lfs.attributes(scname..".tmp")) |
| 66 | assert.is.truthy(lfs.attributes("src/luarocks/site_config.lua")) | 68 | assert.is.truthy(lfs.attributes(scname)) |
| 67 | end) | 69 | end) |
| 68 | 70 | ||
| 69 | -- Disable versioned config temporarily, because it always takes | ||
| 70 | -- precedence over config.lua (config-5.x.lua is installed by default on Windows, | ||
| 71 | -- but not on Unix, so on Unix the os.rename commands below will fail silently, but this is harmless) | ||
| 72 | describe("LuaRocks config - more complex tests", function() | ||
| 73 | local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" | ||
| 74 | local versioned_scname = scdir .. "/config-" .. env_variables.LUA_VERSION .. ".lua" | ||
| 75 | local scname = scdir .. "/config.lua" | ||
| 76 | |||
| 77 | local configfile | ||
| 78 | if test_env.TEST_TARGET_OS == "windows" then | ||
| 79 | configfile = versioned_scname | ||
| 80 | else | ||
| 81 | configfile = scname | ||
| 82 | end | ||
| 83 | |||
| 84 | it("LuaRocks fail system config", function() | ||
| 85 | os.rename(versioned_scname, versioned_scname .. "bak") | ||
| 86 | local ok = run.luarocks_bool("config --system-config") | ||
| 87 | os.rename(versioned_scname .. ".bak", versioned_scname) | ||
| 88 | assert.is_false(ok) | ||
| 89 | end) | ||
| 90 | |||
| 91 | it("LuaRocks system config", function() | ||
| 92 | lfs.mkdir(testing_paths.testing_lrprefix) | ||
| 93 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") | ||
| 94 | lfs.mkdir(scdir) | ||
| 95 | |||
| 96 | local sysconfig = io.open(configfile, "w+") | ||
| 97 | sysconfig:write(" ") | ||
| 98 | sysconfig:close() | ||
| 99 | |||
| 100 | local output = run.luarocks("config --system-config") | ||
| 101 | os.remove(configfile) | ||
| 102 | assert.are.same(output, configfile) | ||
| 103 | end) | ||
| 104 | |||
| 105 | it("LuaRocks fail system config invalid", function() | ||
| 106 | lfs.mkdir(testing_paths.testing_lrprefix) | ||
| 107 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") | ||
| 108 | lfs.mkdir(scdir) | ||
| 109 | |||
| 110 | local sysconfig = io.open(configfile, "w+") | ||
| 111 | sysconfig:write("if if if") | ||
| 112 | sysconfig:close() | ||
| 113 | local ok = run.luarocks_bool("config --system-config") | ||
| 114 | os.remove(configfile) | ||
| 115 | assert.is_false(ok) | ||
| 116 | end) | ||
| 117 | end) | ||
| 118 | end) | 71 | end) |
| 119 | 72 | ||
| 120 | test_env.unload_luarocks() | 73 | test_env.unload_luarocks() |
