diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2021-03-16 13:36:26 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2021-03-16 16:32:45 -0300 |
| commit | 8f3ce333e7a1abfc6bf0488817d9eff4a2fd443f (patch) | |
| tree | f05d1a49995341a56e602ce2a3256b89372e9d04 /spec/config_spec.lua | |
| parent | 2b56388e76952be52d849415b1ebae74b6dc4607 (diff) | |
| download | luarocks-8f3ce333e7a1abfc6bf0488817d9eff4a2fd443f.tar.gz luarocks-8f3ce333e7a1abfc6bf0488817d9eff4a2fd443f.tar.bz2 luarocks-8f3ce333e7a1abfc6bf0488817d9eff4a2fd443f.zip | |
editorconfig: trim trailing whitespace
Diffstat (limited to 'spec/config_spec.lua')
| -rw-r--r-- | spec/config_spec.lua | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/spec/config_spec.lua b/spec/config_spec.lua index f4a793c4..a14b1ec0 100644 --- a/spec/config_spec.lua +++ b/spec/config_spec.lua | |||
| @@ -9,7 +9,7 @@ local hardcoded | |||
| 9 | test_env.unload_luarocks() | 9 | test_env.unload_luarocks() |
| 10 | 10 | ||
| 11 | describe("LuaRocks config tests #integration", function() | 11 | describe("LuaRocks config tests #integration", function() |
| 12 | 12 | ||
| 13 | setup(function() | 13 | setup(function() |
| 14 | test_env.setup_specs() | 14 | test_env.setup_specs() |
| 15 | test_env.unload_luarocks() -- need to be required here, because hardcoded is created after first loading of specs | 15 | test_env.unload_luarocks() -- need to be required here, because hardcoded is created after first loading of specs |
| @@ -55,12 +55,12 @@ describe("LuaRocks config tests #integration", function() | |||
| 55 | local output = run.luarocks("config --lua-incdir") | 55 | local output = run.luarocks("config --lua-incdir") |
| 56 | assert.match(hardcoded.LUA_DIR, output, 1, true) | 56 | assert.match(hardcoded.LUA_DIR, output, 1, true) |
| 57 | end) | 57 | end) |
| 58 | 58 | ||
| 59 | it("--lua-libdir returns a subdir of LUA_DIR", function() | 59 | it("--lua-libdir returns a subdir of LUA_DIR", function() |
| 60 | local output = run.luarocks("config --lua-libdir") | 60 | local output = run.luarocks("config --lua-libdir") |
| 61 | assert.match(hardcoded.LUA_DIR, output, 1, true) | 61 | assert.match(hardcoded.LUA_DIR, output, 1, true) |
| 62 | end) | 62 | end) |
| 63 | 63 | ||
| 64 | it("--lua-ver returns the Lua version", function() | 64 | it("--lua-ver returns the Lua version", function() |
| 65 | local output = run.luarocks("config --lua-ver") | 65 | local output = run.luarocks("config --lua-ver") |
| 66 | local lua_version = _VERSION:gsub("Lua ", "") | 66 | local lua_version = _VERSION:gsub("Lua ", "") |
| @@ -69,17 +69,17 @@ describe("LuaRocks config tests #integration", function() | |||
| 69 | end | 69 | end |
| 70 | assert.are.same(lua_version, output) | 70 | assert.are.same(lua_version, output) |
| 71 | end) | 71 | end) |
| 72 | 72 | ||
| 73 | it("--rock-trees lists rock trees", function() | 73 | it("--rock-trees lists rock trees", function() |
| 74 | assert.is_true(run.luarocks_bool("config --rock-trees")) | 74 | assert.is_true(run.luarocks_bool("config --rock-trees")) |
| 75 | end) | 75 | end) |
| 76 | 76 | ||
| 77 | describe("--user-config", function() | 77 | describe("--user-config", function() |
| 78 | it("returns user config dir", function() | 78 | it("returns user config dir", function() |
| 79 | local user_config_path = run.luarocks("config --user-config") | 79 | local user_config_path = run.luarocks("config --user-config") |
| 80 | assert.is.truthy(lfs.attributes(user_config_path)) | 80 | assert.is.truthy(lfs.attributes(user_config_path)) |
| 81 | end) | 81 | end) |
| 82 | 82 | ||
| 83 | it("handles a missing user config", function() | 83 | it("handles a missing user config", function() |
| 84 | local output = run.luarocks("config --user-config", {LUAROCKS_CONFIG = "missing_file.lua"}) | 84 | local output = run.luarocks("config --user-config", {LUAROCKS_CONFIG = "missing_file.lua"}) |
| 85 | assert.match("Warning", output) | 85 | assert.match("Warning", output) |
| @@ -89,7 +89,7 @@ describe("LuaRocks config tests #integration", function() | |||
| 89 | describe("--system-config", function() | 89 | describe("--system-config", function() |
| 90 | local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" | 90 | local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" |
| 91 | local configfile = scdir .. "/config-" .. env_variables.LUA_VERSION .. ".lua" | 91 | local configfile = scdir .. "/config-" .. env_variables.LUA_VERSION .. ".lua" |
| 92 | 92 | ||
| 93 | it("fails if system config doesn't exist", function() | 93 | it("fails if system config doesn't exist", function() |
| 94 | os.rename(configfile, configfile .. ".bak") | 94 | os.rename(configfile, configfile .. ".bak") |
| 95 | finally(function() | 95 | finally(function() |
| @@ -97,28 +97,28 @@ describe("LuaRocks config tests #integration", function() | |||
| 97 | end) | 97 | end) |
| 98 | assert.is_false(run.luarocks_bool("config --system-config")) | 98 | assert.is_false(run.luarocks_bool("config --system-config")) |
| 99 | end) | 99 | end) |
| 100 | 100 | ||
| 101 | it("outputs the path of the system config", function() | 101 | it("outputs the path of the system config", function() |
| 102 | lfs.mkdir(testing_paths.testing_lrprefix) | 102 | lfs.mkdir(testing_paths.testing_lrprefix) |
| 103 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") | 103 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") |
| 104 | lfs.mkdir(scdir) | 104 | lfs.mkdir(scdir) |
| 105 | 105 | ||
| 106 | local sysconfig = io.open(configfile, "w+") | 106 | local sysconfig = io.open(configfile, "w+") |
| 107 | sysconfig:write(" ") | 107 | sysconfig:write(" ") |
| 108 | sysconfig:close() | 108 | sysconfig:close() |
| 109 | finally(function() | 109 | finally(function() |
| 110 | os.remove(configfile) | 110 | os.remove(configfile) |
| 111 | end) | 111 | end) |
| 112 | 112 | ||
| 113 | local output = run.luarocks("config --system-config") | 113 | local output = run.luarocks("config --system-config") |
| 114 | assert.are.same(configfile, output) | 114 | assert.are.same(configfile, output) |
| 115 | end) | 115 | end) |
| 116 | 116 | ||
| 117 | it("fails if system config is invalid", function() | 117 | it("fails if system config is invalid", function() |
| 118 | lfs.mkdir(testing_paths.testing_lrprefix) | 118 | lfs.mkdir(testing_paths.testing_lrprefix) |
| 119 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") | 119 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") |
| 120 | lfs.mkdir(scdir) | 120 | lfs.mkdir(scdir) |
| 121 | 121 | ||
| 122 | local sysconfig = io.open(configfile, "w+") | 122 | local sysconfig = io.open(configfile, "w+") |
| 123 | sysconfig:write("if if if") | 123 | sysconfig:write("if if if") |
| 124 | sysconfig:close() | 124 | sysconfig:close() |
| @@ -176,7 +176,7 @@ describe("LuaRocks config tests #integration", function() | |||
| 176 | local myproject = tmpdir .. "/myproject" | 176 | local myproject = tmpdir .. "/myproject" |
| 177 | lfs.mkdir(myproject) | 177 | lfs.mkdir(myproject) |
| 178 | lfs.chdir(myproject) | 178 | lfs.chdir(myproject) |
| 179 | 179 | ||
| 180 | assert(run.luarocks("init")) | 180 | assert(run.luarocks("init")) |
| 181 | assert.truthy(run.luarocks_bool("config my_var my_value")) | 181 | assert.truthy(run.luarocks_bool("config my_var my_value")) |
| 182 | 182 | ||
| @@ -206,7 +206,7 @@ describe("LuaRocks config tests #integration", function() | |||
| 206 | local myproject = tmpdir .. "/myproject" | 206 | local myproject = tmpdir .. "/myproject" |
| 207 | lfs.mkdir(myproject) | 207 | lfs.mkdir(myproject) |
| 208 | lfs.chdir(myproject) | 208 | lfs.chdir(myproject) |
| 209 | 209 | ||
| 210 | assert(run.luarocks("init")) | 210 | assert(run.luarocks("init")) |
| 211 | assert.truthy(run.luarocks_bool("config web_browser foo --scope=project")) | 211 | assert.truthy(run.luarocks_bool("config web_browser foo --scope=project")) |
| 212 | 212 | ||
| @@ -220,7 +220,7 @@ describe("LuaRocks config tests #integration", function() | |||
| 220 | local myproject = tmpdir .. "/myproject" | 220 | local myproject = tmpdir .. "/myproject" |
| 221 | lfs.mkdir(myproject) | 221 | lfs.mkdir(myproject) |
| 222 | lfs.chdir(myproject) | 222 | lfs.chdir(myproject) |
| 223 | 223 | ||
| 224 | assert(run.luarocks("init")) | 224 | assert(run.luarocks("init")) |
| 225 | assert.truthy(run.luarocks_bool("config variables.FOO_DIR /foo/bar --scope=project")) | 225 | assert.truthy(run.luarocks_bool("config variables.FOO_DIR /foo/bar --scope=project")) |
| 226 | 226 | ||
| @@ -234,7 +234,7 @@ describe("LuaRocks config tests #integration", function() | |||
| 234 | local myproject = tmpdir .. "/myproject" | 234 | local myproject = tmpdir .. "/myproject" |
| 235 | lfs.mkdir(myproject) | 235 | lfs.mkdir(myproject) |
| 236 | lfs.chdir(myproject) | 236 | lfs.chdir(myproject) |
| 237 | 237 | ||
| 238 | assert(run.luarocks("init")) | 238 | assert(run.luarocks("init")) |
| 239 | assert.truthy(run.luarocks_bool("config external_deps_patterns.lib[1] testtest --scope=project")) | 239 | assert.truthy(run.luarocks_bool("config external_deps_patterns.lib[1] testtest --scope=project")) |
| 240 | 240 | ||
