diff options
| author | Hisham <hisham@gobolinux.org> | 2016-10-14 16:38:51 -0700 |
|---|---|---|
| committer | Hisham <hisham@gobolinux.org> | 2016-10-14 16:38:51 -0700 |
| commit | 075196e8b5d315888a8ae110fa9a18089044ae3b (patch) | |
| tree | eca3eb78c23f8d85dbe625564a2d66966d6281f1 /spec/config_spec.lua | |
| parent | dbca97cdcc15e386554b2631a0ae7aca02500abf (diff) | |
| parent | 1fea0e3a0972bcc6b4319cd3d9e79834562486bc (diff) | |
| download | luarocks-075196e8b5d315888a8ae110fa9a18089044ae3b.tar.gz luarocks-075196e8b5d315888a8ae110fa9a18089044ae3b.tar.bz2 luarocks-075196e8b5d315888a8ae110fa9a18089044ae3b.zip | |
Merge branch 'master' into luarocks-3
Diffstat (limited to 'spec/config_spec.lua')
| -rw-r--r-- | spec/config_spec.lua | 70 |
1 files changed, 51 insertions, 19 deletions
diff --git a/spec/config_spec.lua b/spec/config_spec.lua index 0dee8620..4a7f4aea 100644 --- a/spec/config_spec.lua +++ b/spec/config_spec.lua | |||
| @@ -2,6 +2,7 @@ local test_env = require("test/test_environment") | |||
| 2 | local lfs = require("lfs") | 2 | local lfs = require("lfs") |
| 3 | local run = test_env.run | 3 | local run = test_env.run |
| 4 | local testing_paths = test_env.testing_paths | 4 | local testing_paths = test_env.testing_paths |
| 5 | local env_variables = test_env.env_variables | ||
| 5 | local site_config | 6 | local site_config |
| 6 | 7 | ||
| 7 | test_env.unload_luarocks() | 8 | test_env.unload_luarocks() |
| @@ -21,12 +22,20 @@ describe("LuaRocks config tests #blackbox #b_config", function() | |||
| 21 | 22 | ||
| 22 | it("LuaRocks config include dir", function() | 23 | it("LuaRocks config include dir", function() |
| 23 | local output = run.luarocks("config --lua-incdir") | 24 | local output = run.luarocks("config --lua-incdir") |
| 24 | assert.are.same(output, site_config.LUA_INCDIR) | 25 | if test_env.TEST_TARGET_OS == "windows" then |
| 26 | assert.are.same(output, site_config.LUA_INCDIR:gsub("\\","/")) | ||
| 27 | else | ||
| 28 | assert.are.same(output, site_config.LUA_INCDIR) | ||
| 29 | end | ||
| 25 | end) | 30 | end) |
| 26 | 31 | ||
| 27 | it("LuaRocks config library dir", function() | 32 | it("LuaRocks config library dir", function() |
| 28 | local output = run.luarocks("config --lua-libdir") | 33 | local output = run.luarocks("config --lua-libdir") |
| 29 | assert.are.same(output, site_config.LUA_LIBDIR) | 34 | if test_env.TEST_TARGET_OS == "windows" then |
| 35 | assert.are.same(output, site_config.LUA_LIBDIR:gsub("\\","/")) | ||
| 36 | else | ||
| 37 | assert.are.same(output, site_config.LUA_LIBDIR) | ||
| 38 | end | ||
| 30 | end) | 39 | end) |
| 31 | 40 | ||
| 32 | it("LuaRocks config lua version", function() | 41 | it("LuaRocks config lua version", function() |
| @@ -53,38 +62,61 @@ describe("LuaRocks config tests #blackbox #b_config", function() | |||
| 53 | end) | 62 | end) |
| 54 | 63 | ||
| 55 | describe("LuaRocks config - more complex tests", function() | 64 | describe("LuaRocks config - more complex tests", function() |
| 65 | local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" | ||
| 66 | local versioned_scname = scdir .. "/config-" .. env_variables.LUA_VERSION .. ".lua" | ||
| 67 | local scname = scdir .. "/config.lua" | ||
| 68 | |||
| 69 | local configfile | ||
| 70 | if test_env.TEST_TARGET_OS == "windows" then | ||
| 71 | configfile = versioned_scname | ||
| 72 | else | ||
| 73 | configfile = scname | ||
| 74 | end | ||
| 75 | |||
| 56 | it("LuaRocks fail system config", function() | 76 | it("LuaRocks fail system config", function() |
| 57 | os.remove(testing_paths.testing_lrprefix .. "/etc/luarocks/config.lua") | 77 | os.rename(configfile, configfile .. ".bak") |
| 58 | assert.is_false(run.luarocks_bool("config --system-config;")) | 78 | assert.is_false(run.luarocks_bool("config --system-config")) |
| 79 | os.rename(configfile .. ".bak", configfile) | ||
| 59 | end) | 80 | end) |
| 60 | 81 | ||
| 61 | it("LuaRocks system config", function() | 82 | it("LuaRocks system config", function() |
| 62 | local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" | ||
| 63 | lfs.mkdir(testing_paths.testing_lrprefix) | 83 | lfs.mkdir(testing_paths.testing_lrprefix) |
| 64 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") | 84 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") |
| 65 | lfs.mkdir(scdir) | 85 | lfs.mkdir(scdir) |
| 66 | 86 | ||
| 67 | local sysconfig = io.open(scdir .. "/config.lua", "w+") | 87 | if test_env.TEST_TARGET_OS == "windows" then |
| 68 | sysconfig:write(" ") | 88 | local output = run.luarocks("config --system-config") |
| 69 | sysconfig:close() | 89 | assert.are.same(output, configfile) |
| 70 | 90 | else | |
| 71 | local output = run.luarocks("config --system-config;") | 91 | local sysconfig = io.open(configfile, "w+") |
| 72 | assert.are.same(output, scdir .. "/config.lua") | 92 | sysconfig:write(" ") |
| 73 | test_env.remove_dir(testing_paths.testing_lrprefix) | 93 | sysconfig:close() |
| 94 | |||
| 95 | local output = run.luarocks("config --system-config") | ||
| 96 | assert.are.same(output, configfile) | ||
| 97 | os.remove(configfile) | ||
| 98 | end | ||
| 74 | end) | 99 | end) |
| 75 | 100 | ||
| 76 | it("LuaRocks fail system config invalid", function() | 101 | it("LuaRocks fail system config invalid", function() |
| 77 | local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" | ||
| 78 | lfs.mkdir(testing_paths.testing_lrprefix) | 102 | lfs.mkdir(testing_paths.testing_lrprefix) |
| 79 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") | 103 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") |
| 80 | lfs.mkdir(scdir) | 104 | lfs.mkdir(scdir) |
| 81 | 105 | ||
| 82 | local sysconfig = io.open(scdir .. "/config.lua", "w+") | 106 | if test_env.TEST_TARGET_OS == "windows" then |
| 83 | sysconfig:write("if if if") | 107 | test_env.copy(configfile, "configfile_temp") |
| 84 | sysconfig:close() | 108 | local sysconfig = io.open(configfile, "w+") |
| 85 | 109 | sysconfig:write("if if if") | |
| 86 | assert.is_false(run.luarocks_bool("config --system-config;")) | 110 | sysconfig:close() |
| 87 | test_env.remove_dir(testing_paths.testing_lrprefix) | 111 | assert.is_false(run.luarocks_bool("config --system-config")) |
| 112 | test_env.copy("configfile_temp", configfile) | ||
| 113 | else | ||
| 114 | local sysconfig = io.open(configfile, "w+") | ||
| 115 | sysconfig:write("if if if") | ||
| 116 | sysconfig:close() | ||
| 117 | assert.is_false(run.luarocks_bool("config --system-config")) | ||
| 118 | os.remove(configfile) | ||
| 119 | end | ||
| 88 | end) | 120 | end) |
| 89 | end) | 121 | end) |
| 90 | end) | 122 | end) |
