aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2022-04-11 19:16:10 -0300
committerHisham Muhammad <hisham@gobolinux.org>2022-04-12 13:19:12 -0300
commit238ba6b21cfcb1af56f1e70dd50de201fc3482a7 (patch)
treec948b6d3e12e3a518a69d0c844e016c590b31825 /spec
parentdf8a3cd3c957db337bfc3ab4d404c33066a24923 (diff)
downloadluarocks-238ba6b21cfcb1af56f1e70dd50de201fc3482a7.tar.gz
luarocks-238ba6b21cfcb1af56f1e70dd50de201fc3482a7.tar.bz2
luarocks-238ba6b21cfcb1af56f1e70dd50de201fc3482a7.zip
tests: avoid repeated hardcoded package version numbers all over
Diffstat (limited to 'spec')
-rw-r--r--spec/add_spec.lua12
-rw-r--r--spec/build_spec.lua10
-rw-r--r--spec/deps_spec.lua102
-rw-r--r--spec/install_spec.lua61
-rw-r--r--spec/list_spec.lua5
-rw-r--r--spec/make_spec.lua66
-rw-r--r--spec/new_version_spec.lua14
-rw-r--r--spec/pack_spec.lua4
-rw-r--r--spec/remove_spec.lua37
-rw-r--r--spec/test_spec.lua9
-rw-r--r--spec/upload_spec.lua4
-rw-r--r--spec/util/test_env.lua131
-rw-r--r--spec/util/versions.lua14
13 files changed, 291 insertions, 178 deletions
diff --git a/spec/add_spec.lua b/spec/add_spec.lua
index ea6274ba..b17cadac 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-2.src.rock", 8 "/luasocket-${LUASOCKET}.src.rock",
9 "/luasocket-3.0rc1-2.rockspec" 9 "/luasocket-${LUASOCKET}.rockspec"
10} 10}
11 11
12describe("LuaRocks add tests #integration", function() 12describe("LuaRocks add tests #integration", function()
@@ -25,20 +25,20 @@ describe("LuaRocks add tests #integration", function()
25 end) 25 end)
26 26
27 it("invalid server", function() 27 it("invalid server", function()
28 assert.is_false(run.luarocks_admin_bool("--server=invalid add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.src.rock")) 28 assert.is_false(run.luarocks_admin_bool("--server=invalid add " .. testing_paths.testing_server .. "/luasocket-${LUASOCKET}.src.rock"))
29 end) 29 end)
30 30
31 it("invalid server #ssh", function() 31 it("invalid server #ssh", function()
32 assert.is_true(run.luarocks_admin_bool("--server=testing add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.src.rock")) 32 assert.is_true(run.luarocks_admin_bool("--server=testing add " .. testing_paths.testing_server .. "/luasocket-${LUASOCKET}.src.rock"))
33 end) 33 end)
34 34
35 --TODO This test fails, sftp support not yet implemented 35 --TODO This test fails, sftp support not yet implemented
36 it("invalid server", function() 36 it("invalid server", function()
37 assert.is_false(run.luarocks_admin_bool("--server=testing add luasocket-3.0rc1-2.src.rock", { LUAROCKS_CONFIG = testing_paths.testrun_dir .. "/testing_config_sftp.lua" } )) 37 assert.is_false(run.luarocks_admin_bool("--server=testing add luasocket-${LUASOCKET}.src.rock", { LUAROCKS_CONFIG = testing_paths.testrun_dir .. "/testing_config_sftp.lua" } ))
38 end) 38 end)
39 39
40 it("split server url", function() 40 it("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-2.src.rock")) 41 assert.is_false(run.luarocks_admin_bool("--server=\"localhost@/tmp/luarocks_testing\" add " .. testing_paths.testing_server .. "/luasocket-${LUASOCKET}.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 a970a5da..ba6c1a94 100644
--- a/spec/build_spec.lua
+++ b/spec/build_spec.lua
@@ -19,9 +19,9 @@ local extra_rocks = {
19 "/lmathx-20150505-1.rockspec", 19 "/lmathx-20150505-1.rockspec",
20 "/lpeg-1.0.0-1.rockspec", 20 "/lpeg-1.0.0-1.rockspec",
21 "/lpeg-1.0.0-1.src.rock", 21 "/lpeg-1.0.0-1.src.rock",
22 "/luafilesystem-1.6.3-1.src.rock", 22 "/luafilesystem-${LUAFILESYSTEM}.src.rock",
23 "/luasocket-3.0rc1-2.src.rock", 23 "/luasocket-${LUASOCKET}.src.rock",
24 "/luasocket-3.0rc1-2.rockspec", 24 "/luasocket-${LUASOCKET}.rockspec",
25 "/stdlib-41.0.0-1.src.rock", 25 "/stdlib-41.0.0-1.src.rock",
26 "spec/fixtures/a_rock-1.0-1.src.rock", 26 "spec/fixtures/a_rock-1.0-1.src.rock",
27 "/busted-2.0.0-1.rockspec", 27 "/busted-2.0.0-1.rockspec",
@@ -137,8 +137,8 @@ describe("LuaRocks build #integration", function()
137 137
138 describe("basic builds", function() 138 describe("basic builds", function()
139 it("luacov diff version", function() 139 it("luacov diff version", function()
140 assert.is_true(run.luarocks_bool("build luacov 0.15.0-1")) 140 assert.is_true(run.luarocks_bool("build luacov ${LUACOV}"))
141 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luacov/0.15.0-1/luacov-0.15.0-1.rockspec")) 141 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luacov/${LUACOV}/luacov-${LUACOV}.rockspec"))
142 end) 142 end)
143 143
144 it("command stdlib", function() 144 it("command stdlib", function()
diff --git a/spec/deps_spec.lua b/spec/deps_spec.lua
index 35fd8be5..b0064298 100644
--- a/spec/deps_spec.lua
+++ b/spec/deps_spec.lua
@@ -6,11 +6,11 @@ local testing_paths = test_env.testing_paths
6test_env.unload_luarocks() 6test_env.unload_luarocks()
7 7
8local extra_rocks = { 8local extra_rocks = {
9 "/lxsh-0.8.6-2.src.rock", 9 "/lxsh-${LXSH}.src.rock",
10 "/lxsh-0.8.6-2.rockspec", 10 "/lxsh-${LXSH}.rockspec",
11 "/luasocket-3.0rc1-2.src.rock", 11 "/luasocket-${LUASOCKET}.src.rock",
12 "/luasocket-3.0rc1-2.rockspec", 12 "/luasocket-${LUASOCKET}.rockspec",
13 "/lpeg-1.0.0-1.src.rock", 13 "/lpeg-${LPEG}.src.rock",
14} 14}
15 15
16describe("LuaRocks deps-mode #integration", function() 16describe("LuaRocks deps-mode #integration", function()
@@ -23,92 +23,96 @@ describe("LuaRocks deps-mode #integration", 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_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) 26 assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lpeg/${LPEG}/lpeg-${LPEG}.rockspec"))
27 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) 27 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/${LPEG}/lpeg-${LPEG}.rockspec"))
28 assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) 28 assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/${LXSH}/lxsh-${LXSH}.rockspec"))
29 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) 29 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/${LXSH}/lxsh-${LXSH}.rockspec"))
30 end) 30 end)
31 31
32 it("order", function() 32 it("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_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) 36 assert.is.falsy(lfs.attributes(testing_paths.testing_rocks .. "/lpeg/${LPEG}/lpeg-${LPEG}.rockspec"))
37 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) 37 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/${LPEG}/lpeg-${LPEG}.rockspec"))
38 assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) 38 assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/${LXSH}/lxsh-${LXSH}.rockspec"))
39 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) 39 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/${LXSH}/lxsh-${LXSH}.rockspec"))
40 end) 40 end)
41 41
42 it("order sys", function() 42 it("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_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) 46 assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lpeg/${LPEG}/lpeg-${LPEG}.rockspec"))
47 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) 47 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/${LPEG}/lpeg-${LPEG}.rockspec"))
48 assert.is.falsy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) 48 assert.is.falsy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/${LXSH}/lxsh-${LXSH}.rockspec"))
49 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) 49 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/${LXSH}/lxsh-${LXSH}.rockspec"))
50 end) 50 end)
51 51
52 it("all sys", function() 52 it("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_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) 56 assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lpeg/${LPEG}/lpeg-${LPEG}.rockspec"))
57 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) 57 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/${LPEG}/lpeg-${LPEG}.rockspec"))
58 assert.is.falsy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) 58 assert.is.falsy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/${LXSH}/lxsh-${LXSH}.rockspec"))
59 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) 59 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/${LXSH}/lxsh-${LXSH}.rockspec"))
60 end) 60 end)
61 61
62 it("none", function() 62 it("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_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) 66 assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lpeg/${LPEG}/lpeg-${LPEG}.rockspec"))
67 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) 67 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/${LPEG}/lpeg-${LPEG}.rockspec"))
68 assert.is.falsy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) 68 assert.is.falsy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/${LXSH}/lxsh-${LXSH}.rockspec"))
69 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) 69 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/${LXSH}/lxsh-${LXSH}.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_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) 75 assert.is.falsy(lfs.attributes(testing_paths.testing_rocks .. "/lpeg/${LPEG}/lpeg-${LPEG}.rockspec"))
76 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) 76 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/${LPEG}/lpeg-${LPEG}.rockspec"))
77 assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) 77 assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/${LXSH}/lxsh-${LXSH}.rockspec"))
78 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) 78 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/${LXSH}/lxsh-${LXSH}.rockspec"))
79 end) 79 end)
80 80
81 it("make order", function() 81 it("make order", function()
82 assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_sys_tree .. " lpeg")) 82 assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_sys_tree .. " lpeg"))
83 assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6")) 83 assert.is_true(run.luarocks_bool("download --source lxsh ${LXSH_V}"))
84 assert.is_true(run.luarocks_bool("unpack lxsh-0.8.6-2.src.rock")) 84 assert.is_true(run.luarocks_bool("unpack lxsh-${LXSH}.src.rock"))
85 lfs.chdir("lxsh-0.8.6-2/lxsh-0.8.6-1/") 85 lfs.chdir("lxsh-${LXSH}/lxsh-${LXSH_V}-1/")
86 assert.is_true(run.luarocks_bool("make --tree=" .. testing_paths.testing_tree .. " --deps-mode=order")) 86 assert.is_true(run.luarocks_bool("make --tree=" .. testing_paths.testing_tree .. " --deps-mode=order"))
87 87
88 lfs.chdir(testing_paths.testrun_dir) 88 finally(function()
89 test_env.remove_dir("lxsh-0.8.6-2") 89 lfs.chdir(testing_paths.testrun_dir)
90 assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) 90 test_env.remove_dir("lxsh-${LXSH}")
91 assert.is_true(os.remove("lxsh-${LXSH}.src.rock"))
92 end)
91 93
92 assert.is.falsy(lfs.attributes(testing_paths.testing_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) 94 assert.is.falsy(lfs.attributes(testing_paths.testing_rocks .. "/lpeg/${LPEG}/lpeg-${LPEG}.rockspec"))
93 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) 95 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/${LPEG}/lpeg-${LPEG}.rockspec"))
94 assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) 96 assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/${LXSH}/lxsh-${LXSH}.rockspec"))
95 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) 97 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/${LXSH}/lxsh-${LXSH}.rockspec"))
96 end) 98 end)
97 99
98 it("make order sys", function() 100 it("make order sys", function()
99 assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg")) 101 assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg"))
100 assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6")) 102 assert.is_true(run.luarocks_bool("download --source lxsh ${LXSH_V}"))
101 assert.is_true(run.luarocks_bool("unpack lxsh-0.8.6-2.src.rock")) 103 assert.is_true(run.luarocks_bool("unpack lxsh-${LXSH}.src.rock"))
102 lfs.chdir("lxsh-0.8.6-2/lxsh-0.8.6-1/") 104 lfs.chdir("lxsh-${LXSH}/lxsh-${LXSH_V}-1/")
103 assert.is_true(run.luarocks_bool("make --tree=" .. testing_paths.testing_sys_tree .. " --deps-mode=order")) 105 assert.is_true(run.luarocks_bool("make --tree=" .. testing_paths.testing_sys_tree .. " --deps-mode=order"))
104 106
105 lfs.chdir(testing_paths.testrun_dir) 107 finally(function()
106 test_env.remove_dir("lxsh-0.8.6-2") 108 lfs.chdir(testing_paths.testrun_dir)
107 assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) 109 test_env.remove_dir("lxsh-${LXSH}")
110 assert.is_true(os.remove("lxsh-${LXSH}.src.rock"))
111 end)
108 112
109 assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) 113 assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lpeg/${LPEG}/lpeg-${LPEG}.rockspec"))
110 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) 114 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/${LPEG}/lpeg-${LPEG}.rockspec"))
111 assert.is.falsy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) 115 assert.is.falsy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/${LXSH}/lxsh-${LXSH}.rockspec"))
112 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) 116 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/${LXSH}/lxsh-${LXSH}.rockspec"))
113 end) 117 end)
114end) 118end)
diff --git a/spec/install_spec.lua b/spec/install_spec.lua
index ea6e1d3f..24dbdb30 100644
--- a/spec/install_spec.lua
+++ b/spec/install_spec.lua
@@ -5,23 +5,24 @@ local testing_paths = test_env.testing_paths
5local env_variables = test_env.env_variables 5local env_variables = test_env.env_variables
6local write_file = test_env.write_file 6local write_file = test_env.write_file
7local git_repo = require("spec.util.git_repo") 7local git_repo = require("spec.util.git_repo")
8local V = test_env.V
8 9
9test_env.unload_luarocks() 10test_env.unload_luarocks()
10 11
11local extra_rocks = { 12local extra_rocks = {
12 "/cprint-0.1-2.src.rock", 13 "/cprint-0.1-2.src.rock",
13 "/cprint-0.1-2.rockspec", 14 "/cprint-0.1-2.rockspec",
14 "/lpeg-0.12-1.src.rock", 15 "/lpeg-${LPEG}.src.rock",
15 "/luassert-1.7.0-1.src.rock", 16 "/luassert-1.7.0-1.src.rock",
16 "/luasocket-3.0rc1-2.src.rock", 17 "/luasocket-${LUASOCKET}.src.rock",
17 "/luasocket-3.0rc1-2.rockspec", 18 "/luasocket-${LUASOCKET}.rockspec",
18 "/lxsh-0.8.6-2.src.rock", 19 "/lxsh-${LXSH}.src.rock",
19 "/lxsh-0.8.6-2.rockspec", 20 "/lxsh-${LXSH}.rockspec",
20 "/say-1.2-1.src.rock", 21 "/say-1.2-1.src.rock",
21 "/say-1.0-1.src.rock", 22 "/say-1.0-1.src.rock",
22 "/wsapi-1.6-1.src.rock", 23 "/wsapi-1.6-1.src.rock",
23 "/luafilesystem-1.6.3-2.src.rock", 24 "/luafilesystem-${LUAFILESYSTEM}.src.rock",
24 "/luafilesystem-1.6.3-1.src.rock", 25 "/luafilesystem-${LUAFILESYSTEM_OLD}.src.rock",
25 "spec/fixtures/a_repo/has_build_dep-1.0-1.all.rock", 26 "spec/fixtures/a_repo/has_build_dep-1.0-1.all.rock",
26 "spec/fixtures/a_repo/a_build_dep-1.0-1.all.rock", 27 "spec/fixtures/a_repo/a_build_dep-1.0-1.all.rock",
27 "spec/fixtures/a_repo/a_rock-1.0-1.src.rock", 28 "spec/fixtures/a_repo/a_rock-1.0-1.src.rock",
@@ -78,7 +79,7 @@ describe("luarocks install #integration", function()
78 end) 79 end)
79 80
80 it("only-deps of lxsh show there is no lxsh", function() 81 it("only-deps of lxsh show there is no lxsh", function()
81 assert.is_true(run.luarocks_bool("install lxsh 0.8.6-2 --only-deps")) 82 assert.is_true(run.luarocks_bool("install lxsh ${LXSH} --only-deps"))
82 assert.is_false(run.luarocks_bool("show lxsh")) 83 assert.is_false(run.luarocks_bool("show lxsh"))
83 end) 84 end)
84 85
@@ -170,16 +171,20 @@ describe("luarocks install #integration", function()
170 end) 171 end)
171 172
172 it('handle versioned modules when installing another version with --keep #268', function() 173 it('handle versioned modules when installing another version with --keep #268', function()
174 local libdir = testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION
175
173 assert.is_true(run.luarocks_bool("install luafilesystem")) 176 assert.is_true(run.luarocks_bool("install luafilesystem"))
174 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension)) 177 assert.is.truthy(lfs.attributes(libdir .."/lfs."..test_env.lib_extension))
178
179 local suffix = (V"${LUAFILESYSTEM_OLD}"):gsub("[%.%-]", "_")
175 180
176 assert.is_true(run.luarocks_bool("install luafilesystem 1.6.3-1 --keep")) 181 assert.is_true(run.luarocks_bool("install luafilesystem ${LUAFILESYSTEM_OLD} --keep"))
177 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension)) 182 assert.is.truthy(lfs.attributes(libdir .. "/lfs."..test_env.lib_extension))
178 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/luafilesystem_1_6_3_1-lfs."..test_env.lib_extension)) 183 assert.is.truthy(lfs.attributes(libdir .. "/luafilesystem_"..suffix.."-lfs."..test_env.lib_extension))
179 184
180 assert.is_true(run.luarocks_bool("install luafilesystem")) 185 assert.is_true(run.luarocks_bool("install luafilesystem"))
181 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension)) 186 assert.is.truthy(lfs.attributes(libdir .. "/lfs."..test_env.lib_extension))
182 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/luafilesystem_1_6_3_1-lfs."..test_env.lib_extension)) 187 assert.is.falsy(lfs.attributes(libdir .. "/luafilesystem_"..suffix.."-lfs."..test_env.lib_extension))
183 end) 188 end)
184 189
185 it('handle non-Lua files in build.install.lua when upgrading sailorproject/sailor#138', function() 190 it('handle non-Lua files in build.install.lua when upgrading sailorproject/sailor#138', function()
@@ -193,21 +198,21 @@ describe("luarocks install #integration", function()
193 end) 198 end)
194 199
195 it("only-deps of luasocket packed rock", function() 200 it("only-deps of luasocket packed rock", function()
196 assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket 3.0rc1-2")) 201 assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket ${LUASOCKET}"))
197 local output = run.luarocks("install --only-deps " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock") 202 local output = run.luarocks("install --only-deps " .. "luasocket-${LUASOCKET}." .. test_env.platform .. ".rock")
198 assert.match("Successfully installed dependencies for luasocket 3.0rc1-2", output, 1, true) 203 assert.match(V"Successfully installed dependencies for luasocket ${LUASOCKET}", output, 1, true)
199 assert.is_true(os.remove("luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) 204 assert.is_true(os.remove("luasocket-${LUASOCKET}." .. test_env.platform .. ".rock"))
200 end) 205 end)
201 206
202 it("reinstall", function() 207 it("reinstall", function()
203 assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket 3.0rc1-2")) 208 assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket ${LUASOCKET}"))
204 assert.is_true(run.luarocks_bool("install " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) 209 assert.is_true(run.luarocks_bool("install " .. "luasocket-${LUASOCKET}." .. test_env.platform .. ".rock"))
205 assert.is_true(run.luarocks_bool("install --deps-mode=none " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) 210 assert.is_true(run.luarocks_bool("install --deps-mode=none " .. "luasocket-${LUASOCKET}." .. test_env.platform .. ".rock"))
206 assert.is_true(os.remove("luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) 211 assert.is_true(os.remove("luasocket-${LUASOCKET}." .. test_env.platform .. ".rock"))
207 end) 212 end)
208 213
209 it("installation rolls back on failure", function() 214 it("installation rolls back on failure", function()
210 assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket 3.0rc1-2")) 215 assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket ${LUASOCKET}"))
211 local luadir = testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION 216 local luadir = testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION
212 lfs.mkdir(luadir) 217 lfs.mkdir(luadir)
213 218
@@ -219,7 +224,7 @@ describe("luarocks install #integration", function()
219 fd:close() 224 fd:close()
220 225
221 -- try to install and fail 226 -- try to install and fail
222 assert.is_false(run.luarocks_bool("install " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) 227 assert.is_false(run.luarocks_bool("install " .. "luasocket-${LUASOCKET}." .. test_env.platform .. ".rock"))
223 228
224 -- file is still there 229 -- file is still there
225 assert.is.truthy(lfs.attributes(luadir .. "/socket")) 230 assert.is.truthy(lfs.attributes(luadir .. "/socket"))
@@ -230,13 +235,13 @@ describe("luarocks install #integration", function()
230 assert.is_true(os.remove(luadir .. "/socket")) 235 assert.is_true(os.remove(luadir .. "/socket"))
231 236
232 -- try again and succeed 237 -- try again and succeed
233 assert.is_true(run.luarocks_bool("install " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) 238 assert.is_true(run.luarocks_bool("install " .. "luasocket-${LUASOCKET}." .. test_env.platform .. ".rock"))
234 239
235 -- files installed successfully 240 -- files installed successfully
236 assert.is.truthy(lfs.attributes(luadir .. "/socket/ftp.lua")) 241 assert.is.truthy(lfs.attributes(luadir .. "/socket/ftp.lua"))
237 assert.is.truthy(lfs.attributes(luadir .. "/mime.lua")) 242 assert.is.truthy(lfs.attributes(luadir .. "/mime.lua"))
238 243
239 assert.is_true(os.remove("luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) 244 assert.is_true(os.remove("luasocket-${LUASOCKET}." .. test_env.platform .. ".rock"))
240 end) 245 end)
241 246
242 it("binary rock of cprint", function() 247 it("binary rock of cprint", function()
@@ -246,11 +251,11 @@ describe("luarocks install #integration", function()
246 end) 251 end)
247 252
248 it("accepts --no-manifest flag", function() 253 it("accepts --no-manifest flag", function()
249 assert.is_true(run.luarocks_bool("install lxsh 0.8.6-2")) 254 assert.is_true(run.luarocks_bool("install lxsh ${LXSH}"))
250 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/manifest")) 255 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/manifest"))
251 assert.is.truthy(os.remove(testing_paths.testing_sys_rocks .. "/manifest")) 256 assert.is.truthy(os.remove(testing_paths.testing_sys_rocks .. "/manifest"))
252 257
253 assert.is_true(run.luarocks_bool("install --no-manifest lxsh 0.8.6-2")) 258 assert.is_true(run.luarocks_bool("install --no-manifest lxsh ${LXSH}"))
254 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/manifest")) 259 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/manifest"))
255 end) 260 end)
256 end) 261 end)
diff --git a/spec/list_spec.lua b/spec/list_spec.lua
index 875d72a4..54c63bea 100644
--- a/spec/list_spec.lua
+++ b/spec/list_spec.lua
@@ -1,4 +1,5 @@
1local test_env = require("spec.util.test_env") 1local test_env = require("spec.util.test_env")
2local V = test_env.V
2local run = test_env.run 3local run = test_env.run
3local testing_paths = test_env.testing_paths 4local testing_paths = test_env.testing_paths
4 5
@@ -22,13 +23,13 @@ describe("luarocks list #integration", function()
22 23
23 it("--porcelain", function() 24 it("--porcelain", function()
24 local output = run.luarocks("list --porcelain") 25 local output = run.luarocks("list --porcelain")
25 assert.is.truthy(output:find("luacov\t0.15.0-1\tinstalled\t" .. testing_paths.testing_sys_rocks, 1, true)) 26 assert.is.truthy(output:find(V"luacov\t${LUACOV}\tinstalled\t" .. testing_paths.testing_sys_rocks, 1, true))
26 end) 27 end)
27 28
28 it("shows version number", function() 29 it("shows version number", function()
29 local output = run.luarocks("list") 30 local output = run.luarocks("list")
30 assert.is.truthy(output:find("luacov")) 31 assert.is.truthy(output:find("luacov"))
31 assert.matches("0.15.0-1", output, 1, true) 32 assert.matches(V"${LUACOV}", output, 1, true)
32 end) 33 end)
33 34
34 it("LuaRocks install outdated and list it", function() 35 it("LuaRocks install outdated and list it", function()
diff --git a/spec/make_spec.lua b/spec/make_spec.lua
index e14eb66b..626d84df 100644
--- a/spec/make_spec.lua
+++ b/spec/make_spec.lua
@@ -8,11 +8,11 @@ local write_file = test_env.write_file
8test_env.unload_luarocks() 8test_env.unload_luarocks()
9 9
10local extra_rocks = { 10local extra_rocks = {
11 "/luasocket-3.0rc1-2.src.rock", 11 "/luasocket-${LUASOCKET}.src.rock",
12 "/luasocket-3.0rc1-2.rockspec", 12 "/luasocket-${LUASOCKET}.rockspec",
13 "/lpeg-0.12-1.src.rock", 13 "/lpeg-${LPEG}.src.rock",
14 "/lxsh-0.8.6-2.src.rock", 14 "/lxsh-${LXSH}.src.rock",
15 "/lxsh-0.8.6-2.rockspec" 15 "/lxsh-${LXSH}.rockspec"
16} 16}
17 17
18describe("luarocks make #integration", function() 18describe("luarocks make #integration", function()
@@ -35,35 +35,35 @@ describe("luarocks make #integration", function()
35 finally(function() 35 finally(function()
36 -- delete downloaded and unpacked files 36 -- delete downloaded and unpacked files
37 lfs.chdir(testing_paths.testrun_dir) 37 lfs.chdir(testing_paths.testrun_dir)
38 test_env.remove_dir("luasocket-3.0rc1-2") 38 test_env.remove_dir("luasocket-${LUASOCKET}")
39 os.remove("luasocket-3.0rc1-2.src.rock") 39 os.remove("luasocket-${LUASOCKET}.src.rock")
40 end) 40 end)
41 41
42 -- make luasocket 42 -- make luasocket
43 assert.is_true(run.luarocks_bool("download --source luasocket 3.0rc1-2")) 43 assert.is_true(run.luarocks_bool("download --source luasocket ${LUASOCKET}"))
44 assert.is_true(run.luarocks_bool("unpack luasocket-3.0rc1-2.src.rock")) 44 assert.is_true(run.luarocks_bool("unpack luasocket-${LUASOCKET}.src.rock"))
45 lfs.chdir("luasocket-3.0rc1-2/luasocket-3.0-rc1/") 45 lfs.chdir("luasocket-${LUASOCKET}/luasocket/")
46 assert.is_true(run.luarocks_bool("make luasocket-3.0rc1-2.rockspec")) 46 assert.is_true(run.luarocks_bool("make luasocket-${LUASOCKET}.rockspec"))
47 47
48 -- test it 48 -- test it
49 assert.is_true(run.luarocks_bool("show luasocket")) 49 assert.is_true(run.luarocks_bool("show luasocket"))
50 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasocket/3.0rc1-2/luasocket-3.0rc1-2.rockspec")) 50 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasocket/${LUASOCKET}/luasocket-${LUASOCKET}.rockspec"))
51 end) 51 end)
52 52
53 it("--no-doc", function() 53 it("--no-doc", function()
54 finally(function() 54 finally(function()
55 lfs.chdir(testing_paths.testrun_dir) 55 lfs.chdir(testing_paths.testrun_dir)
56 test_env.remove_dir("luasocket-3.0rc1-2") 56 test_env.remove_dir("luasocket-${LUASOCKET}")
57 os.remove("luasocket-3.0rc1-2.src.rock") 57 os.remove("luasocket-${LUASOCKET}.src.rock")
58 end) 58 end)
59 59
60 assert.is_true(run.luarocks_bool("download --source luasocket 3.0rc1-2")) 60 assert.is_true(run.luarocks_bool("download --source luasocket ${LUASOCKET}"))
61 assert.is_true(run.luarocks_bool("unpack luasocket-3.0rc1-2.src.rock")) 61 assert.is_true(run.luarocks_bool("unpack luasocket-${LUASOCKET}.src.rock"))
62 lfs.chdir("luasocket-3.0rc1-2/luasocket-3.0-rc1/") 62 lfs.chdir("luasocket-${LUASOCKET}/luasocket")
63 assert.is_true(run.luarocks_bool("make --no-doc luasocket-3.0rc1-2.rockspec")) 63 assert.is_true(run.luarocks_bool("make --no-doc luasocket-${LUASOCKET}.rockspec"))
64 64
65 assert.is_true(run.luarocks_bool("show luasocket")) 65 assert.is_true(run.luarocks_bool("show luasocket"))
66 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasocket/3.0rc1-2/doc")) 66 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasocket/${LUASOCKET}/doc"))
67 end) 67 end)
68 68
69 it("--only-deps", function() 69 it("--only-deps", function()
@@ -82,24 +82,24 @@ describe("luarocks make #integration", function()
82 describe("LuaRocks making rockspecs (using lxsh)", function() 82 describe("LuaRocks making rockspecs (using lxsh)", function()
83 --download lxsh and unpack it 83 --download lxsh and unpack it
84 before_each(function() 84 before_each(function()
85 assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6-2")) 85 assert.is_true(run.luarocks_bool("download --source lxsh ${LXSH}"))
86 assert.is_true(run.luarocks_bool("unpack lxsh-0.8.6-2.src.rock")) 86 assert.is_true(run.luarocks_bool("unpack lxsh-${LXSH}.src.rock"))
87 assert.is_true(lfs.chdir("lxsh-0.8.6-2/lxsh-0.8.6-1/")) 87 assert.is_true(lfs.chdir("lxsh-${LXSH}/lxsh-${LXSH_V}-1/"))
88 end) 88 end)
89 89
90 -- delete downloaded and unpacked files 90 -- delete downloaded and unpacked files
91 after_each(function() 91 after_each(function()
92 assert(lfs.chdir(testing_paths.testrun_dir)) 92 assert(lfs.chdir(testing_paths.testrun_dir))
93 test_env.remove_dir("lxsh-0.8.6-2") 93 test_env.remove_dir("lxsh-${LXSH}")
94 assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) 94 assert.is_true(os.remove("lxsh-${LXSH}.src.rock"))
95 end) 95 end)
96 96
97 it("default rockspec", function() 97 it("default rockspec", function()
98 assert.is_true(run.luarocks_bool("new_version lxsh-0.8.6-2.rockspec")) 98 assert.is_true(run.luarocks_bool("new_version lxsh-${LXSH}.rockspec"))
99 assert.is_true(run.luarocks_bool("make")) 99 assert.is_true(run.luarocks_bool("make"))
100 100
101 assert.is_true(run.luarocks_bool("show lxsh")) 101 assert.is_true(run.luarocks_bool("show lxsh"))
102 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-3/lxsh-0.8.6-3.rockspec")) 102 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/${LXSH_V}-3/lxsh-${LXSH_V}-3.rockspec"))
103 end) 103 end)
104 104
105 it("unnamed rockspec", function() 105 it("unnamed rockspec", function()
@@ -107,35 +107,35 @@ describe("luarocks make #integration", function()
107 os.remove("rockspec") 107 os.remove("rockspec")
108 end) 108 end)
109 109
110 test_env.copy("lxsh-0.8.6-2.rockspec", "rockspec") 110 test_env.copy("lxsh-${LXSH}.rockspec", "rockspec")
111 assert.is_true(run.luarocks_bool("make")) 111 assert.is_true(run.luarocks_bool("make"))
112 112
113 assert.is_true(run.luarocks_bool("show lxsh")) 113 assert.is_true(run.luarocks_bool("show lxsh"))
114 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) 114 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/${LXSH}/lxsh-${LXSH}.rockspec"))
115 end) 115 end)
116 116
117 it("ambiguous rockspec", function() 117 it("ambiguous rockspec", function()
118 assert.is.truthy(os.rename("lxsh-0.8.6-2.rockspec", "lxsh2-0.8.6-2.rockspec")) 118 assert.is.truthy(os.rename("lxsh-${LXSH}.rockspec", "lxsh2-${LXSH}.rockspec"))
119 local output = run.luarocks("make") 119 local output = run.luarocks("make")
120 assert.is.truthy(output:match("Error: Inconsistency between rockspec filename")) 120 assert.is.truthy(output:match("Error: Inconsistency between rockspec filename"))
121 121
122 assert.is_false(run.luarocks_bool("show lxsh")) 122 assert.is_false(run.luarocks_bool("show lxsh"))
123 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) 123 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/${LXSH}/lxsh-${LXSH}.rockspec"))
124 end) 124 end)
125 125
126 it("ambiguous unnamed rockspec", function() 126 it("ambiguous unnamed rockspec", function()
127 assert.is.truthy(os.rename("lxsh-0.8.6-2.rockspec", "1_rockspec")) 127 assert.is.truthy(os.rename("lxsh-${LXSH}.rockspec", "1_rockspec"))
128 test_env.copy("1_rockspec", "2_rockspec") 128 test_env.copy("1_rockspec", "2_rockspec")
129 local output = run.luarocks("make") 129 local output = run.luarocks("make")
130 assert.is.truthy(output:match("Error: Please specify which rockspec file to use")) 130 assert.is.truthy(output:match("Error: Please specify which rockspec file to use"))
131 131
132 assert.is_false(run.luarocks_bool("show lxsh")) 132 assert.is_false(run.luarocks_bool("show lxsh"))
133 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) 133 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/${LXSH}/lxsh-${LXSH}.rockspec"))
134 end) 134 end)
135 135
136 it("pack binary rock", function() 136 it("pack binary rock", function()
137 assert.is_true(run.luarocks_bool("make --deps-mode=none --pack-binary-rock")) 137 assert.is_true(run.luarocks_bool("make --deps-mode=none --pack-binary-rock"))
138 assert.is.truthy(lfs.attributes("lxsh-0.8.6-2.all.rock")) 138 assert.is.truthy(lfs.attributes("lxsh-${LXSH}.all.rock"))
139 end) 139 end)
140 end) 140 end)
141 141
diff --git a/spec/new_version_spec.lua b/spec/new_version_spec.lua
index f8795db0..d47cfd05 100644
--- a/spec/new_version_spec.lua
+++ b/spec/new_version_spec.lua
@@ -7,7 +7,7 @@ test_env.unload_luarocks()
7 7
8local extra_rocks = { 8local extra_rocks = {
9 "/abelhas-1.1-1.rockspec", 9 "/abelhas-1.1-1.rockspec",
10 "/lpeg-0.12-1.rockspec" 10 "/lpeg-${LPEG}.rockspec"
11} 11}
12 12
13describe("luarocks new_version #integration", function() 13describe("luarocks new_version #integration", function()
@@ -41,8 +41,8 @@ describe("luarocks new_version #integration", function()
41 41
42 describe("more complex tests", function() 42 describe("more complex tests", function()
43 it("of luacov", function() 43 it("of luacov", function()
44 assert.is_true(run.luarocks_bool("download --rockspec luacov 0.15.0")) 44 assert.is_true(run.luarocks_bool("download --rockspec luacov ${LUACOV_V}"))
45 assert.is_true(run.luarocks_bool("new_version luacov-0.15.0-1.rockspec 0.2")) 45 assert.is_true(run.luarocks_bool("new_version luacov-${LUACOV}.rockspec 0.2"))
46 assert.is.truthy(lfs.attributes("luacov-0.2-1.rockspec")) 46 assert.is.truthy(lfs.attributes("luacov-0.2-1.rockspec"))
47 test_env.remove_files(lfs.currentdir(), "luacov%-") 47 test_env.remove_files(lfs.currentdir(), "luacov%-")
48 end) 48 end)
@@ -55,15 +55,15 @@ describe("luarocks new_version #integration", function()
55 end) 55 end)
56 56
57 it("of luacov with tag", function() 57 it("of luacov with tag", function()
58 assert.is_true(run.luarocks_bool("download --rockspec luacov 0.15.0")) 58 assert.is_true(run.luarocks_bool("download --rockspec luacov ${LUACOV_V}"))
59 assert.is_true(run.luarocks_bool("new_version luacov-0.15.0-1.rockspec --tag v0.3")) 59 assert.is_true(run.luarocks_bool("new_version luacov-${LUACOV}.rockspec --tag v0.3"))
60 assert.is.truthy(lfs.attributes("luacov-0.3-1.rockspec")) 60 assert.is.truthy(lfs.attributes("luacov-0.3-1.rockspec"))
61 test_env.remove_files(lfs.currentdir(), "luacov%-") 61 test_env.remove_files(lfs.currentdir(), "luacov%-")
62 end) 62 end)
63 63
64 it("updating md5", function() 64 it("updating md5", function()
65 assert.is_true(run.luarocks_bool("download --rockspec lpeg 0.12")) 65 assert.is_true(run.luarocks_bool("download --rockspec lpeg ${LPEG_V}"))
66 assert.is_true(run.luarocks_bool("new_version lpeg-0.12-1.rockspec 0.2 https://luarocks.org/manifests/gvvaughan/lpeg-1.0.0-1.rockspec")) 66 assert.is_true(run.luarocks_bool("new_version lpeg-${LPEG}.rockspec 0.2 https://luarocks.org/manifests/gvvaughan/lpeg-1.0.0-1.rockspec"))
67 test_env.remove_files(lfs.currentdir(), "lpeg%-") 67 test_env.remove_files(lfs.currentdir(), "lpeg%-")
68 end) 68 end)
69 end) 69 end)
diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua
index d81258c6..0a4e0d8a 100644
--- a/spec/pack_spec.lua
+++ b/spec/pack_spec.lua
@@ -8,8 +8,8 @@ test_env.unload_luarocks()
8 8
9local extra_rocks = { 9local extra_rocks = {
10 "/luassert-1.7.0-1.src.rock", 10 "/luassert-1.7.0-1.src.rock",
11 "/luasocket-3.0rc1-2.src.rock", 11 "/luasocket-${LUASOCKET}.src.rock",
12 "/luasocket-3.0rc1-2.rockspec", 12 "/luasocket-${LUASOCKET}.rockspec",
13 "/say-1.2-1.src.rock", 13 "/say-1.2-1.src.rock",
14 "/say-1.0-1.src.rock" 14 "/say-1.0-1.src.rock"
15} 15}
diff --git a/spec/remove_spec.lua b/spec/remove_spec.lua
index 21a39696..a67db591 100644
--- a/spec/remove_spec.lua
+++ b/spec/remove_spec.lua
@@ -3,16 +3,17 @@ local 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 env_variables = test_env.env_variables
6local V = test_env.V
6 7
7test_env.unload_luarocks() 8test_env.unload_luarocks()
8 9
9local extra_rocks = { 10local extra_rocks = {
10 "/abelhas-1.1-1.src.rock", 11 "/abelhas-1.1-1.src.rock",
11 "/copas-2.0.1-1.src.rock", 12 "/copas-${COPAS}.src.rock",
12 "/coxpcall-1.16.0-1.src.rock", 13 "/coxpcall-1.16.0-1.src.rock",
13 "/coxpcall-1.16.0-1.rockspec", 14 "/coxpcall-1.16.0-1.rockspec",
14 "/luafilesystem-1.7.0-1.src.rock", 15 "/luafilesystem-${LUAFILESYSTEM}.src.rock",
15 "/luafilesystem-1.6.3-2.src.rock", 16 "/luafilesystem-${LUAFILESYSTEM_OLD}.src.rock",
16} 17}
17 18
18describe("luarocks remove #integration", function() 19describe("luarocks remove #integration", function()
@@ -85,31 +86,35 @@ describe("luarocks remove #integration", function()
85 end) 86 end)
86 87
87 it("restores old versions", function() 88 it("restores old versions", function()
88 assert.is_true(run.luarocks_bool("install luafilesystem 1.6.3")) 89 local libdir = testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION
89 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension)) 90
91 assert.is_true(run.luarocks_bool("install luafilesystem ${LUAFILESYSTEM_OLD_V}"))
92 assert.is.truthy(lfs.attributes(libdir.."/lfs."..test_env.lib_extension))
90 93
91 if test_env.TEST_TARGET_OS ~= "windows" then 94 if test_env.TEST_TARGET_OS ~= "windows" then
92 local fd = io.open(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension, "r") 95 local fd = io.open(libdir.."/lfs."..test_env.lib_extension, "r")
93 assert(fd:read("*a"):match("LuaFileSystem 1.6.3", 1, true)) 96 assert(fd:read("*a"):match(V"LuaFileSystem ${LUAFILESYSTEM_OLD_V}", 1, true))
94 fd:close() 97 fd:close()
95 end 98 end
96 99
97 assert.is_true(run.luarocks_bool("install luafilesystem 1.7.0 --keep")) 100 local suffix = (V"${LUAFILESYSTEM_OLD}"):gsub("[%.%-]", "_")
98 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension)) 101
99 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/luafilesystem_1_6_3_2-lfs."..test_env.lib_extension)) 102 assert.is_true(run.luarocks_bool("install luafilesystem ${LUAFILESYSTEM_V} --keep"))
103 assert.is.truthy(lfs.attributes(libdir.."/lfs."..test_env.lib_extension))
104 assert.is.truthy(lfs.attributes(libdir.."/luafilesystem_"..suffix.."-lfs."..test_env.lib_extension))
100 105
101 if test_env.TEST_TARGET_OS ~= "windows" then 106 if test_env.TEST_TARGET_OS ~= "windows" then
102 local fd = io.open(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension, "r") 107 local fd = io.open(libdir.."/lfs."..test_env.lib_extension, "r")
103 assert(fd:read("*a"):match("LuaFileSystem 1.7.0", 1, true)) 108 assert(fd:read("*a"):match(V"LuaFileSystem ${LUAFILESYSTEM_V}", 1, true))
104 fd:close() 109 fd:close()
105 end 110 end
106 111
107 assert.is_true(run.luarocks_bool("remove luafilesystem 1.7.0")) 112 assert.is_true(run.luarocks_bool("remove luafilesystem ${LUAFILESYSTEM_V}"))
108 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension)) 113 assert.is.truthy(lfs.attributes(libdir.."/lfs."..test_env.lib_extension))
109 114
110 if test_env.TEST_TARGET_OS ~= "windows" then 115 if test_env.TEST_TARGET_OS ~= "windows" then
111 local fd = io.open(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension, "r") 116 local fd = io.open(libdir.."/lfs."..test_env.lib_extension, "r")
112 assert(fd:read("*a"):match("LuaFileSystem 1.6.3", 1, true)) 117 assert(fd:read("*a"):match(V"LuaFileSystem ${LUAFILESYSTEM_OLD_V}", 1, true))
113 fd:close() 118 fd:close()
114 end 119 end
115 end) 120 end)
diff --git a/spec/test_spec.lua b/spec/test_spec.lua
index 943d0e48..21844d63 100644
--- a/spec/test_spec.lua
+++ b/spec/test_spec.lua
@@ -10,7 +10,7 @@ test_env.unload_luarocks()
10local extra_rocks = { 10local extra_rocks = {
11 "/busted-2.0.0-1.rockspec", 11 "/busted-2.0.0-1.rockspec",
12 "/lua_cliargs-3.0-1.src.rock", 12 "/lua_cliargs-3.0-1.src.rock",
13 "/luafilesystem-1.7.0-2.src.rock", 13 "/luafilesystem-${LUAFILESYSTEM}.src.rock",
14 "/luasystem-0.2.1-0.src.rock", 14 "/luasystem-0.2.1-0.src.rock",
15 "/dkjson-2.5-2.src.rock", 15 "/dkjson-2.5-2.src.rock",
16 "/say-1.3-1.rockspec", 16 "/say-1.3-1.rockspec",
@@ -41,6 +41,7 @@ describe("luarocks test #integration", function()
41 lazy_setup(function() 41 lazy_setup(function()
42 -- Try to cache rocks from the host system to speed up test 42 -- Try to cache rocks from the host system to speed up test
43 for _, r in ipairs(extra_rocks) do 43 for _, r in ipairs(extra_rocks) do
44 r = test_env.V(r)
44 local n, v = r:match("^/(.*)%-([^%-]+)%-%d+%.[^%-]+$") 45 local n, v = r:match("^/(.*)%-([^%-]+)%-%d+%.[^%-]+$")
45 os.execute("luarocks pack " .. n .. " " .. v) 46 os.execute("luarocks pack " .. n .. " " .. v)
46 end 47 end
@@ -84,17 +85,17 @@ describe("luarocks test #integration", function()
84 assert.is_true(run.luarocks_bool("unpack busted_project-0.1-1.src.rock")) 85 assert.is_true(run.luarocks_bool("unpack busted_project-0.1-1.src.rock"))
85 lfs.chdir("busted_project-0.1-1/busted_project") 86 lfs.chdir("busted_project-0.1-1/busted_project")
86 assert.is_true(run.luarocks_bool("make")) 87 assert.is_true(run.luarocks_bool("make"))
87 88
88 run.luarocks_bool("remove busted") 89 run.luarocks_bool("remove busted")
89 local prepareOutput = run.luarocks_bool("test --prepare") 90 local prepareOutput = run.luarocks_bool("test --prepare")
90 assert.is_true(run.luarocks_bool("show busted")) 91 assert.is_true(run.luarocks_bool("show busted"))
91 92
92 -- Assert that "test --prepare" run successfully 93 -- Assert that "test --prepare" run successfully
93 assert.is_true(prepareOutput) 94 assert.is_true(prepareOutput)
94 95
95 local output = run.luarocks("test") 96 local output = run.luarocks("test")
96 assert.not_match(tostring(prepareOutput), output) 97 assert.not_match(tostring(prepareOutput), output)
97 98
98 end) 99 end)
99 end) 100 end)
100end) 101end)
diff --git a/spec/upload_spec.lua b/spec/upload_spec.lua
index 73775992..73f26cd7 100644
--- a/spec/upload_spec.lua
+++ b/spec/upload_spec.lua
@@ -23,12 +23,12 @@ describe("luarocks upload #integration", function()
23 end) 23 end)
24 24
25 it("api key invalid and skip-pack", function() 25 it("api key invalid and skip-pack", function()
26 assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --skip-pack " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec")) 26 assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --skip-pack " .. testing_paths.testing_server .. "/luasocket-${LUASOCKET}.rockspec"))
27 end) 27 end)
28 28
29 it("force #unix", function() 29 it("force #unix", function()
30 assert.is_true(test_env.need_rock("dkjson")) 30 assert.is_true(test_env.need_rock("dkjson"))
31 assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --force " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec")) 31 assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --force " .. testing_paths.testing_server .. "/luasocket-${LUASOCKET}.rockspec"))
32 end) 32 end)
33 33
34 describe("tests with Xavante server #mock", function() 34 describe("tests with Xavante server #mock", function()
diff --git a/spec/util/test_env.lua b/spec/util/test_env.lua
index 737d90a5..6a466bae 100644
--- a/spec/util/test_env.lua
+++ b/spec/util/test_env.lua
@@ -1,6 +1,7 @@
1local test_env = {} 1local test_env = {}
2 2
3local lfs = require("lfs") 3local lfs = require("lfs")
4local versions = require("spec.util.versions")
4 5
5local help_message = [[ 6local help_message = [[
6LuaRocks test-suite 7LuaRocks test-suite
@@ -36,14 +37,6 @@ local function title(str)
36 print(("-"):rep(#str)) 37 print(("-"):rep(#str))
37end 38end
38 39
39function test_env.exists(path)
40 return lfs.attributes(path, "mode") ~= nil
41end
42
43function test_env.file_if_exists(path)
44 return lfs.attributes(path, "mode") and path
45end
46
47--- Quote argument for shell processing. Fixes paths on Windows. 40--- Quote argument for shell processing. Fixes paths on Windows.
48-- Adds double quotes and escapes. Based on function in fs/win32.lua. 41-- Adds double quotes and escapes. Based on function in fs/win32.lua.
49-- @param arg string: Unquoted argument. 42-- @param arg string: Unquoted argument.
@@ -66,6 +59,62 @@ local function Q(arg)
66 end 59 end
67end 60end
68 61
62local function V(str)
63 return (str:gsub("${([^}]-)}", function(name)
64 name = name:lower()
65 local prefix, suffix = name:match("^(.*)_(.)$")
66 if suffix then
67 name = prefix
68 local d = assert(versions[name])
69 local v, r = d:match("^([^-]*)%-(%d*)$")
70 if suffix == "d" then
71 return d
72 elseif suffix == "v" then
73 return v
74 elseif suffix == "r" then
75 return v
76 else
77 print("Test error: invalid suffix " .. suffix .. " in variable " .. name)
78 os.exit(1)
79 end
80 else
81 if not versions[name] then
82 print("Test error: no version definition for " .. name)
83 os.exit(1)
84 end
85 return versions[name]
86 end
87 end))
88end
89
90local os_remove = os.remove
91os.remove = function(f) -- luacheck: ignore
92 return os_remove(V(f))
93end
94
95local os_rename = os.rename
96os.rename = function(a, b) -- luacheck: ignore
97 return os_rename(V(a), V(b))
98end
99
100local lfs_chdir = lfs.chdir
101lfs.chdir = function(d) -- luacheck: ignore
102 return lfs_chdir(V(d))
103end
104
105local lfs_attributes = lfs.attributes
106lfs.attributes = function(f, ...) -- luacheck: ignore
107 return lfs_attributes(V(f), ...)
108end
109
110function test_env.exists(path)
111 return lfs.attributes(path, "mode") ~= nil
112end
113
114function test_env.file_if_exists(path)
115 return lfs.attributes(path, "mode") and path
116end
117
69function test_env.quiet(command) 118function test_env.quiet(command)
70 if not test_env.VERBOSE then 119 if not test_env.VERBOSE then
71 if test_env.TEST_TARGET_OS == "windows" then 120 if test_env.TEST_TARGET_OS == "windows" then
@@ -79,6 +128,9 @@ function test_env.quiet(command)
79end 128end
80 129
81function test_env.copy(source, destination) 130function test_env.copy(source, destination)
131 source = V(source)
132 destination = V(destination)
133
82 local r_source, err = io.open(source, "r") 134 local r_source, err = io.open(source, "r")
83 local r_destination, err = io.open(destination, "w") 135 local r_destination, err = io.open(destination, "w")
84 136
@@ -303,6 +355,9 @@ function test_env.set_args()
303end 355end
304 356
305function test_env.copy_dir(source_path, target_path) 357function test_env.copy_dir(source_path, target_path)
358 source_path = V(source_path)
359 target_path = V(target_path)
360
306 local testing_paths = test_env.testing_paths 361 local testing_paths = test_env.testing_paths
307 if test_env.TEST_TARGET_OS == "windows" then 362 if test_env.TEST_TARGET_OS == "windows" then
308 execute_bool(testing_paths.win_tools .. "/cp -R ".. source_path .. "/. " .. target_path) 363 execute_bool(testing_paths.win_tools .. "/cp -R ".. source_path .. "/. " .. target_path)
@@ -314,6 +369,8 @@ end
314--- Remove directory recursively 369--- Remove directory recursively
315-- @param path string: directory path to delete 370-- @param path string: directory path to delete
316function test_env.remove_dir(path) 371function test_env.remove_dir(path)
372 path = V(path)
373
317 if test_env.exists(path) then 374 if test_env.exists(path) then
318 for file in lfs.dir(path) do 375 for file in lfs.dir(path) do
319 if file ~= "." and file ~= ".." then 376 if file ~= "." and file ~= ".." then
@@ -334,6 +391,8 @@ end
334-- @param path string: path to directory 391-- @param path string: path to directory
335-- @param pattern string: pattern matching basenames of subdirectories to be removed 392-- @param pattern string: pattern matching basenames of subdirectories to be removed
336function test_env.remove_subdirs(path, pattern) 393function test_env.remove_subdirs(path, pattern)
394 path = V(path)
395
337 if test_env.exists(path) then 396 if test_env.exists(path) then
338 for file in lfs.dir(path) do 397 for file in lfs.dir(path) do
339 if file ~= "." and file ~= ".." then 398 if file ~= "." and file ~= ".." then
@@ -352,6 +411,8 @@ end
352-- @param pattern string: pattern matching basenames of files to be deleted 411-- @param pattern string: pattern matching basenames of files to be deleted
353-- @return result_check boolean: true if one or more files deleted 412-- @return result_check boolean: true if one or more files deleted
354function test_env.remove_files(path, pattern) 413function test_env.remove_files(path, pattern)
414 path = V(path)
415
355 local result_check = false 416 local result_check = false
356 if test_env.exists(path) then 417 if test_env.exists(path) then
357 for file in lfs.dir(path) do 418 for file in lfs.dir(path) do
@@ -378,6 +439,8 @@ local function download_rocks(urls, save_path)
378 local to_download = {} 439 local to_download = {}
379 local fixtures = {} 440 local fixtures = {}
380 for _, url in ipairs(urls) do 441 for _, url in ipairs(urls) do
442 url = V(url)
443
381 if url:match("^spec/fixtures") then 444 if url:match("^spec/fixtures") then
382 table.insert(fixtures, (url:gsub("^spec/fixtures", test_env.testing_paths.fixtures_dir))) 445 table.insert(fixtures, (url:gsub("^spec/fixtures", test_env.testing_paths.fixtures_dir)))
383 else 446 else
@@ -399,7 +462,10 @@ local function download_rocks(urls, save_path)
399 else 462 else
400 cmd = "wget -cP " .. save_path 463 cmd = "wget -cP " .. save_path
401 end 464 end
402 assert(execute_bool(cmd.." "..table.concat(to_download, " "))) 465 local ok = execute_bool(cmd.." "..table.concat(to_download, " "))
466 if not ok then
467 os.exit(1)
468 end
403 end 469 end
404 470
405 return (#fixtures > 0) or (#to_download > 0) 471 return (#fixtures > 0) or (#to_download > 0)
@@ -409,6 +475,8 @@ end
409-- @param pathname string: path to file. 475-- @param pathname string: path to file.
410-- @param str string: content of the file. 476-- @param str string: content of the file.
411function test_env.write_file(pathname, str, finally) 477function test_env.write_file(pathname, str, finally)
478 pathname = V(pathname)
479
412 local file = assert(io.open(pathname, "w")) 480 local file = assert(io.open(pathname, "w"))
413 file:write(str) 481 file:write(str)
414 file:close() 482 file:close()
@@ -487,6 +555,7 @@ local function make_run_function(cmd_name, exec_function, with_coverage, do_prin
487 end 555 end
488 556
489 return function(cmd, new_vars) 557 return function(cmd, new_vars)
558 cmd = V(cmd)
490 local temp_vars = {} 559 local temp_vars = {}
491 for k, v in pairs(test_env.env_variables) do 560 for k, v in pairs(test_env.env_variables) do
492 temp_vars[k] = v 561 temp_vars[k] = v
@@ -519,7 +588,11 @@ local function move_file(src, dst)
519 if test_env.TEST_TARGET_OS == "windows" then 588 if test_env.TEST_TARGET_OS == "windows" then
520 execute_bool(test_env.testing_paths.win_tools .. "/mv " .. src .. " " .. dst) 589 execute_bool(test_env.testing_paths.win_tools .. "/mv " .. src .. " " .. dst)
521 else 590 else
522 execute_bool("mv " .. src .. " " .. dst) 591 local ok = execute_bool("mv " .. src .. " " .. dst)
592 if not ok then
593 print(debug.traceback())
594 os.exit(1)
595 end
523 end 596 end
524end 597end
525 598
@@ -541,9 +614,9 @@ local function build_environment(rocks, env_variables)
541 test_env.run.luarocks_admin_nocov("make_manifest " .. Q(testing_paths.testing_cache)) 614 test_env.run.luarocks_admin_nocov("make_manifest " .. Q(testing_paths.testing_cache))
542 615
543 for _, rock in ipairs(rocks) do 616 for _, rock in ipairs(rocks) do
544 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 617 if not test_env.run.luarocks_nocov(test_env.quiet("install --only-server=" .. testing_paths.testing_cache .. " --tree=" .. testing_paths.testing_sys_tree .. " " .. Q(rock), env_variables)) then
545 test_env.run.luarocks_nocov("build --tree=" .. Q(testing_paths.testing_sys_tree) .. " " .. Q(rock), env_variables) 618 assert(test_env.run.luarocks_nocov("build --tree=" .. Q(testing_paths.testing_sys_tree) .. " " .. Q(rock), env_variables))
546 test_env.run.luarocks_nocov("pack --tree=" .. Q(testing_paths.testing_sys_tree) .. " " .. Q(rock), env_variables) 619 assert(test_env.run.luarocks_nocov("pack --tree=" .. Q(testing_paths.testing_sys_tree) .. " " .. Q(rock), env_variables))
547 move_file(rock .. "-*.rock", testing_paths.testing_cache) 620 move_file(rock .. "-*.rock", testing_paths.testing_cache)
548 end 621 end
549 end 622 end
@@ -685,6 +758,8 @@ end
685-- Return `true` if the rock is already installed or has been installed successfully, 758-- Return `true` if the rock is already installed or has been installed successfully,
686-- `false` if installation failed. 759-- `false` if installation failed.
687function test_env.need_rock(rock) 760function test_env.need_rock(rock)
761 rock = V(rock)
762
688 print("Check if " .. rock .. " is installed") 763 print("Check if " .. rock .. " is installed")
689 if test_env.run.luarocks_noprint_nocov(test_env.quiet("show " .. rock)) then 764 if test_env.run.luarocks_noprint_nocov(test_env.quiet("show " .. rock)) then
690 return true 765 return true
@@ -887,10 +962,12 @@ local function prepare_mock_server_binary_rocks()
887 962
888 local rocks = { 963 local rocks = {
889 -- rocks needed for mock-server 964 -- rocks needed for mock-server
890 "luasocket-3.0rc1-2.src.rock", 965 "luasocket-${LUASOCKET}.src.rock",
891 "coxpcall-1.16.0-1.src.rock", 966 "coxpcall-1.16.0-1.src.rock",
892 "copas-2.0.1-1.src.rock", 967 "binaryheap-${BINARYHEAP}.src.rock",
893 "luafilesystem-1.7.0-2.src.rock", 968 "timerwheel-${TIMERWHEEL}.src.rock",
969 "copas-${COPAS}.src.rock",
970 "luafilesystem-${LUAFILESYSTEM}.src.rock",
894 "xavante-2.4.0-1.src.rock", 971 "xavante-2.4.0-1.src.rock",
895 "wsapi-1.6.1-1.src.rock", 972 "wsapi-1.6.1-1.src.rock",
896 "rings-1.3.0-1.src.rock", 973 "rings-1.3.0-1.src.rock",
@@ -901,6 +978,7 @@ local function prepare_mock_server_binary_rocks()
901 } 978 }
902 local make_manifest = download_rocks(rocks, testing_paths.testing_server) 979 local make_manifest = download_rocks(rocks, testing_paths.testing_server)
903 for _, rock in ipairs(rocks) do 980 for _, rock in ipairs(rocks) do
981 rock = V(rock)
904 local rockname = rock:gsub("%-[^-]+%-%d+%.[%a.]+$", "") 982 local rockname = rock:gsub("%-[^-]+%-%d+%.[%a.]+$", "")
905 if not find_binary_rock(rock, testing_paths.testing_server) then 983 if not find_binary_rock(rock, testing_paths.testing_server) then
906 test_env.run.luarocks_nocov("build " .. Q(testing_paths.testing_server .. "/" .. rock) .. " --tree=" .. testing_paths.testing_cache) 984 test_env.run.luarocks_nocov("build " .. Q(testing_paths.testing_server .. "/" .. rock) .. " --tree=" .. testing_paths.testing_cache)
@@ -937,25 +1015,29 @@ function test_env.main()
937 local urls = {} -- names of rock and rockspec files to be downloaded 1015 local urls = {} -- names of rock and rockspec files to be downloaded
938 1016
939 if test_env.TYPE_TEST_ENV == "full" then 1017 if test_env.TYPE_TEST_ENV == "full" then
940 table.insert(urls, "/luafilesystem-1.6.3-1.src.rock") 1018 table.insert(urls, "/luafilesystem-${LUAFILESYSTEM}.src.rock")
941 table.insert(urls, "/luasocket-3.0rc1-1.src.rock") 1019 table.insert(urls, "/luasocket-${LUASOCKET}.src.rock")
942 table.insert(urls, "/luasocket-3.0rc1-1.rockspec") 1020 table.insert(urls, "/luasocket-${LUASOCKET}.rockspec")
943 table.insert(urls, "/md5-1.2-1.src.rock") 1021 table.insert(urls, "/md5-1.2-1.src.rock")
944 --table.insert(urls, "/lzlib-0.4.1.53-1.src.rock") 1022 --table.insert(urls, "/lzlib-0.4.1.53-1.src.rock")
945 table.insert(urls, "/lua-zlib-1.2-0.src.rock") 1023 table.insert(urls, "/lua-zlib-1.2-0.src.rock")
946 table.insert(urls, "/lua-bz2-0.1.0-1.src.rock") 1024 table.insert(urls, "/lua-bz2-0.1.0-1.src.rock")
947 rocks = {"luafilesystem", "luasocket", "md5", "lua-zlib", "lua-bz2"} 1025 rocks = {"luafilesystem", "luasocket", "md5", "lua-zlib", "lua-bz2"}
948 if test_env.TEST_TARGET_OS ~= "windows" then 1026 if test_env.TEST_TARGET_OS ~= "windows" then
949 table.insert(urls, "/luaposix-33.2.1-1.src.rock") 1027 if test_env.lua_version == "5.1" then
1028 table.insert(urls, "/bit32-${BIT32}.src.rock")
1029 table.insert(rocks, "bit32")
1030 end
1031 table.insert(urls, "/luaposix-${LUAPOSIX}.src.rock")
950 table.insert(rocks, "luaposix") 1032 table.insert(rocks, "luaposix")
951 end 1033 end
952 end 1034 end
953 1035
954 -- luacov is needed for both minimal or full environment 1036 -- luacov is needed for both minimal or full environment
955 table.insert(urls, "/luacov-0.15.0-1.rockspec") 1037 table.insert(urls, "/luacov-${LUACOV}.rockspec")
956 table.insert(urls, "/luacov-0.15.0-1.src.rock") 1038 table.insert(urls, "/luacov-${LUACOV}.src.rock")
957 table.insert(urls, "/cluacov-0.1.1-1.rockspec") 1039 table.insert(urls, "/cluacov-${CLUACOV}.rockspec")
958 table.insert(urls, "/cluacov-0.1.1-1.src.rock") 1040 table.insert(urls, "/cluacov-${CLUACOV}.src.rock")
959 table.insert(rocks, "luacov") 1041 table.insert(rocks, "luacov")
960 table.insert(rocks, "cluacov") 1042 table.insert(rocks, "cluacov")
961 1043
@@ -977,5 +1059,6 @@ test_env.set_args()
977test_env.testing_paths = create_paths(test_env.LUA_V or test_env.LUAJIT_V) 1059test_env.testing_paths = create_paths(test_env.LUA_V or test_env.LUAJIT_V)
978test_env.env_variables = create_env(test_env.testing_paths) 1060test_env.env_variables = create_env(test_env.testing_paths)
979test_env.run = make_run_functions() 1061test_env.run = make_run_functions()
1062test_env.V = V
980 1063
981return test_env 1064return test_env
diff --git a/spec/util/versions.lua b/spec/util/versions.lua
new file mode 100644
index 00000000..b0d5c453
--- /dev/null
+++ b/spec/util/versions.lua
@@ -0,0 +1,14 @@
1return {
2 binaryheap = "0.4-1", -- dependency for copas
3 bit32 = "5.3.5.1-1", -- dependency for luaposix on Lua 5.1
4 cluacov = "0.1.2-1",
5 copas = "3.0.0-1",
6 lpeg = "1.0.0-1",
7 luacov = "0.15.0-1",
8 luafilesystem = "1.8.0-1",
9 luafilesystem_old = "1.6.3-2",
10 luaposix = "35.1-1",
11 luasocket = "3.0.0-1",
12 lxsh = "0.8.6-2",
13 timerwheel = "0.2.0-2", -- dependency for copas
14}