aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroboo <robo.karasek@gmail.com>2016-08-21 21:50:38 +0200
committerroboo <robo.karasek@gmail.com>2016-08-21 21:50:38 +0200
commit2f3c8648289bb4e22eee5f8ff8d27afca6592fa4 (patch)
tree5d4f17b5d949e67edde281e6dbe7142a24b57260
parent5cdc22fb3c3a85160cd7c2d49ba10ab113e4a784 (diff)
downloadluarocks-2f3c8648289bb4e22eee5f8ff8d27afca6592fa4.tar.gz
luarocks-2f3c8648289bb4e22eee5f8ff8d27afca6592fa4.tar.bz2
luarocks-2f3c8648289bb4e22eee5f8ff8d27afca6592fa4.zip
Windows and appveyor support for tests
-rw-r--r--spec/add_spec.lua16
-rw-r--r--spec/build_spec.lua89
-rw-r--r--spec/config_spec.lua70
-rw-r--r--spec/deps_spec.lua70
-rw-r--r--spec/install_spec.lua36
-rw-r--r--spec/make_manifest_spec.lua2
-rw-r--r--spec/make_spec.lua43
-rw-r--r--spec/pack_spec.lua18
-rw-r--r--spec/refresh_cache_spec.lua2
-rw-r--r--spec/remove_spec.lua6
-rw-r--r--spec/search_spec.lua1
-rw-r--r--spec/show_spec.lua6
-rw-r--r--spec/unpack_spec.lua18
-rw-r--r--spec/upload_spec.lua14
-rw-r--r--spec/util_spec.lua59
-rw-r--r--test/test_environment.lua173
16 files changed, 408 insertions, 215 deletions
diff --git a/spec/add_spec.lua b/spec/add_spec.lua
index dca6f850..d42a97d0 100644
--- a/spec/add_spec.lua
+++ b/spec/add_spec.lua
@@ -5,8 +5,8 @@ local testing_paths = test_env.testing_paths
5test_env.unload_luarocks() 5test_env.unload_luarocks()
6 6
7local extra_rocks = { 7local extra_rocks = {
8 "/luasocket-3.0rc1-1.src.rock", 8 "/luasocket-3.0rc1-2.src.rock",
9 "/luasocket-3.0rc1-1.rockspec" 9 "/luasocket-3.0rc1-2.rockspec"
10} 10}
11 11
12describe("LuaRocks add tests #blackbox #b_add", function() 12describe("LuaRocks add tests #blackbox #b_add", function()
@@ -25,20 +25,20 @@ describe("LuaRocks add tests #blackbox #b_add", function()
25 end) 25 end)
26 26
27 it("LuaRocks-admin add invalid server", function() 27 it("LuaRocks-admin add invalid server", function()
28 assert.is_false(run.luarocks_admin_bool("--server=invalid add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-1.src.rock")) 28 assert.is_false(run.luarocks_admin_bool("--server=invalid add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.src.rock"))
29 end) 29 end)
30 30
31 it("LuaRocks-admin add invalid server #ssh", function() 31 it("LuaRocks-admin add invalid server #ssh", function()
32 assert.is_true(run.luarocks_admin_bool("--server=testing add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-1.src.rock")) 32 assert.is_true(run.luarocks_admin_bool("--server=testing add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.src.rock"))
33 end) 33 end)
34 34
35 --TODO This test fails, sftp not implemented 35 --TODO This test fails, sftp support not yet implemented
36 it("LuaRocks-admin add invalid server", function() --? 36 it("LuaRocks-admin add invalid server", function()
37 assert.is_false(run.luarocks_admin_bool("--server=testing add luasocket-3.0rc1-1.src.rock", { LUAROCKS_CONFIG = testing_paths.testing_dir .. "/testing_config_sftp.lua" } )) 37 assert.is_false(run.luarocks_admin_bool("--server=testing add luasocket-3.0rc1-2.src.rock", { LUAROCKS_CONFIG = testing_paths.testing_dir .. "/testing_config_sftp.lua" } ))
38 end) 38 end)
39 39
40 it("LuaRocks-admin add, split server url", function() 40 it("LuaRocks-admin add, split server url", function()
41 assert.is_false(run.luarocks_admin_bool("--server=\"localhost@/tmp/luarocks_testing\" add " .. testing_paths.testing_server .. "luasocket-3.0rc1-1.src.rock")) 41 assert.is_false(run.luarocks_admin_bool("--server=\"localhost@/tmp/luarocks_testing\" add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.src.rock"))
42 end) 42 end)
43 end) 43 end)
44end) 44end)
diff --git a/spec/build_spec.lua b/spec/build_spec.lua
index 2ede5211..b4f838ca 100644
--- a/spec/build_spec.lua
+++ b/spec/build_spec.lua
@@ -12,15 +12,16 @@ local extra_rocks = {
12 "/lmathx-20120430.52-1.rockspec", 12 "/lmathx-20120430.52-1.rockspec",
13 "/lmathx-20150505-1.src.rock", 13 "/lmathx-20150505-1.src.rock",
14 "/lmathx-20150505-1.rockspec", 14 "/lmathx-20150505-1.rockspec",
15 "/lpeg-0.12-1.src.rock", 15 "/lpeg-1.0.0-1.rockspec",
16 "/lpeg-1.0.0-1.src.rock",
16 "/lpty-1.0.1-1.src.rock", 17 "/lpty-1.0.1-1.src.rock",
17 "/luadoc-3.0.1-1.src.rock", 18 "/luadoc-3.0.1-1.src.rock",
18 "/luafilesystem-1.6.3-1.src.rock", 19 "/luafilesystem-1.6.3-1.src.rock",
19 "/lualogging-1.3.0-1.src.rock", 20 "/lualogging-1.3.0-1.src.rock",
20 "/luarepl-0.4-1.src.rock", 21 "/luarepl-0.4-1.src.rock",
21 "/luasec-0.6-1.rockspec", 22 "/luasec-0.6-1.rockspec",
22 "/luasocket-3.0rc1-1.src.rock", 23 "/luasocket-3.0rc1-2.src.rock",
23 "/luasocket-3.0rc1-1.rockspec", 24 "/luasocket-3.0rc1-2.rockspec",
24 "/lxsh-0.8.6-2.src.rock", 25 "/lxsh-0.8.6-2.src.rock",
25 "/lxsh-0.8.6-2.rockspec", 26 "/lxsh-0.8.6-2.rockspec",
26 "/stdlib-41.0.0-1.src.rock", 27 "/stdlib-41.0.0-1.src.rock",
@@ -57,27 +58,35 @@ describe("LuaRocks build tests #blackbox #b_build", function()
57 end) 58 end)
58 59
59 it("LuaRocks build lpeg verbose", function() 60 it("LuaRocks build lpeg verbose", function()
60 assert.is.truthy(run.luarocks("build --verbose lpeg")) 61 assert.is_true(run.luarocks_bool("build --verbose lpeg"))
61 end) 62 end)
62 63
63 it("LuaRocks build lpeg branch=master", function() 64 it("LuaRocks build lpeg branch=master", function()
64 assert.is_true(run.luarocks_bool("build --branch=master lpeg")) 65 assert.is_true(run.luarocks_bool("build --branch=master lpeg"))
65 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) 66 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
66 end) 67 end)
67 68
68 it("LuaRocks build lpeg deps-mode=123", function() 69 it("LuaRocks build lpeg deps-mode=123", function()
69 assert.is_false(run.luarocks_bool("build --deps-mode=123 lpeg")) 70 assert.is_false(run.luarocks_bool("build --deps-mode=123 lpeg --verbose"))
70 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) 71 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
71 end) 72 end)
72 73
73 it("LuaRocks build lpeg only-sources example", function() 74 it("LuaRocks build lpeg only-sources example", function()
74 assert.is_true(run.luarocks_bool("build --only-sources=\"http://example.com\" lpeg")) 75 assert.is_true(run.luarocks_bool("download --rockspec lpeg"))
75 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) 76 assert.is_false(run.luarocks_bool("build --only-sources=\"http://example.com\" lpeg-1.0.0-1.rockspec"))
77 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
78
79 assert.is_true(run.luarocks_bool("download --source lpeg"))
80 assert.is_true(run.luarocks_bool("build --only-sources=\"http://example.com\" lpeg-1.0.0-1.src.rock"))
81 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
82
83 assert.is_true(os.remove("lpeg-1.0.0-1.rockspec"))
84 assert.is_true(os.remove("lpeg-1.0.0-1.src.rock"))
76 end) 85 end)
77 86
78 it("LuaRocks build lpeg with empty tree", function() 87 it("LuaRocks build lpeg with empty tree", function()
79 assert.is_false(run.luarocks_bool("build --tree=\"\" lpeg")) 88 assert.is_false(run.luarocks_bool("build --tree=\"\" lpeg"))
80 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) 89 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
81 end) 90 end)
82 end) 91 end)
83 92
@@ -88,32 +97,47 @@ describe("LuaRocks build tests #blackbox #b_build", function()
88 97
89 it("LuaRocks build luacov diff version", function() 98 it("LuaRocks build luacov diff version", function()
90 assert.is_true(run.luarocks_bool("build luacov 0.11.0-1")) 99 assert.is_true(run.luarocks_bool("build luacov 0.11.0-1"))
91 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luacov")) 100 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luacov/0.11.0-1/luacov-0.11.0-1.rockspec"))
92 end) 101 end)
93 102
94 it("LuaRocks build command stdlib", function() 103 it("LuaRocks build command stdlib", function()
95 assert.is_true(run.luarocks_bool("build stdlib")) 104 assert.is_true(run.luarocks_bool("build stdlib"))
96 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/stdlib")) 105 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/stdlib/41.0.0-1/stdlib-41.0.0-1.rockspec"))
97 end) 106 end)
98 107
99 it("LuaRocks build install bin luarepl", function() 108 it("LuaRocks build install bin luarepl", function()
100 assert.is_true(run.luarocks_bool("build luarepl")) 109 assert.is_true(run.luarocks_bool("build luarepl"))
101 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luarepl")) 110 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luarepl/0.4-1/luarepl-0.4-1.rockspec"))
102 end) 111 end)
103 112
104 it("LuaRocks build supported platforms lpty", function() 113 it("LuaRocks build supported platforms lpty", function()
105 assert.is_true(run.luarocks_bool(test_env.quiet("build lpty"))) 114 if test_env.TEST_TARGET_OS == "windows" then
106 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpty")) 115 assert.is_false(run.luarocks_bool("build lpty")) --Error: This rockspec for lpty does not support win32, windows platforms
116 else
117 assert.is_true(run.luarocks_bool(test_env.quiet("build lpty")))
118 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpty/1.0.1-1/lpty-1.0.1-1.rockspec"))
119 end
107 end) 120 end)
108 121
109 it("LuaRocks build luasec with skipping dependency checks", function() 122 it("LuaRocks build luasec with skipping dependency checks", function()
110 assert.is_true(run.luarocks_bool(test_env.quiet("build luasec --nodeps"))) 123 if test_env.APPVEYOR then
111 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec")) 124 assert.is_true(run.luarocks_bool("build luasec " .. test_env.APPVEYOR_OPENSSL .. " --nodeps"))
125 else
126 assert.is_true(run.luarocks_bool("build luasec --nodeps"))
127 end
128 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec/0.6-1/luasec-0.6-1.rockspec"))
112 end) 129 end)
113 130
114 it("LuaRocks build lmathx deps partial match", function() 131 it("LuaRocks build lmathx deps partial match", function()
115 assert.is_true(run.luarocks_bool("build lmathx")) 132 assert.is_true(run.luarocks_bool("build lmathx"))
116 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lmathx")) 133
134 if test_env.LUA_V == "5.1" or test_env.LUAJIT_V then
135 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lmathx/20120430.51-1/lmathx-20120430.51-1.rockspec"))
136 elseif test_env.LUA_V == "5.2" then
137 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lmathx/20120430.52-1/lmathx-20120430.52-1.rockspec"))
138 elseif test_env.LUA_V == "5.3" then
139 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lmathx/20150505-1/lmathx-20150505-1.rockspec"))
140 end
117 end) 141 end)
118 end) 142 end)
119 143
@@ -126,17 +150,21 @@ describe("LuaRocks build tests #blackbox #b_build", function()
126 end 150 end
127 151
128 it("LuaRocks build luasec only deps", function() 152 it("LuaRocks build luasec only deps", function()
129 assert.is_true(run.luarocks_bool(test_env.quiet("build luasec --only-deps"))) 153 if test_env.APPVEYOR then
154 assert.is_true(run.luarocks_bool(test_env.quiet("build luasec " .. test_env.APPVEYOR_OPENSSL .. " --only-deps")))
155 else
156 assert.is_true(run.luarocks_bool(test_env.quiet("build luasec --only-deps")))
157 end
130 assert.is_false(run.luarocks_bool("show luasec")) 158 assert.is_false(run.luarocks_bool("show luasec"))
131 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec")) 159 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec/0.6-1/luasec-0.6-1.rockspec"))
132 end) 160 end)
133 161
134 it("LuaRocks build only deps of downloaded rockspec of lxsh", function() 162 it("LuaRocks build only deps of downloaded rockspec of lxsh", function()
135 assert.is_true(run.luarocks_bool("download --rockspec lxsh 0.8.6-2")) 163 assert.is_true(run.luarocks_bool("download --rockspec lxsh 0.8.6-2"))
136 assert.is.truthy(run.luarocks("build lxsh-0.8.6-2.rockspec --only-deps")) 164 assert.is.truthy(run.luarocks("build lxsh-0.8.6-2.rockspec --only-deps"))
137 assert.is_false(run.luarocks_bool("show lxsh")) 165 assert.is_false(run.luarocks_bool("show lxsh"))
138 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) 166 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
139 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) 167 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
140 assert.is_true(os.remove("lxsh-0.8.6-2.rockspec")) 168 assert.is_true(os.remove("lxsh-0.8.6-2.rockspec"))
141 end) 169 end)
142 170
@@ -144,8 +172,8 @@ describe("LuaRocks build tests #blackbox #b_build", function()
144 assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6-2")) 172 assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6-2"))
145 assert.is.truthy(run.luarocks("build lxsh-0.8.6-2.src.rock --only-deps")) 173 assert.is.truthy(run.luarocks("build lxsh-0.8.6-2.src.rock --only-deps"))
146 assert.is_false(run.luarocks_bool("show lxsh")) 174 assert.is_false(run.luarocks_bool("show lxsh"))
147 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) 175 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
148 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) 176 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
149 assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) 177 assert.is_true(os.remove("lxsh-0.8.6-2.src.rock"))
150 end) 178 end)
151 179
@@ -154,19 +182,22 @@ describe("LuaRocks build tests #blackbox #b_build", function()
154 assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec")) 182 assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec"))
155 183
156 assert.is.truthy(run.luarocks("show validate-args")) 184 assert.is.truthy(run.luarocks("show validate-args"))
157 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args")) 185 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args/1.5.4-1/validate-args-1.5.4-1.rockspec"))
158 186
159 assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) 187 assert.is_true(os.remove("validate-args-1.5.4-1.rockspec"))
160 end) 188 end)
161 189
162 it("LuaRocks build with https", function() 190 it("LuaRocks build with https", function()
163 assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) 191 assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1"))
164 assert.is_true(run.luarocks_bool(test_env.quiet("install luasec"))) 192
193 if test_env.APPVEYOR then
194 assert.is_true(run.luarocks_bool(test_env.quiet("install luasec " .. test_env.APPVEYOR_OPENSSL)))
195 else
196 assert.is_true(run.luarocks_bool(test_env.quiet("install luasec")))
197 end
165 assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec")) 198 assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec"))
166
167 assert.is.truthy(run.luarocks("show validate-args")) 199 assert.is.truthy(run.luarocks("show validate-args"))
168 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args")) 200 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args/1.5.4-1/validate-args-1.5.4-1.rockspec"))
169
170 assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) 201 assert.is_true(os.remove("validate-args-1.5.4-1.rockspec"))
171 end) 202 end)
172 203
diff --git a/spec/config_spec.lua b/spec/config_spec.lua
index 0dee8620..439d0493 100644
--- a/spec/config_spec.lua
+++ b/spec/config_spec.lua
@@ -2,6 +2,7 @@ local test_env = require("test/test_environment")
2local lfs = require("lfs") 2local lfs = require("lfs")
3local run = test_env.run 3local run = test_env.run
4local testing_paths = test_env.testing_paths 4local testing_paths = test_env.testing_paths
5local env_variables = test_env.env_variables
5local site_config 6local site_config
6 7
7test_env.unload_luarocks() 8test_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(versioned_scname, versioned_scname .. ".bak")
58 assert.is_false(run.luarocks_bool("config --system-config;")) 78 assert.is_false(run.luarocks_bool("config --system-config"))
79 os.rename(versioned_scname .. ".bak", versioned_scname)
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, versioned_scname)
70 90 else
71 local output = run.luarocks("config --system-config;") 91 sysconfig = io.open(scname, "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, scname)
97 os.remove(scname)
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(versioned_scname, "versioned_scname_temp")
84 sysconfig:close() 108 sysconfig = io.open(versioned_scname, "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("versioned_scname_temp", versioned_scname)
113 else
114 sysconfig = io.open(scname, "w+")
115 sysconfig:write("if if if")
116 sysconfig:close()
117 assert.is_false(run.luarocks_bool("config --system-config"))
118 os.remove(scname)
119 end
88 end) 120 end)
89 end) 121 end)
90end) 122end)
diff --git a/spec/deps_spec.lua b/spec/deps_spec.lua
index c1bd404d..e453c9a1 100644
--- a/spec/deps_spec.lua
+++ b/spec/deps_spec.lua
@@ -8,9 +8,9 @@ test_env.unload_luarocks()
8local extra_rocks = { 8local extra_rocks = {
9 "/lxsh-0.8.6-2.src.rock", 9 "/lxsh-0.8.6-2.src.rock",
10 "/lxsh-0.8.6-2.rockspec", 10 "/lxsh-0.8.6-2.rockspec",
11 "/luasocket-3.0rc1-1.src.rock", 11 "/luasocket-3.0rc1-2.src.rock",
12 "/luasocket-3.0rc1-1.rockspec", 12 "/luasocket-3.0rc1-2.rockspec",
13 "/lpeg-0.12-1.src.rock" 13 "/lpeg-1.0.0-1.src.rock",
14} 14}
15 15
16describe("LuaRocks deps tests #blackbox #b_deps", function() 16describe("LuaRocks deps tests #blackbox #b_deps", function()
@@ -23,59 +23,59 @@ describe("LuaRocks deps tests #blackbox #b_deps", function()
23 assert.is_true(run.luarocks_bool("build --tree=system lpeg")) 23 assert.is_true(run.luarocks_bool("build --tree=system lpeg"))
24 assert.is_true(run.luarocks_bool("build --deps-mode=one --tree=" .. testing_paths.testing_tree .. " lxsh")) 24 assert.is_true(run.luarocks_bool("build --deps-mode=one --tree=" .. testing_paths.testing_tree .. " lxsh"))
25 25
26 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) 26 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
27 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) 27 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
28 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) 28 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
29 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) 29 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
30 end) 30 end)
31 31
32 it("LuaRocks deps mode order", function() 32 it("LuaRocks deps mode order", function()
33 assert.is_true(run.luarocks_bool("build --tree=system lpeg")) 33 assert.is_true(run.luarocks_bool("build --tree=system lpeg"))
34 assert.is_true(run.luarocks_bool("build --deps-mode=order --tree=" .. testing_paths.testing_tree .. " lxsh")) 34 assert.is_true(run.luarocks_bool("build --deps-mode=order --tree=" .. testing_paths.testing_tree .. " lxsh"))
35 35
36 assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) 36 assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
37 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) 37 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
38 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) 38 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
39 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) 39 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
40 end) 40 end)
41 41
42 it("LuaRocks deps mode order sys", function() 42 it("LuaRocks deps mode order sys", function()
43 assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg")) 43 assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg"))
44 assert.is_true(run.luarocks_bool("build --deps-mode=order --tree=" .. testing_paths.testing_sys_tree .. " lxsh")) 44 assert.is_true(run.luarocks_bool("build --deps-mode=order --tree=" .. testing_paths.testing_sys_tree .. " lxsh"))
45 45
46 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) 46 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
47 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) 47 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
48 assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) 48 assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
49 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) 49 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
50 end) 50 end)
51 51
52 it("LuaRocks deps mode all sys", function() 52 it("LuaRocks deps mode all sys", function()
53 assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg")) 53 assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg"))
54 assert.is_true(run.luarocks_bool("build --deps-mode=all --tree=" .. testing_paths.testing_sys_tree .. " lxsh")) 54 assert.is_true(run.luarocks_bool("build --deps-mode=all --tree=" .. testing_paths.testing_sys_tree .. " lxsh"))
55 55
56 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) 56 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
57 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) 57 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
58 assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) 58 assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
59 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) 59 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
60 end) 60 end)
61 61
62 it("LuaRocks deps mode none", function() 62 it("LuaRocks deps mode none", function()
63 assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg")) 63 assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg"))
64 assert.is_true(run.luarocks_bool("build --deps-mode=none lxsh")) 64 assert.is_true(run.luarocks_bool("build --deps-mode=none lxsh"))
65 65
66 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) 66 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
67 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) 67 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
68 assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) 68 assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
69 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) 69 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
70 end) 70 end)
71 71
72 it("LuaRocks nodeps alias", function() 72 it("LuaRocks nodeps alias", function()
73 assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " --nodeps lxsh")) 73 assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " --nodeps lxsh"))
74 74
75 assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) 75 assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
76 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) 76 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
77 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) 77 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
78 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) 78 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
79 end) 79 end)
80 80
81 it("LuaRocks deps mode make order", function() 81 it("LuaRocks deps mode make order", function()
@@ -89,10 +89,10 @@ describe("LuaRocks deps tests #blackbox #b_deps", function()
89 test_env.remove_dir("lxsh-0.8.6-2") 89 test_env.remove_dir("lxsh-0.8.6-2")
90 assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) 90 assert.is_true(os.remove("lxsh-0.8.6-2.src.rock"))
91 91
92 assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) 92 assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
93 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) 93 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
94 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) 94 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
95 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) 95 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
96 end) 96 end)
97 97
98 it("LuaRocks deps mode make order sys", function() 98 it("LuaRocks deps mode make order sys", function()
@@ -106,9 +106,9 @@ describe("LuaRocks deps tests #blackbox #b_deps", function()
106 test_env.remove_dir("lxsh-0.8.6-2") 106 test_env.remove_dir("lxsh-0.8.6-2")
107 assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) 107 assert.is_true(os.remove("lxsh-0.8.6-2.src.rock"))
108 108
109 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) 109 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
110 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) 110 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
111 assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) 111 assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
112 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) 112 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
113 end) 113 end)
114end) 114end)
diff --git a/spec/install_spec.lua b/spec/install_spec.lua
index bd480c21..2b6cb77f 100644
--- a/spec/install_spec.lua
+++ b/spec/install_spec.lua
@@ -12,8 +12,8 @@ local extra_rocks = {
12 "/lpeg-0.12-1.src.rock", 12 "/lpeg-0.12-1.src.rock",
13 "/luasec-0.6-1.rockspec", 13 "/luasec-0.6-1.rockspec",
14 "/luassert-1.7.0-1.src.rock", 14 "/luassert-1.7.0-1.src.rock",
15 "/luasocket-3.0rc1-1.src.rock", 15 "/luasocket-3.0rc1-2.src.rock",
16 "/luasocket-3.0rc1-1.rockspec", 16 "/luasocket-3.0rc1-2.rockspec",
17 "/lxsh-0.8.6-2.src.rock", 17 "/lxsh-0.8.6-2.src.rock",
18 "/lxsh-0.8.6-2.rockspec", 18 "/lxsh-0.8.6-2.rockspec",
19 "/say-1.2-1.src.rock", 19 "/say-1.2-1.src.rock",
@@ -44,8 +44,8 @@ describe("LuaRocks install tests #blackbox #b_install", function()
44 assert.is_false(run.luarocks_bool("install \"invalid.rock\" ")) 44 assert.is_false(run.luarocks_bool("install \"invalid.rock\" "))
45 end) 45 end)
46 46
47 it("LuaRocks install with local flag as root", function() 47 it("LuaRocks install with local flag as root #unix", function()
48 assert.is_false(run.luarocks_bool("install --local luasocket", { USER = "root" } )) 48 assert.is_false(run.luarocks_bool("install --local luasocket ", { USER = "root" } ))
49 end) 49 end)
50 50
51 it("LuaRocks install not a zip file", function() 51 it("LuaRocks install not a zip file", function()
@@ -66,14 +66,22 @@ describe("LuaRocks install tests #blackbox #b_install", function()
66 end) 66 end)
67 67
68 it("LuaRocks install luasec and show luasocket (dependency)", function() 68 it("LuaRocks install luasec and show luasocket (dependency)", function()
69 assert.is_true(run.luarocks_bool("install luasec")) 69 if test_env.APPVEYOR then
70 assert.is_true(run.luarocks_bool(test_env.quiet("install luasec " .. test_env.APPVEYOR_OPENSSL)))
71 else
72 assert.is_true(run.luarocks_bool(test_env.quiet("install luasec")))
73 end
70 assert.is_true(run.luarocks_bool("show luasocket")) 74 assert.is_true(run.luarocks_bool("show luasocket"))
71 end) 75 end)
72 end) 76 end)
73 77
74 describe("LuaRocks install - more complex tests", function() 78 describe("LuaRocks install - more complex tests", function()
75 it('LuaRocks install luasec with skipping dependency checks', function() 79 it('LuaRocks install luasec with skipping dependency checks', function()
76 run.luarocks_bool(test_env.quiet(" install luasec --nodeps")) 80 if test_env.APPVEYOR then
81 assert.is_true(run.luarocks_bool(test_env.quiet("install luasec " .. test_env.APPVEYOR_OPENSSL .. " --nodeps")))
82 else
83 assert.is_true(run.luarocks_bool(test_env.quiet("install luasec --nodeps")))
84 end
77 assert.is_true(run.luarocks_bool(test_env.quiet("show luasec"))) 85 assert.is_true(run.luarocks_bool(test_env.quiet("show luasec")))
78 if env_variables.TYPE_TEST_ENV == "minimal" then 86 if env_variables.TYPE_TEST_ENV == "minimal" then
79 assert.is_false(run.luarocks_bool(test_env.quiet("show luasocket"))) 87 assert.is_false(run.luarocks_bool(test_env.quiet("show luasocket")))
@@ -83,17 +91,17 @@ describe("LuaRocks install tests #blackbox #b_install", function()
83 end) 91 end)
84 92
85 it("LuaRocks install only-deps of luasocket packed rock", function() 93 it("LuaRocks install only-deps of luasocket packed rock", function()
86 assert.is_true(run.luarocks_bool(test_env.quiet("build --pack-binary-rock luasocket 3.0rc1-1"))) 94 assert.is_true(run.luarocks_bool(test_env.quiet("build --pack-binary-rock luasocket 3.0rc1-2")))
87 local output = run.luarocks("install --only-deps " .. "luasocket-3.0rc1-1." .. test_env.platform .. ".rock") 95 local output = run.luarocks("install --only-deps " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock")
88 assert.are.same(output, "Successfully installed dependencies for luasocket 3.0rc1-1") 96 assert.are.same(output, "Successfully installed dependencies for luasocket 3.0rc1-2")
89 assert.is_true(os.remove("luasocket-3.0rc1-1." .. test_env.platform .. ".rock")) 97 assert.is_true(os.remove("luasocket-3.0rc1-2." .. test_env.platform .. ".rock"))
90 end) 98 end)
91 99
92 it("LuaRocks install reinstall", function() 100 it("LuaRocks install reinstall", function()
93 assert.is_true(run.luarocks_bool(test_env.quiet("build --pack-binary-rock luasocket 3.0rc1-1"))) 101 assert.is_true(run.luarocks_bool(test_env.quiet("build --pack-binary-rock luasocket 3.0rc1-2")))
94 assert.is_true(run.luarocks_bool("install " .. "luasocket-3.0rc1-1." .. test_env.platform .. ".rock")) 102 assert.is_true(run.luarocks_bool("install " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock"))
95 assert.is_true(run.luarocks_bool("install --deps-mode=none " .. "luasocket-3.0rc1-1." .. test_env.platform .. ".rock")) 103 assert.is_true(run.luarocks_bool("install --deps-mode=none " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock"))
96 assert.is_true(os.remove("luasocket-3.0rc1-1." .. test_env.platform .. ".rock")) 104 assert.is_true(os.remove("luasocket-3.0rc1-2." .. test_env.platform .. ".rock"))
97 end) 105 end)
98 106
99 it("LuaRocks install binary rock of cprint", function() 107 it("LuaRocks install binary rock of cprint", function()
diff --git a/spec/make_manifest_spec.lua b/spec/make_manifest_spec.lua
index 1c7f5bf8..3e998cbf 100644
--- a/spec/make_manifest_spec.lua
+++ b/spec/make_manifest_spec.lua
@@ -4,7 +4,7 @@ local run = test_env.run
4test_env.unload_luarocks() 4test_env.unload_luarocks()
5 5
6describe("LuaRocks make_manifest tests #blackbox #b_make_manifest", function() 6describe("LuaRocks make_manifest tests #blackbox #b_make_manifest", function()
7 7
8 before_each(function() 8 before_each(function()
9 test_env.setup_specs() 9 test_env.setup_specs()
10 end) 10 end)
diff --git a/spec/make_spec.lua b/spec/make_spec.lua
index e684033a..624badff 100644
--- a/spec/make_spec.lua
+++ b/spec/make_spec.lua
@@ -6,9 +6,9 @@ local testing_paths = test_env.testing_paths
6test_env.unload_luarocks() 6test_env.unload_luarocks()
7 7
8local extra_rocks = { 8local extra_rocks = {
9 "/lpeg-0.12-1.src.rock", 9 "lpeg-1.0.0-1.rockspec",
10 "/luasocket-3.0rc1-1.src.rock", 10 "/luasocket-3.0rc1-2.src.rock",
11 "/luasocket-3.0rc1-1.rockspec", 11 "/luasocket-3.0rc1-2.rockspec",
12 "/lxsh-0.8.6-2.src.rock", 12 "/lxsh-0.8.6-2.src.rock",
13 "/lxsh-0.8.6-2.rockspec" 13 "/lxsh-0.8.6-2.rockspec"
14} 14}
@@ -27,19 +27,19 @@ describe("LuaRocks make tests #blackbox #b_make", function()
27 27
28 it("LuaRocks make with rockspec", function() 28 it("LuaRocks make with rockspec", function()
29 -- make luasocket 29 -- make luasocket
30 assert.is_true(run.luarocks_bool("download --source luasocket 3.0rc1-1")) 30 assert.is_true(run.luarocks_bool("download --source luasocket 3.0rc1-2"))
31 assert.is_true(run.luarocks_bool("unpack luasocket-3.0rc1-1.src.rock")) 31 assert.is_true(run.luarocks_bool("unpack luasocket-3.0rc1-2.src.rock"))
32 lfs.chdir("luasocket-3.0rc1-1/luasocket-3.0-rc1/") 32 lfs.chdir("luasocket-3.0rc1-2/luasocket-3.0-rc1/")
33 assert.is_true(run.luarocks_bool(test_env.quiet("make luasocket-3.0rc1-1.rockspec"))) 33 assert.is_true(run.luarocks_bool(test_env.quiet("make luasocket-3.0rc1-2.rockspec")))
34 34
35 -- test it 35 -- test it
36 assert.is_true(run.luarocks_bool(test_env.quiet("show luasocket"))) 36 assert.is_true(run.luarocks_bool(test_env.quiet("show luasocket")))
37 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) 37 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket/3.0rc1-2/luasocket-3.0rc1-2.rockspec"))
38 38
39 -- delete downloaded and unpacked files 39 -- delete downloaded and unpacked files
40 lfs.chdir(testing_paths.luarocks_dir) 40 lfs.chdir(testing_paths.luarocks_dir)
41 test_env.remove_dir("luasocket-3.0rc1-1") 41 test_env.remove_dir("luasocket-3.0rc1-2")
42 assert.is_true(os.remove("luasocket-3.0rc1-1.src.rock")) 42 assert.is_true(os.remove("luasocket-3.0rc1-2.src.rock"))
43 end) 43 end)
44 44
45 describe("LuaRocks making rockspecs (using lxsh)", function() 45 describe("LuaRocks making rockspecs (using lxsh)", function()
@@ -61,33 +61,36 @@ describe("LuaRocks make tests #blackbox #b_make", function()
61 assert.is_true(run.luarocks_bool("new_version lxsh-0.8.6-2.rockspec")) 61 assert.is_true(run.luarocks_bool("new_version lxsh-0.8.6-2.rockspec"))
62 assert.is_true(run.luarocks_bool("make")) 62 assert.is_true(run.luarocks_bool("make"))
63 63
64 assert.is_true(run.luarocks_bool(test_env.quiet("show lxsh"))) 64 assert.is_true(run.luarocks_bool("show lxsh"))
65 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) 65 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-3/lxsh-0.8.6-3.rockspec"))
66 end) 66 end)
67 67
68 it("LuaRocks make unnamed rockspec", function() 68 it("LuaRocks make unnamed rockspec", function()
69 os.execute("cp lxsh-0.8.6-2.rockspec rockspec") --rewrite with lfs 69 test_env.copy("lxsh-0.8.6-2.rockspec", "rockspec")
70 assert.is_true(run.luarocks_bool("make")) 70 assert.is_true(run.luarocks_bool("make"))
71 71
72 assert.is_true(run.luarocks_bool(test_env.quiet("show lxsh"))) 72 assert.is_true(run.luarocks_bool(test_env.quiet("show lxsh")))
73 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) 73 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
74 os.remove("rockspec")
74 end) 75 end)
75 76
76 it("LuaRocks make ambiguous rockspec", function() 77 it("LuaRocks make ambiguous rockspec", function()
77 assert.is.truthy(os.rename("lxsh-0.8.6-2.rockspec", "lxsh2-0.8.6-2.rockspec")) 78 assert.is.truthy(os.rename("lxsh-0.8.6-2.rockspec", "lxsh2-0.8.6-2.rockspec"))
78 assert.is_false(run.luarocks_bool("make")) 79 local output = run.luarocks("make")
80 assert.is.truthy(output:match("Error: Inconsistency between rockspec filename"))
79 81
80 assert.is_false(run.luarocks_bool("show lxsh")) 82 assert.is_false(run.luarocks_bool("show lxsh"))
81 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) 83 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
82 end) 84 end)
83 85
84 it("LuaRocks make ambiguous unnamed rockspec", function() 86 it("LuaRocks make ambiguous unnamed rockspec", function()
85 assert.is.truthy(os.rename("lxsh-0.8.6-2.rockspec", "1_rockspec")) 87 assert.is.truthy(os.rename("lxsh-0.8.6-2.rockspec", "1_rockspec"))
86 os.execute("cp 1_rockspec 2_rockspec") --rewrite with lfs 88 test_env.copy("1_rockspec", "2_rockspec")
87 assert.is_false(run.luarocks_bool("make")) 89 local output = run.luarocks("make")
90 assert.is.truthy(output:match("Error: Please specify which rockspec file to use"))
88 91
89 assert.is_false(run.luarocks_bool("show lxsh")) 92 assert.is_false(run.luarocks_bool("show lxsh"))
90 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) 93 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
91 end) 94 end)
92 95
93 it("LuaRocks make pack binary rock", function() 96 it("LuaRocks make pack binary rock", function()
diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua
index 0e5b31c6..21f33b02 100644
--- a/spec/pack_spec.lua
+++ b/spec/pack_spec.lua
@@ -6,9 +6,10 @@ local testing_paths = test_env.testing_paths
6test_env.unload_luarocks() 6test_env.unload_luarocks()
7 7
8local extra_rocks = { 8local extra_rocks = {
9 "/luasec-0.6-1.rockspec", 9 "/luasec-0.6-1.rockspec",
10 "/luasocket-3.0rc1-1.src.rock", 10 "/luassert-1.7.0-1.src.rock",
11 "/luasocket-3.0rc1-1.rockspec", 11 "/luasocket-3.0rc1-2.src.rock",
12 "/luasocket-3.0rc1-2.rockspec",
12 "/say-1.2-1.src.rock", 13 "/say-1.2-1.src.rock",
13 "/say-1.0-1.src.rock" 14 "/say-1.0-1.src.rock"
14} 15}
@@ -44,14 +45,17 @@ describe("LuaRocks pack tests #blackbox #b_pack", function()
44 assert.is_true(run.luarocks_bool("install say 1.2")) 45 assert.is_true(run.luarocks_bool("install say 1.2"))
45 assert.is_true(run.luarocks_bool("install luassert")) 46 assert.is_true(run.luarocks_bool("install luassert"))
46 assert.is_true(run.luarocks_bool("install say 1.0")) 47 assert.is_true(run.luarocks_bool("install say 1.0"))
47
48 assert.is_false(run.luarocks_bool("pack say")) 48 assert.is_false(run.luarocks_bool("pack say"))
49 end) 49 end)
50 50
51 it("LuaRocks pack src", function() 51 it("LuaRocks pack src", function()
52 assert.is_true(run.luarocks_bool(test_env.quiet("install luasec"))) 52 if test_env.APPVEYOR then
53 assert.is_true(run.luarocks_bool("download --rockspec luasocket 3.0rc1-1")) 53 assert.is_true(run.luarocks_bool(test_env.quiet("install luasec " .. test_env.APPVEYOR_OPENSSL)))
54 assert.is_true(run.luarocks_bool("pack luasocket-3.0rc1-1.rockspec")) 54 else
55 assert.is_true(run.luarocks_bool(test_env.quiet("install luasec")))
56 end
57 assert.is_true(run.luarocks_bool("download --rockspec luasocket 3.0rc1-2"))
58 assert.is_true(run.luarocks_bool("pack luasocket-3.0rc1-2.rockspec"))
55 assert.is_true(test_env.remove_files(lfs.currentdir(), "luasocket-")) 59 assert.is_true(test_env.remove_files(lfs.currentdir(), "luasocket-"))
56 end) 60 end)
57end) 61end)
diff --git a/spec/refresh_cache_spec.lua b/spec/refresh_cache_spec.lua
index c20771ab..09f5645e 100644
--- a/spec/refresh_cache_spec.lua
+++ b/spec/refresh_cache_spec.lua
@@ -4,7 +4,7 @@ local run = test_env.run
4test_env.unload_luarocks() 4test_env.unload_luarocks()
5 5
6describe("LuaRocks refresh_cache tests #blackbox #b_refresh_cache", function() 6describe("LuaRocks refresh_cache tests #blackbox #b_refresh_cache", function()
7 7
8 before_each(function() 8 before_each(function()
9 test_env.setup_specs() 9 test_env.setup_specs()
10 end) 10 end)
diff --git a/spec/remove_spec.lua b/spec/remove_spec.lua
index 7bf1bb10..3d321e30 100644
--- a/spec/remove_spec.lua
+++ b/spec/remove_spec.lua
@@ -8,8 +8,8 @@ test_env.unload_luarocks()
8local extra_rocks = { 8local extra_rocks = {
9 "/abelhas-1.0-1.rockspec", 9 "/abelhas-1.0-1.rockspec",
10 "/lualogging-1.3.0-1.src.rock", 10 "/lualogging-1.3.0-1.src.rock",
11 "/luasocket-3.0rc1-1.src.rock", 11 "/luasocket-3.0rc1-2.src.rock",
12 "/luasocket-3.0rc1-1.rockspec" 12 "/luasocket-3.0rc1-2.rockspec"
13} 13}
14 14
15describe("LuaRocks remove tests #blackbox #b_remove", function() 15describe("LuaRocks remove tests #blackbox #b_remove", function()
@@ -76,7 +76,7 @@ describe("LuaRocks remove tests #blackbox #b_remove", function()
76 end) 76 end)
77 77
78 it("LuaRocks-admin remove #ssh", function() 78 it("LuaRocks-admin remove #ssh", function()
79 assert.is_true(run.luarocks_admin_bool("--server=testing remove luasocket-3.0rc1-1.src.rock")) 79 assert.is_true(run.luarocks_admin_bool("--server=testing remove luasocket-3.0rc1-2.src.rock"))
80 end) 80 end)
81 81
82 it("LuaRocks-admin remove missing", function() 82 it("LuaRocks-admin remove missing", function()
diff --git a/spec/search_spec.lua b/spec/search_spec.lua
index b31624b8..f75bc3c1 100644
--- a/spec/search_spec.lua
+++ b/spec/search_spec.lua
@@ -32,5 +32,4 @@ describe("LuaRocks search tests #blackbox #b_search", function()
32 it("LuaRocks search with flag all", function() 32 it("LuaRocks search with flag all", function()
33 assert.is_true(run.luarocks_bool(test_env.quiet("search --all"))) 33 assert.is_true(run.luarocks_bool(test_env.quiet("search --all")))
34 end) 34 end)
35
36end) 35end)
diff --git a/spec/show_spec.lua b/spec/show_spec.lua
index f528a6de..915129ae 100644
--- a/spec/show_spec.lua
+++ b/spec/show_spec.lua
@@ -20,10 +20,12 @@ describe("LuaRocks show tests #blackbox #b_show", function()
20 20
21 it("LuaRocks show luacov", function() 21 it("LuaRocks show luacov", function()
22 local output = run.luarocks("show luacov") 22 local output = run.luarocks("show luacov")
23 assert.is.truthy(output:match("LuaCov"))
23 end) 24 end)
24 25
25 it("LuaRocks show modules of luacov", function() 26 it("LuaRocks show modules of luacov", function()
26 local output = run.luarocks("show --modules luacov") 27 local output = run.luarocks("show --modules luacov")
28 assert.is.truthy(output:match("luacovluacov.defaultsluacov.reporterluacov.reporter.defaultluacov.runnerluacov.statsluacov.tick"))
27 end) 29 end)
28 30
29 it("LuaRocks show dependencies of luacov", function() 31 it("LuaRocks show dependencies of luacov", function()
@@ -32,10 +34,12 @@ describe("LuaRocks show tests #blackbox #b_show", function()
32 34
33 it("LuaRocks show rockspec of luacov", function() 35 it("LuaRocks show rockspec of luacov", function()
34 local output = run.luarocks("show --rockspec luacov") 36 local output = run.luarocks("show --rockspec luacov")
37 assert.is.truthy(output:match("luacov-0.11.0-1.rockspec"))
35 end) 38 end)
36 39
37 it("LuaRocks show mversion of luacov", function() 40 it("LuaRocks show mversion of luacov", function()
38 local output = run.luarocks("show --mversion luacov") 41 local output = run.luarocks("show --mversion luacov")
42 assert.is.truthy(output:match("0.11.0--1"))
39 end) 43 end)
40 44
41 it("LuaRocks show rock tree of luacov", function() 45 it("LuaRocks show rock tree of luacov", function()
@@ -49,6 +53,6 @@ describe("LuaRocks show tests #blackbox #b_show", function()
49 53
50 it("LuaRocks show old version of luacov", function() 54 it("LuaRocks show old version of luacov", function()
51 run.luarocks("install luacov 0.11.0") 55 run.luarocks("install luacov 0.11.0")
52 run.luarocks("show luacov 0.11.0") 56 run.luarocks_bool("show luacov 0.11.0")
53 end) 57 end)
54end) 58end)
diff --git a/spec/unpack_spec.lua b/spec/unpack_spec.lua
index 8db779c3..220ef00d 100644
--- a/spec/unpack_spec.lua
+++ b/spec/unpack_spec.lua
@@ -1,14 +1,12 @@
1local test_env = require("test/test_environment") 1local test_env = require("test/test_environment")
2local run = test_env.run 2local run = test_env.run
3local testing_paths = test_env.testing_paths 3local testing_paths = test_env.testing_paths
4local lfs = require("lfs")
5 4
6test_env.unload_luarocks() 5test_env.unload_luarocks()
7 6
8local extra_rocks = { 7local extra_rocks = {
9 "/cprint-0.1-2.src.rock", 8 "/cprint-0.1-2.src.rock",
10 "/cprint-0.1-2.rockspec", 9 "/cprint-0.1-2.rockspec"
11 "/luazip-1.2.4-1.rockspec"
12} 10}
13 11
14describe("LuaRocks unpack tests #blackbox #b_unpack", function() 12describe("LuaRocks unpack tests #blackbox #b_unpack", function()
@@ -21,9 +19,11 @@ describe("LuaRocks unpack tests #blackbox #b_unpack", function()
21 it("LuaRocks unpack with no flags/arguments", function() 19 it("LuaRocks unpack with no flags/arguments", function()
22 assert.is_false(run.luarocks_bool("unpack")) 20 assert.is_false(run.luarocks_bool("unpack"))
23 end) 21 end)
22
24 it("LuaRocks unpack with invalid rockspec", function() 23 it("LuaRocks unpack with invalid rockspec", function()
25 assert.is_false(run.luarocks_bool("unpack invalid.rockspec")) 24 assert.is_false(run.luarocks_bool("unpack invalid.rockspec"))
26 end) 25 end)
26
27 it("LuaRocks unpack with invalid patch", function() 27 it("LuaRocks unpack with invalid patch", function()
28 assert.is_false(run.luarocks_bool("unpack " .. testing_paths.testing_dir .. "/testfiles/invalid_patch-0.1-1.rockspec")) 28 assert.is_false(run.luarocks_bool("unpack " .. testing_paths.testing_dir .. "/testfiles/invalid_patch-0.1-1.rockspec"))
29 end) 29 end)
@@ -34,26 +34,22 @@ describe("LuaRocks unpack tests #blackbox #b_unpack", function()
34 assert.is_true(run.luarocks_bool("unpack cprint")) 34 assert.is_true(run.luarocks_bool("unpack cprint"))
35 test_env.remove_dir("cprint-0.1-2") 35 test_env.remove_dir("cprint-0.1-2")
36 end) 36 end)
37
37 it("LuaRocks unpack src", function() 38 it("LuaRocks unpack src", function()
38 assert.is_true(run.luarocks_bool("download --source cprint")) 39 assert.is_true(run.luarocks_bool("download --source cprint"))
39 assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.src.rock")) 40 assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.src.rock"))
40 os.remove("cprint-0.1-2.src.rock") 41 os.remove("cprint-0.1-2.src.rock")
41 test_env.remove_dir("cprint-0.1-2") 42 test_env.remove_dir("cprint-0.1-2")
42 end) 43 end)
43 it("LuaRocks unpack rockspec", function() 44
45 it("LuaRocks unpack src", function()
44 assert.is_true(run.luarocks_bool("download --rockspec cprint")) 46 assert.is_true(run.luarocks_bool("download --rockspec cprint"))
45 assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.rockspec")) 47 assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.rockspec"))
46 os.remove("cprint-0.1-2.rockspec") 48 os.remove("cprint-0.1-2.rockspec")
47 os.remove("lua-cprint") 49 os.remove("lua-cprint")
48 test_env.remove_dir("cprint-0.1-2") 50 test_env.remove_dir("cprint-0.1-2")
49 end) 51 end)
50 -- #595 luarocks unpack of a git:// rockspec fails to copy the rockspec 52
51 it("LuaRocks unpack git:// rockspec", function()
52 assert.is_true(run.luarocks_bool("download --rockspec luazip"))
53 assert.is_true(run.luarocks_bool("unpack luazip-1.2.4-1.rockspec"))
54 assert.is_truthy(lfs.attributes("luazip-1.2.4-1/luazip/luazip-1.2.4-1.rockspec"))
55 test_env.remove_dir("luazip-1.2.4-1")
56 end)
57 it("LuaRocks unpack binary", function() 53 it("LuaRocks unpack binary", function()
58 assert.is_true(run.luarocks_bool("build cprint")) 54 assert.is_true(run.luarocks_bool("build cprint"))
59 assert.is_true(run.luarocks_bool("pack cprint")) 55 assert.is_true(run.luarocks_bool("pack cprint"))
diff --git a/spec/upload_spec.lua b/spec/upload_spec.lua
index c68a1cdf..af4c36d3 100644
--- a/spec/upload_spec.lua
+++ b/spec/upload_spec.lua
@@ -45,7 +45,7 @@ describe("LuaRocks upload tests #blackbox #b_upload", function()
45 assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --skip-pack luacov-0.11.0-1.rockspec")) 45 assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --skip-pack luacov-0.11.0-1.rockspec"))
46 end) 46 end)
47 47
48 it("LuaRocks upload force", function() 48 it("LuaRocks upload force #unix", function()
49 assert.is_true(run.luarocks_bool("install lua-cjson")) 49 assert.is_true(run.luarocks_bool("install lua-cjson"))
50 assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --force luacov-0.11.0-1.rockspec")) 50 assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --force luacov-0.11.0-1.rockspec"))
51 assert.is_true(run.luarocks_bool("install lua-cjson")) 51 assert.is_true(run.luarocks_bool("install lua-cjson"))
@@ -63,10 +63,18 @@ describe("LuaRocks upload tests #blackbox #b_upload", function()
63 end) 63 end)
64 64
65 it("LuaRocks upload rockspec with api-key", function() 65 it("LuaRocks upload rockspec with api-key", function()
66 assert.is_true(run.luarocks_bool("upload " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"})) 66 if test_env.APPVEYOR then
67 assert.is_true(run.luarocks_bool("upload " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec " .. test_env.APPVEYOR_OPENSSL .. " --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"}))
68 else
69 assert.is_true(run.luarocks_bool("upload " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"}))
70 end
67 end) 71 end)
68 it("LuaRocks upload rockspec with api-key and skip-pack", function() 72 it("LuaRocks upload rockspec with api-key and skip-pack", function()
69 assert.is_true(run.luarocks_bool("upload --skip-pack " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"})) 73 if test_env.APPVEYOR then
74 assert.is_true(run.luarocks_bool("upload --skip-pack " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec " .. test_env.APPVEYOR_OPENSSL .. " --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"}))
75 else
76 assert.is_true(run.luarocks_bool("upload --skip-pack " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"}))
77 end
70 end) 78 end)
71 end) 79 end)
72end) 80end)
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)
99end) 118end)
diff --git a/test/test_environment.lua b/test/test_environment.lua
index 13e548f9..42473b38 100644
--- a/test/test_environment.lua
+++ b/test/test_environment.lua
@@ -17,6 +17,7 @@ ARGUMENTS
17 noreset Don't reset environment after each test 17 noreset Don't reset environment after each test
18 clean Remove existing testing environment. 18 clean Remove existing testing environment.
19 travis Add if running on TravisCI. 19 travis Add if running on TravisCI.
20 appveyor Add if running on Appveyor.
20 os=<type> Set OS ("linux", "osx", or "windows"). 21 os=<type> Set OS ("linux", "osx", or "windows").
21]] 22]]
22 23
@@ -36,18 +37,54 @@ local function exists(path)
36 return lfs.attributes(path, "mode") ~= nil 37 return lfs.attributes(path, "mode") ~= nil
37end 38end
38 39
39function test_env.quiet(commad) 40--- Quote argument for shell processing. Fixes paths on Windows.
41-- Adds double quotes and escapes. Based on function in fs/win32.lua.
42-- @param arg string: Unquoted argument.
43-- @return string: Quoted argument.
44local function Q(arg)
45 if test_env.TEST_TARGET_OS == "windows" then
46 local drive_letter = "[%.a-zA-Z]?:?[\\/]"
47 -- Quote DIR for Windows
48 if arg:match("^"..drive_letter) then
49 arg = arg:gsub("/", "\\")
50 end
51
52 if arg == "\\" then
53 return '\\' -- CHDIR needs special handling for root dir
54 end
55
56 return '"' .. arg .. '"'
57 else
58 return "'" .. arg:gsub("'", "'\\''") .. "'"
59 end
60end
61
62function test_env.quiet(command)
40 if not test_env.VERBOSE then 63 if not test_env.VERBOSE then
41 if test_env.TEST_TARGET_OS == "linux" or test_env.TEST_TARGET_OS == "osx" then 64 if test_env.TEST_TARGET_OS == "windows" then
42 return commad .. " 1> /dev/null 2> /dev/null" 65 return command .. " 1> NUL 2> NUL"
43 elseif test_env.TEST_TARGET_OS == "windows" then 66 else
44 return commad .. " 2> NUL 1> NUL" 67 return command .. " 1> /dev/null 2> /dev/null"
45 end 68 end
46 else 69 else
47 return command 70 return command
48 end 71 end
49end 72end
50 73
74function test_env.copy(source, destination)
75 local r_source, err = io.open(source, "r")
76 local r_destination, err = io.open(destination, "w")
77
78 while true do
79 local block = r_source:read(8192)
80 if not block then break end
81 r_destination:write(block)
82 end
83
84 r_source:close()
85 r_destination:close()
86end
87
51--- Helper function for execute_bool and execute_output 88--- Helper function for execute_bool and execute_output
52-- @param command string: command to execute 89-- @param command string: command to execute
53-- @param print_command boolean: print command if 'true' 90-- @param print_command boolean: print command if 'true'
@@ -61,15 +98,22 @@ function test_env.execute_helper(command, print_command, env_variables)
61 end 98 end
62 99
63 if env_variables then 100 if env_variables then
64 final_command = "export " 101 if test_env.TEST_TARGET_OS == "windows" then
65 for k,v in pairs(env_variables) do 102 for k,v in pairs(env_variables) do
66 final_command = final_command .. k .. "='" .. v .. "' " 103 final_command = final_command .. "set " .. k .. "=" .. v .. "&"
104 end
105 final_command = final_command:sub(1, -2) .. "&"
106 else
107 final_command = "export "
108 for k,v in pairs(env_variables) do
109 final_command = final_command .. k .. "='" .. v .. "' "
110 end
111 -- remove last space and add ';' to separate exporting variables from command
112 final_command = final_command:sub(1, -2) .. "; "
67 end 113 end
68 -- remove last space and add ';' to separate exporting variables from command
69 final_command = final_command:sub(1, -2) .. "; "
70 end 114 end
71 115
72 final_command = final_command .. command 116 final_command = final_command .. command .. " 2>&1"
73 117
74 return final_command 118 return final_command
75end 119end
@@ -122,6 +166,9 @@ function test_env.set_args()
122 test_env.VERBOSE = true 166 test_env.VERBOSE = true
123 elseif argument == "travis" then 167 elseif argument == "travis" then
124 test_env.TRAVIS = true 168 test_env.TRAVIS = true
169 elseif argument == "appveyor" then
170 test_env.APPVEYOR = true
171 test_env.APPVEYOR_OPENSSL = "OPENSSL_LIBDIR=C:\\OpenSSL-Win32\\lib OPENSSL_INCDIR=C:\\OpenSSL-Win32\\include"
125 elseif argument:find("^os=") then 172 elseif argument:find("^os=") then
126 test_env.TEST_TARGET_OS = argument:match("^os=(.*)$") 173 test_env.TEST_TARGET_OS = argument:match("^os=(.*)$")
127 else 174 else
@@ -143,6 +190,15 @@ function test_env.set_args()
143 return true 190 return true
144end 191end
145 192
193local function copy_dir(source_path, target_path)
194 local testing_paths = test_env.testing_paths
195 if test_env.TEST_TARGET_OS == "windows" then
196 execute_bool(testing_paths.win_tools .. "/cp -R ".. source_path .. "/. " .. target_path)
197 else
198 execute_bool("cp -a ".. source_path .. "/. " .. target_path)
199 end
200end
201
146--- Remove directory recursively 202--- Remove directory recursively
147-- @param path string: directory path to delete 203-- @param path string: directory path to delete
148function test_env.remove_dir(path) 204function test_env.remove_dir(path)
@@ -159,7 +215,7 @@ function test_env.remove_dir(path)
159 end 215 end
160 end 216 end
161 end 217 end
162 os.remove(path) 218 lfs.rmdir(path)
163end 219end
164 220
165--- Remove subdirectories of a directory that match a pattern 221--- Remove subdirectories of a directory that match a pattern
@@ -205,13 +261,17 @@ end
205-- @param save_path string: path to directory, where to download rocks/rockspecs 261-- @param save_path string: path to directory, where to download rocks/rockspecs
206-- @return make_manifest boolean: true if new rocks downloaded 262-- @return make_manifest boolean: true if new rocks downloaded
207local function download_rocks(urls, save_path) 263local function download_rocks(urls, save_path)
208 local luarocks_repo = "https://luarocks.org" 264 local luarocks_repo = "https://www.luarocks.org"
209 local make_manifest = false 265 local make_manifest = false
210 266
211 for _, url in ipairs(urls) do 267 for _, url in ipairs(urls) do
212 -- check if already downloaded 268 -- check if already downloaded
213 if not exists(save_path .. url) then 269 if not exists(save_path .. url) then
214 execute_bool("wget -cP " .. save_path .. " " .. luarocks_repo .. url) 270 if test_env.TEST_TARGET_OS == "windows" then
271 execute_bool(test_env.testing_paths.win_tools .. "/wget -cP " .. save_path .. " " .. luarocks_repo .. url .. " --no-check-certificate")
272 else
273 execute_bool("wget -cP " .. save_path .. " " .. luarocks_repo .. url)
274 end
215 make_manifest = true 275 make_manifest = true
216 end 276 end
217 end 277 end
@@ -235,9 +295,9 @@ local function hash_environment(path)
235 return execute_output("find " .. path .. " -printf \"%s %p\n\" | md5sum") 295 return execute_output("find " .. path .. " -printf \"%s %p\n\" | md5sum")
236 elseif test_env.TEST_TARGET_OS == "osx" then 296 elseif test_env.TEST_TARGET_OS == "osx" then
237 return execute_output("find " .. path .. " -type f -exec stat -f \"%z %N\" {} \\; | md5") 297 return execute_output("find " .. path .. " -type f -exec stat -f \"%z %N\" {} \\; | md5")
238 else 298 elseif test_env.TEST_TARGET_OS == "windows" then
239 -- TODO: Windows 299 return execute_output("\"" .. Q(test_env.testing_paths.win_tools .. "/find") .. " " .. Q(path)
240 return "" 300 .. " -printf \"%s %p\"\" > temp_sum.txt && certUtil -hashfile temp_sum.txt && del temp_sum.txt")
241 end 301 end
242end 302end
243 303
@@ -278,13 +338,17 @@ local function create_md5sums(testing_paths)
278end 338end
279 339
280local function make_run_function(cmd_name, exec_function, with_coverage, do_print) 340local function make_run_function(cmd_name, exec_function, with_coverage, do_print)
281 local cmd_prefix = test_env.testing_paths.lua .. " " 341 local cmd_prefix = Q(test_env.testing_paths.lua) .. " "
282 342
283 if with_coverage then 343 if with_coverage then
284 cmd_prefix = cmd_prefix .. "-e \"require('luacov.runner')('" .. test_env.testing_paths.testing_dir .. "/luacov.config')\" " 344 cmd_prefix = cmd_prefix .. "-e \"require('luacov.runner')('" .. test_env.testing_paths.testing_dir .. "/luacov.config')\" "
285 end 345 end
286 346
287 cmd_prefix = cmd_prefix .. test_env.testing_paths.src_dir .. "/bin/" .. cmd_name .. " " 347 if test_env.TEST_TARGET_OS == "windows" then
348 cmd_prefix = cmd_prefix .. Q(test_env.testing_paths.testing_lrprefix .. "/" .. cmd_name .. ".lua") .. " "
349 else
350 cmd_prefix = cmd_prefix .. test_env.testing_paths.src_dir .. "/bin/" .. cmd_name .. " "
351 end
288 352
289 return function(cmd, new_vars) 353 return function(cmd, new_vars)
290 local temp_vars = {} 354 local temp_vars = {}
@@ -327,19 +391,23 @@ local function build_environment(rocks, env_variables)
327 lfs.mkdir(testing_paths.testing_tree) 391 lfs.mkdir(testing_paths.testing_tree)
328 lfs.mkdir(testing_paths.testing_sys_tree) 392 lfs.mkdir(testing_paths.testing_sys_tree)
329 393
330 test_env.run.luarocks_admin_nocov("make_manifest " .. testing_paths.testing_server) 394 test_env.run.luarocks_admin_nocov("make_manifest " .. Q(testing_paths.testing_server))
331 test_env.run.luarocks_admin_nocov("make_manifest " .. testing_paths.testing_cache) 395 test_env.run.luarocks_admin_nocov("make_manifest " .. Q(testing_paths.testing_cache))
332 396
333 for _, rock in ipairs(rocks) do 397 for _, rock in ipairs(rocks) do
334 if not test_env.run.luarocks_nocov("install --only-server=" .. testing_paths.testing_cache .. " --tree=" .. testing_paths.testing_sys_tree .. " " .. rock, env_variables) then 398 if not test_env.run.luarocks_nocov("install --only-server=" .. testing_paths.testing_cache .. " --tree=" .. testing_paths.testing_sys_tree .. " " .. Q(rock), env_variables) then
335 test_env.run.luarocks_nocov("build --tree=" .. testing_paths.testing_sys_tree .. " " .. rock, env_variables) 399 test_env.run.luarocks_nocov("build --tree=" .. Q(testing_paths.testing_sys_tree) .. " " .. Q(rock) .. "", env_variables)
336 test_env.run.luarocks_nocov("pack --tree=" .. testing_paths.testing_sys_tree .. " " .. rock, env_variables) 400 test_env.run.luarocks_nocov("pack --tree=" .. Q(testing_paths.testing_sys_tree) .. " " .. Q(rock), env_variables)
337 execute_bool("mv " .. rock .. "-*.rock " .. testing_paths.testing_cache) 401 if test_env.TEST_TARGET_OS == "windows" then
402 execute_bool(testing_paths.win_tools .. "/mv " .. rock .. "-*.rock " .. testing_paths.testing_cache)
403 else
404 execute_bool("mv " .. rock .. "-*.rock " .. testing_paths.testing_cache)
405 end
338 end 406 end
339 end 407 end
340 408
341 execute_bool("cp -a " .. testing_paths.testing_tree .. "/. " .. testing_paths.testing_tree_copy) 409 copy_dir(testing_paths.testing_tree, testing_paths.testing_tree_copy)
342 execute_bool("cp -a " .. testing_paths.testing_sys_tree .. "/. " .. testing_paths.testing_sys_tree_copy) 410 copy_dir(testing_paths.testing_sys_tree, testing_paths.testing_sys_tree_copy)
343end 411end
344 412
345--- Reset testing environment 413--- Reset testing environment
@@ -349,14 +417,13 @@ local function reset_environment(testing_paths, md5sums)
349 417
350 if testing_tree_md5 ~= md5sums.testing_tree_copy_md5 then 418 if testing_tree_md5 ~= md5sums.testing_tree_copy_md5 then
351 test_env.remove_dir(testing_paths.testing_tree) 419 test_env.remove_dir(testing_paths.testing_tree)
352 execute_bool("cp -a " .. testing_paths.testing_tree_copy .. "/. " .. testing_paths.testing_tree) 420 copy_dir(testing_paths.testing_tree_copy, testing_paths.testing_tree)
353 end 421 end
354 422
355 if testing_sys_tree_md5 ~= md5sums.testing_sys_tree_copy_md5 then 423 if testing_sys_tree_md5 ~= md5sums.testing_sys_tree_copy_md5 then
356 test_env.remove_dir(testing_paths.testing_sys_tree) 424 test_env.remove_dir(testing_paths.testing_sys_tree)
357 execute_bool("cp -a " .. testing_paths.testing_sys_tree_copy .. "/. " .. testing_paths.testing_sys_tree) 425 copy_dir(testing_paths.testing_sys_tree_copy, testing_paths.testing_sys_tree)
358 end 426 end
359
360 print("\n[ENVIRONMENT RESET]") 427 print("\n[ENVIRONMENT RESET]")
361end 428end
362 429
@@ -367,9 +434,18 @@ local function create_paths(luaversion_full)
367 testing_paths.luadir = cfg.variables.LUA_BINDIR:gsub("/bin/?$", "") 434 testing_paths.luadir = cfg.variables.LUA_BINDIR:gsub("/bin/?$", "")
368 testing_paths.lua = cfg.variables.LUA_BINDIR .. "/" .. cfg.lua_interpreter 435 testing_paths.lua = cfg.variables.LUA_BINDIR .. "/" .. cfg.lua_interpreter
369 436
370 testing_paths.luarocks_tmp = "/tmp/luarocks_testing" --windows? 437 if test_env.TEST_TARGET_OS == "windows" then
438 testing_paths.luarocks_tmp = os.getenv("TEMP")
439 else
440 testing_paths.luarocks_tmp = "/tmp/luarocks_testing"
441 end
371 442
372 testing_paths.luarocks_dir = lfs.currentdir() 443 testing_paths.luarocks_dir = lfs.currentdir()
444
445 if test_env.TEST_TARGET_OS == "windows" then
446 testing_paths.luarocks_dir = testing_paths.luarocks_dir:gsub("\\","/")
447 end
448
373 testing_paths.testing_dir = testing_paths.luarocks_dir .. "/test" 449 testing_paths.testing_dir = testing_paths.luarocks_dir .. "/test"
374 testing_paths.src_dir = testing_paths.luarocks_dir .. "/src" 450 testing_paths.src_dir = testing_paths.luarocks_dir .. "/src"
375 testing_paths.testing_lrprefix = testing_paths.testing_dir .. "/testing_lrprefix-" .. luaversion_full 451 testing_paths.testing_lrprefix = testing_paths.testing_dir .. "/testing_lrprefix-" .. luaversion_full
@@ -380,6 +456,10 @@ local function create_paths(luaversion_full)
380 testing_paths.testing_cache = testing_paths.testing_dir .. "/testing_cache-" .. luaversion_full 456 testing_paths.testing_cache = testing_paths.testing_dir .. "/testing_cache-" .. luaversion_full
381 testing_paths.testing_server = testing_paths.testing_dir .. "/testing_server-" .. luaversion_full 457 testing_paths.testing_server = testing_paths.testing_dir .. "/testing_server-" .. luaversion_full
382 458
459 if test_env.TEST_TARGET_OS == "windows" then
460 testing_paths.win_tools = testing_paths.testing_lrprefix .. "/tools"
461 end
462
383 return testing_paths 463 return testing_paths
384end 464end
385 465
@@ -409,7 +489,7 @@ function test_env.setup_specs(extra_rocks)
409 test_env.main() 489 test_env.main()
410 package.path = test_env.env_variables.LUA_PATH 490 package.path = test_env.env_variables.LUA_PATH
411 491
412 test_env.platform = execute_output(test_env.testing_paths.lua .. " -e 'print(require(\"luarocks.cfg\").arch)'", false, test_env.env_variables) 492 test_env.platform = execute_output(test_env.testing_paths.lua .. " -e \"print(require('luarocks.cfg').arch)\"", false, test_env.env_variables)
413 test_env.md5sums = create_md5sums(test_env.testing_paths) 493 test_env.md5sums = create_md5sums(test_env.testing_paths)
414 test_env.setup_done = true 494 test_env.setup_done = true
415 title("RUNNING TESTS") 495 title("RUNNING TESTS")
@@ -546,13 +626,22 @@ end
546 626
547--- Install luarocks into testing prefix. 627--- Install luarocks into testing prefix.
548local function install_luarocks(install_env_vars) 628local function install_luarocks(install_env_vars)
549 -- Configure LuaRocks testing environment 629 local testing_paths = test_env.testing_paths
550 title("Installing LuaRocks") 630 title("Installing LuaRocks")
551 local configure_cmd = "./configure --with-lua=" .. test_env.testing_paths.luadir .. " --prefix=" .. test_env.testing_paths.testing_lrprefix 631 if test_env.TEST_TARGET_OS == "windows" then
552 assert(execute_bool(test_env.quiet(configure_cmd), false, install_env_vars)) 632 if test_env.LUA_V then
553 assert(execute_bool(test_env.quiet("make clean"), false, install_env_vars)) 633 assert(execute_bool("install.bat /LUA " .. testing_paths.luadir .. " /LV " .. test_env.LUA_V .. " /P " .. testing_paths.testing_lrprefix .. " /NOREG /NOADMIN /F /Q /CONFIG " .. testing_paths.testing_lrprefix .. "/etc/luarocks", false, install_env_vars))
554 assert(execute_bool(test_env.quiet("make src/luarocks/site_config.lua"), false, install_env_vars)) 634 else
555 assert(execute_bool(test_env.quiet("make dev"), false, install_env_vars)) 635 assert(execute_bool("install.bat /LUA " .. testing_paths.luadir .. " /P " .. testing_paths.testing_lrprefix .. " /NOREG /NOADMIN /F /Q /CONFIG " .. testing_paths.testing_lrprefix .. "/etc/luarocks", false, install_env_vars))
636 end
637 assert(execute_bool(testing_paths.win_tools .. "/cp " .. testing_paths.testing_lrprefix .. "/lua/luarocks/site_config* " .. testing_paths.src_dir .. "/luarocks/site_config.lua"))
638 else
639 local configure_cmd = "./configure --with-lua=" .. testing_paths.luadir .. " --prefix=" .. testing_paths.testing_lrprefix
640 assert(execute_bool(configure_cmd, false, install_env_vars))
641 assert(execute_bool("make clean", false, install_env_vars))
642 assert(execute_bool("make src/luarocks/site_config.lua", false, install_env_vars))
643 assert(execute_bool("make dev", false, install_env_vars))
644 end
556 print("LuaRocks installed correctly!") 645 print("LuaRocks installed correctly!")
557end 646end
558 647
@@ -572,8 +661,8 @@ function test_env.main()
572 661
573 local install_env_vars = { 662 local install_env_vars = {
574 LUAROCKS_CONFIG = test_env.testing_paths.testing_dir .. "/testing_config.lua", 663 LUAROCKS_CONFIG = test_env.testing_paths.testing_dir .. "/testing_config.lua",
575 LUA_PATH = "", 664 LUA_PATH,
576 LUA_CPATH = "" 665 LUA_CPATH
577 } 666 }
578 667
579 install_luarocks(install_env_vars) 668 install_luarocks(install_env_vars)