diff options
| author | roboo <robo.karasek@gmail.com> | 2016-08-21 21:50:38 +0200 |
|---|---|---|
| committer | roboo <robo.karasek@gmail.com> | 2016-08-21 21:50:38 +0200 |
| commit | 2f3c8648289bb4e22eee5f8ff8d27afca6592fa4 (patch) | |
| tree | 5d4f17b5d949e67edde281e6dbe7142a24b57260 /spec/util_spec.lua | |
| parent | 5cdc22fb3c3a85160cd7c2d49ba10ab113e4a784 (diff) | |
| download | luarocks-2f3c8648289bb4e22eee5f8ff8d27afca6592fa4.tar.gz luarocks-2f3c8648289bb4e22eee5f8ff8d27afca6592fa4.tar.bz2 luarocks-2f3c8648289bb4e22eee5f8ff8d27afca6592fa4.zip | |
Windows and appveyor support for tests
Diffstat (limited to 'spec/util_spec.lua')
| -rw-r--r-- | spec/util_spec.lua | 59 |
1 files changed, 39 insertions, 20 deletions
diff --git a/spec/util_spec.lua b/spec/util_spec.lua index 23e3ebd8..e6776e4b 100644 --- a/spec/util_spec.lua +++ b/spec/util_spec.lua | |||
| @@ -27,7 +27,7 @@ describe("Basic tests #blackbox #b_util", function() | |||
| 27 | assert.is_false(run.luarocks_bool("invalid=5")) | 27 | assert.is_false(run.luarocks_bool("invalid=5")) |
| 28 | end) | 28 | end) |
| 29 | 29 | ||
| 30 | it("LuaRocks execute from not existing directory", function() | 30 | it("LuaRocks execute from not existing directory #unix", function() |
| 31 | local main_path = lfs.currentdir() | 31 | local main_path = lfs.currentdir() |
| 32 | assert.is_true(lfs.mkdir("idontexist")) | 32 | assert.is_true(lfs.mkdir("idontexist")) |
| 33 | assert.is_true(lfs.chdir("idontexist")) | 33 | assert.is_true(lfs.chdir("idontexist")) |
| @@ -66,34 +66,53 @@ describe("Basic tests #blackbox #b_util", function() | |||
| 66 | assert.is.truthy(lfs.attributes("src/luarocks/site_config.lua")) | 66 | assert.is.truthy(lfs.attributes("src/luarocks/site_config.lua")) |
| 67 | end) | 67 | end) |
| 68 | 68 | ||
| 69 | describe("LuaRocks sysconfig fails", function() | 69 | -- Disable versioned config temporarily, because it always takes |
| 70 | local scdir = "" | 70 | -- precedence over config.lua (config-5.x.lua is installed by default on Windows, |
| 71 | 71 | -- but not on Unix, so on Unix the os.rename commands below will fail silently, but this is harmless) | |
| 72 | before_each(function() | 72 | describe("LuaRocks config - more complex tests", function() |
| 73 | scdir = testing_paths.testing_lrprefix .. "/etc/luarocks/" | 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() | ||
| 74 | lfs.mkdir(testing_paths.testing_lrprefix) | 92 | lfs.mkdir(testing_paths.testing_lrprefix) |
| 75 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") | 93 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") |
| 76 | lfs.mkdir(scdir) | 94 | lfs.mkdir(scdir) |
| 77 | end) | ||
| 78 | |||
| 79 | after_each(function() | ||
| 80 | test_env.remove_dir(testing_paths.testing_lrprefix) | ||
| 81 | end) | ||
| 82 | 95 | ||
| 83 | it("LuaRocks sysconfig fail", function() | 96 | local sysconfig = io.open(configfile, "w+") |
| 84 | local sysconfig = io.open(scdir .. "/config.lua", "w+") | 97 | sysconfig:write(" ") |
| 85 | sysconfig:write("aoeui") | ||
| 86 | sysconfig:close() | 98 | sysconfig:close() |
| 87 | 99 | ||
| 88 | assert.is_false(run.luarocks_bool("list")) | 100 | local output = run.luarocks("config --system-config") |
| 101 | os.remove(configfile) | ||
| 102 | assert.are.same(output, configfile) | ||
| 89 | end) | 103 | end) |
| 90 | 104 | ||
| 91 | it("LuaRocks sysconfig fail", function() | 105 | it("LuaRocks fail system config invalid", function() |
| 92 | local sysconfig = io.open(scdir .. "/config-" .. env_variables.LUA_VERSION .. ".lua", "w+") | 106 | lfs.mkdir(testing_paths.testing_lrprefix) |
| 93 | sysconfig:write("aoeui") | 107 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") |
| 94 | sysconfig:close() | 108 | lfs.mkdir(scdir) |
| 95 | 109 | ||
| 96 | assert.is_false(run.luarocks_bool("list")) | 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) | ||
| 97 | end) | 116 | end) |
| 98 | end) | 117 | end) |
| 99 | end) | 118 | end) |
