diff options
-rw-r--r-- | spec/build_spec.lua | 36 | ||||
-rw-r--r-- | spec/help_spec.lua | 6 | ||||
-rw-r--r-- | spec/install_spec.lua | 12 | ||||
-rw-r--r-- | spec/make_spec.lua | 12 | ||||
-rw-r--r-- | spec/pack_spec.lua | 8 | ||||
-rw-r--r-- | spec/remove_spec.lua | 2 | ||||
-rw-r--r-- | spec/search_spec.lua | 6 | ||||
-rw-r--r-- | spec/upload_spec.lua | 37 | ||||
-rw-r--r-- | spec/util_spec.lua | 13 | ||||
-rw-r--r-- | spec/write_rockspec_spec.lua | 3 | ||||
-rw-r--r-- | test/luarocks_site.lua | 6 | ||||
-rw-r--r-- | test/mock-server.lua | 80 | ||||
-rw-r--r-- | test/test_environment.lua | 39 |
13 files changed, 198 insertions, 62 deletions
diff --git a/spec/build_spec.lua b/spec/build_spec.lua index 682c6dcf..2ede5211 100644 --- a/spec/build_spec.lua +++ b/spec/build_spec.lua | |||
@@ -57,7 +57,7 @@ describe("LuaRocks build tests #blackbox #b_build", function() | |||
57 | end) | 57 | end) |
58 | 58 | ||
59 | it("LuaRocks build lpeg verbose", function() | 59 | it("LuaRocks build lpeg verbose", function() |
60 | assert.is_true(run.luarocks_bool("build --verbose lpeg")) | 60 | assert.is.truthy(run.luarocks("build --verbose lpeg")) |
61 | end) | 61 | end) |
62 | 62 | ||
63 | it("LuaRocks build lpeg branch=master", function() | 63 | it("LuaRocks build lpeg branch=master", function() |
@@ -82,9 +82,8 @@ describe("LuaRocks build tests #blackbox #b_build", function() | |||
82 | end) | 82 | end) |
83 | 83 | ||
84 | describe("LuaRocks build - basic builds", function() | 84 | describe("LuaRocks build - basic builds", function() |
85 | |||
86 | it("LuaRocks build luadoc", function() | 85 | it("LuaRocks build luadoc", function() |
87 | assert.is_true(run.luarocks_bool("build luadoc")) | 86 | assert.is_true(run.luarocks_bool(test_env.quiet("build luadoc"))) |
88 | end) | 87 | end) |
89 | 88 | ||
90 | it("LuaRocks build luacov diff version", function() | 89 | it("LuaRocks build luacov diff version", function() |
@@ -103,12 +102,12 @@ describe("LuaRocks build tests #blackbox #b_build", function() | |||
103 | end) | 102 | end) |
104 | 103 | ||
105 | it("LuaRocks build supported platforms lpty", function() | 104 | it("LuaRocks build supported platforms lpty", function() |
106 | assert.is_true(run.luarocks_bool("build lpty")) | 105 | assert.is_true(run.luarocks_bool(test_env.quiet("build lpty"))) |
107 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpty")) | 106 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpty")) |
108 | end) | 107 | end) |
109 | 108 | ||
110 | it("LuaRocks build luasec with skipping dependency checks", function() | 109 | it("LuaRocks build luasec with skipping dependency checks", function() |
111 | assert.is_true(run.luarocks_bool("build luasec --nodeps")) | 110 | assert.is_true(run.luarocks_bool(test_env.quiet("build luasec --nodeps"))) |
112 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec")) | 111 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec")) |
113 | end) | 112 | end) |
114 | 113 | ||
@@ -119,31 +118,34 @@ describe("LuaRocks build tests #blackbox #b_build", function() | |||
119 | end) | 118 | end) |
120 | 119 | ||
121 | describe("LuaRocks build - more complex tests", function() | 120 | describe("LuaRocks build - more complex tests", function() |
122 | 121 | if test_env.TYPE_TEST_ENV == "full" then | |
123 | it("LuaRocks build luacheck show downloads test_config", function() | 122 | it("LuaRocks build luacheck show downloads test_config", function() |
124 | local out = run.luarocks("build luacheck", { LUAROCKS_CONFIG = testing_paths.testing_dir .. "/testing_config_show_downloads.lua"} ) | 123 | local output = run.luarocks("build luacheck", { LUAROCKS_CONFIG = testing_paths.testing_dir .. "/testing_config_show_downloads.lua"} ) |
125 | print(out) | 124 | assert.is.truthy(output:match("%.%.%.")) |
126 | end) | 125 | end) |
127 | 126 | end | |
127 | |||
128 | it("LuaRocks build luasec only deps", function() | 128 | it("LuaRocks build luasec only deps", function() |
129 | assert.is_true(run.luarocks_bool("build luasec --only-deps")) | 129 | assert.is_true(run.luarocks_bool(test_env.quiet("build luasec --only-deps"))) |
130 | assert.is_false(run.luarocks_bool("show luasec")) | 130 | assert.is_false(run.luarocks_bool("show luasec")) |
131 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec")) | 131 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec")) |
132 | end) | 132 | end) |
133 | 133 | ||
134 | it("LuaRocks build only deps of downloaded rockspec of lxsh", function() | 134 | 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")) | 135 | assert.is_true(run.luarocks_bool("download --rockspec lxsh 0.8.6-2")) |
136 | assert.is_true(run.luarocks_bool("build lxsh-0.8.6-2.rockspec --only-deps")) | 136 | assert.is.truthy(run.luarocks("build lxsh-0.8.6-2.rockspec --only-deps")) |
137 | assert.is_false(run.luarocks_bool("show lxsh")) | 137 | assert.is_false(run.luarocks_bool("show lxsh")) |
138 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | 138 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) |
139 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
139 | assert.is_true(os.remove("lxsh-0.8.6-2.rockspec")) | 140 | assert.is_true(os.remove("lxsh-0.8.6-2.rockspec")) |
140 | end) | 141 | end) |
141 | 142 | ||
142 | it("LuaRocks build only deps of downloaded rock of lxsh", function() | 143 | it("LuaRocks build only deps of downloaded rock of lxsh", function() |
143 | assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6-2")) | 144 | assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6-2")) |
144 | assert.is_true(run.luarocks_bool("build lxsh-0.8.6-2.src.rock --only-deps")) | 145 | assert.is.truthy(run.luarocks("build lxsh-0.8.6-2.src.rock --only-deps")) |
145 | assert.is_false(run.luarocks_bool("show lxsh")) | 146 | assert.is_false(run.luarocks_bool("show lxsh")) |
146 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | 147 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) |
148 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
147 | assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) | 149 | assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) |
148 | end) | 150 | end) |
149 | 151 | ||
@@ -151,7 +153,7 @@ describe("LuaRocks build tests #blackbox #b_build", function() | |||
151 | assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) | 153 | assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) |
152 | assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec")) | 154 | assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec")) |
153 | 155 | ||
154 | assert.is_true(run.luarocks_bool("show validate-args")) | 156 | assert.is.truthy(run.luarocks("show validate-args")) |
155 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args")) | 157 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args")) |
156 | 158 | ||
157 | assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) | 159 | assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) |
@@ -159,10 +161,10 @@ describe("LuaRocks build tests #blackbox #b_build", function() | |||
159 | 161 | ||
160 | it("LuaRocks build with https", function() | 162 | it("LuaRocks build with https", function() |
161 | assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) | 163 | assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) |
162 | assert.is_true(run.luarocks_bool("install luasec")) | 164 | assert.is_true(run.luarocks_bool(test_env.quiet("install luasec"))) |
163 | assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec")) | 165 | assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec")) |
164 | 166 | ||
165 | assert.is_true(run.luarocks_bool("show validate-args")) | 167 | assert.is.truthy(run.luarocks("show validate-args")) |
166 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args")) | 168 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args")) |
167 | 169 | ||
168 | assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) | 170 | assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) |
diff --git a/spec/help_spec.lua b/spec/help_spec.lua index 0d41e2e9..88aa5030 100644 --- a/spec/help_spec.lua +++ b/spec/help_spec.lua | |||
@@ -10,7 +10,7 @@ describe("LuaRocks help tests #blackbox #b_help", function() | |||
10 | end) | 10 | end) |
11 | 11 | ||
12 | it("LuaRocks help with no flags/arguments", function() | 12 | it("LuaRocks help with no flags/arguments", function() |
13 | assert.is_true(run.luarocks_bool("help")) | 13 | assert.is_true(run.luarocks_bool(test_env.quiet("help"))) |
14 | end) | 14 | end) |
15 | 15 | ||
16 | it("LuaRocks help invalid argument", function() | 16 | it("LuaRocks help invalid argument", function() |
@@ -18,10 +18,10 @@ describe("LuaRocks help tests #blackbox #b_help", function() | |||
18 | end) | 18 | end) |
19 | 19 | ||
20 | it("LuaRocks help config", function() | 20 | it("LuaRocks help config", function() |
21 | assert.is_true(run.luarocks_bool("help config")) | 21 | assert.is_true(run.luarocks_bool(test_env.quiet("help config"))) |
22 | end) | 22 | end) |
23 | 23 | ||
24 | it("LuaRocks-admin help with no flags/arguments", function() | 24 | it("LuaRocks-admin help with no flags/arguments", function() |
25 | assert.is_true(run.luarocks_admin_bool("help")) | 25 | assert.is_true(run.luarocks_admin_bool(test_env.quiet("help"))) |
26 | end) | 26 | end) |
27 | end) | 27 | end) |
diff --git a/spec/install_spec.lua b/spec/install_spec.lua index 0b2ffb53..bd480c21 100644 --- a/spec/install_spec.lua +++ b/spec/install_spec.lua | |||
@@ -73,31 +73,31 @@ describe("LuaRocks install tests #blackbox #b_install", function() | |||
73 | 73 | ||
74 | describe("LuaRocks install - more complex tests", function() | 74 | describe("LuaRocks install - more complex tests", function() |
75 | it('LuaRocks install luasec with skipping dependency checks', function() | 75 | it('LuaRocks install luasec with skipping dependency checks', function() |
76 | run.luarocks(" install luasec --nodeps") | 76 | run.luarocks_bool(test_env.quiet(" install luasec --nodeps")) |
77 | assert.is_true(run.luarocks_bool("show luasec")) | 77 | assert.is_true(run.luarocks_bool(test_env.quiet("show luasec"))) |
78 | if env_variables.TYPE_TEST_ENV == "minimal" then | 78 | if env_variables.TYPE_TEST_ENV == "minimal" then |
79 | assert.is_false(run.luarocks_bool("show luasocket")) | 79 | assert.is_false(run.luarocks_bool(test_env.quiet("show luasocket"))) |
80 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) | 80 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) |
81 | end | 81 | end |
82 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec")) | 82 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec")) |
83 | end) | 83 | end) |
84 | 84 | ||
85 | it("LuaRocks install only-deps of luasocket packed rock", function() | 85 | it("LuaRocks install only-deps of luasocket packed rock", function() |
86 | assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket")) | 86 | assert.is_true(run.luarocks_bool(test_env.quiet("build --pack-binary-rock luasocket 3.0rc1-1"))) |
87 | local output = run.luarocks("install --only-deps " .. "luasocket-3.0rc1-1." .. test_env.platform .. ".rock") | 87 | local output = run.luarocks("install --only-deps " .. "luasocket-3.0rc1-1." .. test_env.platform .. ".rock") |
88 | assert.are.same(output, "Successfully installed dependencies for luasocket 3.0rc1-1") | 88 | assert.are.same(output, "Successfully installed dependencies for luasocket 3.0rc1-1") |
89 | assert.is_true(os.remove("luasocket-3.0rc1-1." .. test_env.platform .. ".rock")) | 89 | assert.is_true(os.remove("luasocket-3.0rc1-1." .. test_env.platform .. ".rock")) |
90 | end) | 90 | end) |
91 | 91 | ||
92 | it("LuaRocks install reinstall", function() | 92 | it("LuaRocks install reinstall", function() |
93 | assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket")) | 93 | assert.is_true(run.luarocks_bool(test_env.quiet("build --pack-binary-rock luasocket 3.0rc1-1"))) |
94 | assert.is_true(run.luarocks_bool("install " .. "luasocket-3.0rc1-1." .. test_env.platform .. ".rock")) | 94 | assert.is_true(run.luarocks_bool("install " .. "luasocket-3.0rc1-1." .. test_env.platform .. ".rock")) |
95 | assert.is_true(run.luarocks_bool("install --deps-mode=none " .. "luasocket-3.0rc1-1." .. test_env.platform .. ".rock")) | 95 | assert.is_true(run.luarocks_bool("install --deps-mode=none " .. "luasocket-3.0rc1-1." .. test_env.platform .. ".rock")) |
96 | assert.is_true(os.remove("luasocket-3.0rc1-1." .. test_env.platform .. ".rock")) | 96 | assert.is_true(os.remove("luasocket-3.0rc1-1." .. test_env.platform .. ".rock")) |
97 | end) | 97 | end) |
98 | 98 | ||
99 | it("LuaRocks install binary rock of cprint", function() | 99 | it("LuaRocks install binary rock of cprint", function() |
100 | assert.is_true(run.luarocks_bool("build --pack-binary-rock cprint")) | 100 | assert.is_true(run.luarocks_bool(test_env.quiet("build --pack-binary-rock cprint"))) |
101 | assert.is_true(run.luarocks_bool("install cprint-0.1-2." .. test_env.platform .. ".rock")) | 101 | assert.is_true(run.luarocks_bool("install cprint-0.1-2." .. test_env.platform .. ".rock")) |
102 | assert.is_true(os.remove("cprint-0.1-2." .. test_env.platform .. ".rock")) | 102 | assert.is_true(os.remove("cprint-0.1-2." .. test_env.platform .. ".rock")) |
103 | end) | 103 | end) |
diff --git a/spec/make_spec.lua b/spec/make_spec.lua index 2821c143..e684033a 100644 --- a/spec/make_spec.lua +++ b/spec/make_spec.lua | |||
@@ -27,13 +27,13 @@ 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")) | 30 | assert.is_true(run.luarocks_bool("download --source luasocket 3.0rc1-1")) |
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-1.src.rock")) |
32 | lfs.chdir("luasocket-3.0rc1-1/luasocket-3.0-rc1/") | 32 | lfs.chdir("luasocket-3.0rc1-1/luasocket-3.0-rc1/") |
33 | assert.is_true(run.luarocks_bool("make luasocket-3.0rc1-1.rockspec")) | 33 | assert.is_true(run.luarocks_bool(test_env.quiet("make luasocket-3.0rc1-1.rockspec"))) |
34 | 34 | ||
35 | -- test it | 35 | -- test it |
36 | assert.is_true(run.luarocks_bool("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")) |
38 | 38 | ||
39 | -- delete downloaded and unpacked files | 39 | -- delete downloaded and unpacked files |
@@ -61,7 +61,7 @@ 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("show lxsh")) | 64 | assert.is_true(run.luarocks_bool(test_env.quiet("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")) |
66 | end) | 66 | end) |
67 | 67 | ||
@@ -69,7 +69,7 @@ describe("LuaRocks make tests #blackbox #b_make", function() | |||
69 | os.execute("cp lxsh-0.8.6-2.rockspec rockspec") --rewrite with lfs | 69 | os.execute("cp lxsh-0.8.6-2.rockspec rockspec") --rewrite with lfs |
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("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")) |
74 | end) | 74 | end) |
75 | 75 | ||
@@ -91,7 +91,7 @@ describe("LuaRocks make tests #blackbox #b_make", function() | |||
91 | end) | 91 | end) |
92 | 92 | ||
93 | it("LuaRocks make pack binary rock", function() | 93 | it("LuaRocks make pack binary rock", function() |
94 | assert.is_true(run.luarocks_bool("make --deps-mode=none --pack-binary-rock")) | 94 | assert.is_true(run.luarocks_bool(test_env.quiet("make --deps-mode=none --pack-binary-rock"))) |
95 | assert.is.truthy(lfs.attributes("lxsh-0.8.6-2.all.rock")) | 95 | assert.is.truthy(lfs.attributes("lxsh-0.8.6-2.all.rock")) |
96 | end) | 96 | end) |
97 | end) | 97 | end) |
diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua index 67ed5f3f..0e5b31c6 100644 --- a/spec/pack_spec.lua +++ b/spec/pack_spec.lua | |||
@@ -24,8 +24,7 @@ describe("LuaRocks pack tests #blackbox #b_pack", function() | |||
24 | end) | 24 | end) |
25 | 25 | ||
26 | it("LuaRocks pack basic", function() | 26 | it("LuaRocks pack basic", function() |
27 | assert.is_true(run.luarocks_bool("list")) | 27 | assert.is_true(run.luarocks_bool(test_env.quiet("pack luacov"))) |
28 | assert.is_true(run.luarocks_bool("pack luacov")) | ||
29 | assert.is_true(test_env.remove_files(lfs.currentdir(), "luacov-")) | 28 | assert.is_true(test_env.remove_files(lfs.currentdir(), "luacov-")) |
30 | end) | 29 | end) |
31 | 30 | ||
@@ -49,10 +48,9 @@ describe("LuaRocks pack tests #blackbox #b_pack", function() | |||
49 | assert.is_false(run.luarocks_bool("pack say")) | 48 | assert.is_false(run.luarocks_bool("pack say")) |
50 | end) | 49 | end) |
51 | 50 | ||
52 | |||
53 | it("LuaRocks pack src", function() | 51 | it("LuaRocks pack src", function() |
54 | assert.is_true(run.luarocks_bool("install luasec")) | 52 | assert.is_true(run.luarocks_bool(test_env.quiet("install luasec"))) |
55 | assert.is_true(run.luarocks_bool("download --rockspec luasocket")) | 53 | assert.is_true(run.luarocks_bool("download --rockspec luasocket 3.0rc1-1")) |
56 | assert.is_true(run.luarocks_bool("pack luasocket-3.0rc1-1.rockspec")) | 54 | assert.is_true(run.luarocks_bool("pack luasocket-3.0rc1-1.rockspec")) |
57 | assert.is_true(test_env.remove_files(lfs.currentdir(), "luasocket-")) | 55 | assert.is_true(test_env.remove_files(lfs.currentdir(), "luasocket-")) |
58 | end) | 56 | end) |
diff --git a/spec/remove_spec.lua b/spec/remove_spec.lua index c7f83b95..7bf1bb10 100644 --- a/spec/remove_spec.lua +++ b/spec/remove_spec.lua | |||
@@ -45,7 +45,7 @@ describe("LuaRocks remove tests #blackbox #b_remove", function() | |||
45 | 45 | ||
46 | describe("LuaRocks remove more complex tests", function() | 46 | describe("LuaRocks remove more complex tests", function() |
47 | before_each(function() | 47 | before_each(function() |
48 | assert.is_true(test_env.need_rock("luasocket")) | 48 | assert.is.truthy(test_env.need_rock("luasocket")) |
49 | end) | 49 | end) |
50 | 50 | ||
51 | it("LuaRocks remove fail, break dependencies", function() | 51 | it("LuaRocks remove fail, break dependencies", function() |
diff --git a/spec/search_spec.lua b/spec/search_spec.lua index 33c49856..b31624b8 100644 --- a/spec/search_spec.lua +++ b/spec/search_spec.lua | |||
@@ -30,11 +30,7 @@ describe("LuaRocks search tests #blackbox #b_search", function() | |||
30 | end) | 30 | end) |
31 | 31 | ||
32 | it("LuaRocks search with flag all", function() | 32 | it("LuaRocks search with flag all", function() |
33 | assert.is_true(run.luarocks_bool("search --all")) | 33 | assert.is_true(run.luarocks_bool(test_env.quiet("search --all"))) |
34 | end) | 34 | end) |
35 | 35 | ||
36 | it("LuaRocks search zlib", function() | ||
37 | local num = 123 | ||
38 | assert.is_true(run.luarocks_bool("search " .. num)) | ||
39 | end) | ||
40 | end) | 36 | end) |
diff --git a/spec/upload_spec.lua b/spec/upload_spec.lua index c10ef0e9..c68a1cdf 100644 --- a/spec/upload_spec.lua +++ b/spec/upload_spec.lua | |||
@@ -1,10 +1,26 @@ | |||
1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
2 | local run = test_env.run | 2 | local run = test_env.run |
3 | local testing_paths = test_env.testing_paths | ||
3 | 4 | ||
4 | test_env.unload_luarocks() | 5 | test_env.unload_luarocks() |
5 | 6 | ||
6 | local extra_rocks = { | 7 | local extra_rocks = { |
7 | "/lua-cjson-2.1.0-1.src.rock" | 8 | "/lua-cjson-2.1.0-1.src.rock", |
9 | |||
10 | -- rocks needed for mock-server | ||
11 | "/copas-2.0.1-1.src.rock", | ||
12 | "/coxpcall-1.16.0-1.src.rock", | ||
13 | "/dkjson-2.5-2.src.rock", | ||
14 | "/luafilesystem-1.6.3-1.src.rock", | ||
15 | "/luasec-0.6-1.rockspec", | ||
16 | "/luasocket-3.0rc1-2.src.rock", | ||
17 | "/luasocket-3.0rc1-2.rockspec", | ||
18 | "/restserver-0.1-1.src.rock", | ||
19 | "/restserver-xavante-0.2-1.src.rock", | ||
20 | "/rings-1.3.0-1.src.rock", | ||
21 | "/wsapi-1.6.1-1.src.rock", | ||
22 | "/wsapi-xavante-1.6.1-1.src.rock", | ||
23 | "/xavante-2.4.0-1.src.rock" | ||
8 | } | 24 | } |
9 | 25 | ||
10 | describe("LuaRocks upload tests #blackbox #b_upload", function() | 26 | describe("LuaRocks upload tests #blackbox #b_upload", function() |
@@ -34,6 +50,25 @@ describe("LuaRocks upload tests #blackbox #b_upload", function() | |||
34 | 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")) |
35 | assert.is_true(run.luarocks_bool("install lua-cjson")) | 51 | assert.is_true(run.luarocks_bool("install lua-cjson")) |
36 | end) | 52 | end) |
53 | |||
54 | describe("LuaRocks upload tests with Xavante server #mock", function() | ||
55 | before_each(function() | ||
56 | assert.is.truthy(test_env.need_rock("restserver-xavante")) | ||
57 | local final_command = test_env.execute_helper(testing_paths.lua .. " " .. testing_paths.testing_dir .. "/mock-server.lua &", true, test_env.env_variables) | ||
58 | os.execute(final_command) | ||
59 | end) | ||
60 | |||
61 | after_each(function() | ||
62 | os.execute("curl localhost:8080/shutdown") | ||
63 | end) | ||
64 | |||
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"})) | ||
67 | end) | ||
68 | 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"})) | ||
70 | end) | ||
71 | end) | ||
37 | end) | 72 | end) |
38 | 73 | ||
39 | 74 | ||
diff --git a/spec/util_spec.lua b/spec/util_spec.lua index 9118ffc9..23e3ebd8 100644 --- a/spec/util_spec.lua +++ b/spec/util_spec.lua | |||
@@ -34,13 +34,16 @@ describe("Basic tests #blackbox #b_util", function() | |||
34 | local delete_path = lfs.currentdir() | 34 | local delete_path = lfs.currentdir() |
35 | assert.is_true(os.remove(delete_path)) | 35 | assert.is_true(os.remove(delete_path)) |
36 | 36 | ||
37 | assert.is_false(run.luarocks_bool(" ")) | 37 | local output = run.luarocks("") |
38 | assert.is.falsy(output:find("LuaRocks scm, a module deployment system for Lua")) | ||
38 | assert.is_true(lfs.chdir(main_path)) | 39 | assert.is_true(lfs.chdir(main_path)) |
39 | assert.is_true(run.luarocks_bool(" ")) | 40 | |
41 | output = run.luarocks("") | ||
42 | assert.is.truthy(output:find("LuaRocks scm, a module deployment system for Lua")) | ||
40 | end) | 43 | end) |
41 | 44 | ||
42 | it("LuaRocks timeout", function() | 45 | it("LuaRocks timeout", function() |
43 | assert.is_true(run.luarocks_bool("--timeout=10")) | 46 | assert.is.truthy(run.luarocks("--timeout=10")) |
44 | end) | 47 | end) |
45 | 48 | ||
46 | it("LuaRocks timeout invalid", function() | 49 | it("LuaRocks timeout invalid", function() |
@@ -48,7 +51,7 @@ describe("Basic tests #blackbox #b_util", function() | |||
48 | end) | 51 | end) |
49 | 52 | ||
50 | it("LuaRocks only server=testing", function() | 53 | it("LuaRocks only server=testing", function() |
51 | assert.is_true(run.luarocks_bool("--only-server=testing")) | 54 | assert.is.truthy(run.luarocks("--only-server=testing")) |
52 | end) | 55 | end) |
53 | 56 | ||
54 | it("LuaRocks test site config", function() | 57 | it("LuaRocks test site config", function() |
@@ -56,7 +59,7 @@ describe("Basic tests #blackbox #b_util", function() | |||
56 | assert.is.falsy(lfs.attributes("src/luarocks/site_config.lua")) | 59 | assert.is.falsy(lfs.attributes("src/luarocks/site_config.lua")) |
57 | assert.is.truthy(lfs.attributes("src/luarocks/site_config.lua.tmp")) | 60 | assert.is.truthy(lfs.attributes("src/luarocks/site_config.lua.tmp")) |
58 | 61 | ||
59 | assert.is_true(run.luarocks_bool("")) | 62 | assert.is.truthy(run.luarocks("")) |
60 | 63 | ||
61 | assert.is.truthy(os.rename("src/luarocks/site_config.lua.tmp", "src/luarocks/site_config.lua")) | 64 | assert.is.truthy(os.rename("src/luarocks/site_config.lua.tmp", "src/luarocks/site_config.lua")) |
62 | assert.is.falsy(lfs.attributes("src/luarocks/site_config.lua.tmp")) | 65 | assert.is.falsy(lfs.attributes("src/luarocks/site_config.lua.tmp")) |
diff --git a/spec/write_rockspec_spec.lua b/spec/write_rockspec_spec.lua index 85e345d5..531d11eb 100644 --- a/spec/write_rockspec_spec.lua +++ b/spec/write_rockspec_spec.lua | |||
@@ -64,8 +64,7 @@ describe("LuaRocks write_rockspec tests #blackbox #b_write_rockspec", function() | |||
64 | end) | 64 | end) |
65 | 65 | ||
66 | it("LuaRocks write_rockspec git luafcgi with many flags", function() | 66 | it("LuaRocks write_rockspec git luafcgi with many flags", function() |
67 | assert.is_true(run.luarocks_bool("write_rockspec git://github.com/mbalmer/luafcgi --lib=fcgi --license=\"3-clause BSD\" " | 67 | assert.is_true(run.luarocks_bool("write_rockspec git://github.com/mbalmer/luafcgi --lib=fcgi --license=\"3-clause BSD\" " .. "--lua-version=5.1,5.2")) |
68 | .. "--lua-version=5.1,5.2")) | ||
69 | assert.is.truthy(lfs.attributes("luafcgi-scm-1.rockspec")) -- TODO maybe read it content and find arguments from flags? | 68 | assert.is.truthy(lfs.attributes("luafcgi-scm-1.rockspec")) -- TODO maybe read it content and find arguments from flags? |
70 | assert.is_true(os.remove("luafcgi-scm-1.rockspec")) | 69 | assert.is_true(os.remove("luafcgi-scm-1.rockspec")) |
71 | end) | 70 | end) |
diff --git a/test/luarocks_site.lua b/test/luarocks_site.lua new file mode 100644 index 00000000..cfa77dca --- /dev/null +++ b/test/luarocks_site.lua | |||
@@ -0,0 +1,6 @@ | |||
1 | -- Config file of LuaRocks site for tests | ||
2 | upload = { | ||
3 | server = "http://localhost:8080", | ||
4 | tool_version = "1.0.0", | ||
5 | api_version = "1", | ||
6 | } \ No newline at end of file | ||
diff --git a/test/mock-server.lua b/test/mock-server.lua new file mode 100644 index 00000000..797e2bc5 --- /dev/null +++ b/test/mock-server.lua | |||
@@ -0,0 +1,80 @@ | |||
1 | #!/usr/bin/env lua | ||
2 | |||
3 | --- A simple LuaRocks mock-server for testing. | ||
4 | local restserver = require("restserver") | ||
5 | local server = restserver:new():port(8080) | ||
6 | |||
7 | server:add_resource("api/tool_version", { | ||
8 | { | ||
9 | method = "GET", | ||
10 | path = "/", | ||
11 | produces = "application/json", | ||
12 | handler = function(query) | ||
13 | local json = { version = query.current } | ||
14 | return restserver.response():status(200):entity(json) | ||
15 | end | ||
16 | } | ||
17 | }) | ||
18 | |||
19 | server:add_resource("api/1/{id:[0-9]+}/status", { | ||
20 | { | ||
21 | method = "GET", | ||
22 | path = "/", | ||
23 | produces = "application/json", | ||
24 | handler = function(query) | ||
25 | local json = { user_id = "123", created_at = "29.1.1993" } | ||
26 | return restserver.response():status(200):entity(json) | ||
27 | end | ||
28 | } | ||
29 | }) | ||
30 | |||
31 | server:add_resource("/api/1/{id:[0-9]+}/check_rockspec", { | ||
32 | { | ||
33 | method = "GET", | ||
34 | path = "/", | ||
35 | produces = "application/json", | ||
36 | handler = function(query) | ||
37 | local json = {} | ||
38 | return restserver.response():status(200):entity(json) | ||
39 | end | ||
40 | } | ||
41 | }) | ||
42 | |||
43 | server:add_resource("/api/1/{id:[0-9]+}/upload", { | ||
44 | { | ||
45 | method = "POST", | ||
46 | path = "/", | ||
47 | produces = "application/json", | ||
48 | handler = function(query) | ||
49 | local json = {module = "luasocket", version = {id = "1.0"}, module_url = "http://localhost/luasocket", manifests = "root", is_new = "is_new"} | ||
50 | return restserver.response():status(200):entity(json) | ||
51 | end | ||
52 | } | ||
53 | }) | ||
54 | |||
55 | server:add_resource("/api/1/{id:[0-9]+}/upload_rock/{id:[0-9]+}", { | ||
56 | { | ||
57 | method = "POST", | ||
58 | path = "/", | ||
59 | produces = "application/json", | ||
60 | handler = function(query) | ||
61 | local json = {"rock","module_url"} | ||
62 | return restserver.response():status(200):entity(json) | ||
63 | end | ||
64 | } | ||
65 | }) | ||
66 | |||
67 | -- SHUTDOWN this mock-server | ||
68 | server:add_resource("/shutdown", { | ||
69 | { | ||
70 | method = "GET", | ||
71 | path = "/", | ||
72 | handler = function(query) | ||
73 | os.exit() | ||
74 | return restserver.response():status(200):entity() | ||
75 | end | ||
76 | } | ||
77 | }) | ||
78 | |||
79 | -- This loads the restserver.xavante plugin | ||
80 | server:enable("restserver.xavante"):start() \ No newline at end of file | ||
diff --git a/test/test_environment.lua b/test/test_environment.lua index eb545a47..5d1e8198 100644 --- a/test/test_environment.lua +++ b/test/test_environment.lua | |||
@@ -36,12 +36,24 @@ local function exists(path) | |||
36 | return lfs.attributes(path, "mode") ~= nil | 36 | return lfs.attributes(path, "mode") ~= nil |
37 | end | 37 | end |
38 | 38 | ||
39 | function test_env.quiet(commad) | ||
40 | if not test_env.VERBOSE then | ||
41 | if test_env.TEST_TARGET_OS == "linux" or test_env.TEST_TARGET_OS == "osx" then | ||
42 | return commad .. " 1> /dev/null 2> /dev/null" | ||
43 | elseif test_env.TEST_TARGET_OS == "windows" then | ||
44 | return commad .. " 2> NUL 1> NUL" | ||
45 | end | ||
46 | else | ||
47 | return command | ||
48 | end | ||
49 | end | ||
50 | |||
39 | --- Helper function for execute_bool and execute_output | 51 | --- Helper function for execute_bool and execute_output |
40 | -- @param command string: command to execute | 52 | -- @param command string: command to execute |
41 | -- @param print_command boolean: print command if 'true' | 53 | -- @param print_command boolean: print command if 'true' |
42 | -- @param env_variables table: table of environment variables to export {FOO="bar", BAR="foo"} | 54 | -- @param env_variables table: table of environment variables to export {FOO="bar", BAR="foo"} |
43 | -- @return final_command string: concatenated command to execution | 55 | -- @return final_command string: concatenated command to execution |
44 | local function execute_helper(command, print_command, env_variables) | 56 | function test_env.execute_helper(command, print_command, env_variables) |
45 | local final_command = "" | 57 | local final_command = "" |
46 | 58 | ||
47 | if print_command then | 59 | if print_command then |
@@ -66,7 +78,7 @@ end | |||
66 | -- In Lua5.1 os.execute returns numeric value, but in Lua5.2+ returns boolean | 78 | -- In Lua5.1 os.execute returns numeric value, but in Lua5.2+ returns boolean |
67 | -- @return true/false boolean: status of the command execution | 79 | -- @return true/false boolean: status of the command execution |
68 | local function execute_bool(command, print_command, env_variables) | 80 | local function execute_bool(command, print_command, env_variables) |
69 | command = execute_helper(command, print_command, env_variables) | 81 | command = test_env.execute_helper(command, print_command, env_variables) |
70 | 82 | ||
71 | local ok = os.execute(command) | 83 | local ok = os.execute(command) |
72 | return ok == true or ok == 0 | 84 | return ok == true or ok == 0 |
@@ -75,7 +87,7 @@ end | |||
75 | --- Execute command and returns output of command | 87 | --- Execute command and returns output of command |
76 | -- @return output string: output the command execution | 88 | -- @return output string: output the command execution |
77 | local function execute_output(command, print_command, env_variables) | 89 | local function execute_output(command, print_command, env_variables) |
78 | command = execute_helper(command, print_command, env_variables) | 90 | command = test_env.execute_helper(command, print_command, env_variables) |
79 | 91 | ||
80 | local file = assert(io.popen(command)) | 92 | local file = assert(io.popen(command)) |
81 | local output = file:read('*all') | 93 | local output = file:read('*all') |
@@ -106,6 +118,8 @@ function test_env.set_args() | |||
106 | test_env.RESET_ENV = false | 118 | test_env.RESET_ENV = false |
107 | elseif argument == "clean" then | 119 | elseif argument == "clean" then |
108 | test_env.TEST_ENV_CLEAN = true | 120 | test_env.TEST_ENV_CLEAN = true |
121 | elseif argument == "verbose" then | ||
122 | test_env.VERBOSE = true | ||
109 | elseif argument == "travis" then | 123 | elseif argument == "travis" then |
110 | test_env.TRAVIS = true | 124 | test_env.TRAVIS = true |
111 | elseif argument:find("^os=") then | 125 | elseif argument:find("^os=") then |
@@ -415,10 +429,11 @@ end | |||
415 | 429 | ||
416 | --- Test if required rock is installed if not, install it | 430 | --- Test if required rock is installed if not, install it |
417 | function test_env.need_rock(rock) | 431 | function test_env.need_rock(rock) |
418 | if test_env.run.luarocks_nocov("show " .. rock) then | 432 | print("Check if " .. rock .. " is installed") |
433 | if test_env.run.luarocks_noprint_nocov(test_env.quiet("show " .. rock)) then | ||
419 | return true | 434 | return true |
420 | else | 435 | else |
421 | return test_env.run.luarocks_nocov("install " .. rock) | 436 | return test_env.run.luarocks_noprint_nocov(test_env.quiet("install " .. rock)) |
422 | end | 437 | end |
423 | end | 438 | end |
424 | 439 | ||
@@ -525,18 +540,20 @@ local function clean() | |||
525 | test_env.remove_subdirs(test_env.testing_paths.testing_dir, "testing[_%-]") | 540 | test_env.remove_subdirs(test_env.testing_paths.testing_dir, "testing[_%-]") |
526 | test_env.remove_files(test_env.testing_paths.testing_dir, "testing_") | 541 | test_env.remove_files(test_env.testing_paths.testing_dir, "testing_") |
527 | test_env.remove_files(test_env.testing_paths.testing_dir, "luacov") | 542 | test_env.remove_files(test_env.testing_paths.testing_dir, "luacov") |
543 | test_env.remove_files(test_env.testing_paths.testing_dir, "upload_config") | ||
528 | print("Cleaning done!") | 544 | print("Cleaning done!") |
529 | end | 545 | end |
530 | 546 | ||
531 | --- Install luarocks into testing prefix. | 547 | --- Install luarocks into testing prefix. |
532 | local function install_luarocks(install_env_vars) | 548 | local function install_luarocks(install_env_vars) |
533 | -- Configure LuaRocks testing environment | 549 | -- Configure LuaRocks testing environment |
534 | local configure_cmd = "./configure --with-lua=" .. test_env.testing_paths.luadir .. | 550 | title("Installing LuaRocks") |
535 | " --prefix=" .. test_env.testing_paths.testing_lrprefix .. | 551 | local configure_cmd = "./configure --with-lua=" .. test_env.testing_paths.luadir .. " --prefix=" .. test_env.testing_paths.testing_lrprefix |
536 | " && make clean" | 552 | assert(execute_bool(test_env.quiet(configure_cmd)), false, install_env_vars) |
537 | 553 | assert(execute_bool(test_env.quiet("make clean")), false, install_env_vars) | |
538 | assert(execute_bool(configure_cmd, false, install_env_vars)) | 554 | assert(execute_bool(test_env.quiet("make src/luarocks/site_config.lua")), false, install_env_vars) |
539 | assert(execute_bool("make src/luarocks/site_config.lua && make dev", false, install_env_vars)) | 555 | assert(execute_bool(test_env.quiet("make dev")), false, install_env_vars) |
556 | print("LuaRocks installed correctly!") | ||
540 | end | 557 | end |
541 | 558 | ||
542 | --- | 559 | --- |