diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2019-11-13 14:28:53 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2019-11-29 18:36:42 -0300 |
commit | b4dfc787519e9d6df798812858e70778b7c5cf30 (patch) | |
tree | 654f34151d88a7b3c27d9006bf665350184ed4e2 /spec | |
parent | 51a2c592405c6c9fc006014973229ce1ac011d21 (diff) | |
download | luarocks-b4dfc787519e9d6df798812858e70778b7c5cf30.tar.gz luarocks-b4dfc787519e9d6df798812858e70778b7c5cf30.tar.bz2 luarocks-b4dfc787519e9d6df798812858e70778b7c5cf30.zip |
tests: simplify descriptions and set lazy setup/teardown
Diffstat (limited to 'spec')
-rw-r--r-- | spec/build_spec.lua | 64 | ||||
-rw-r--r-- | spec/test_spec.lua | 6 |
2 files changed, 35 insertions, 35 deletions
diff --git a/spec/build_spec.lua b/spec/build_spec.lua index f0377b5f..eeca75cf 100644 --- a/spec/build_spec.lua +++ b/spec/build_spec.lua | |||
@@ -39,8 +39,8 @@ local c_module_source = [[ | |||
39 | } | 39 | } |
40 | ]] | 40 | ]] |
41 | 41 | ||
42 | describe("LuaRocks build tests #integration", function() | 42 | describe("LuaRocks build #integration", function() |
43 | setup(function() | 43 | lazy_setup(function() |
44 | cfg.init() | 44 | cfg.init() |
45 | fs.init() | 45 | fs.init() |
46 | end) | 46 | end) |
@@ -49,12 +49,12 @@ describe("LuaRocks build tests #integration", function() | |||
49 | test_env.setup_specs(extra_rocks) | 49 | test_env.setup_specs(extra_rocks) |
50 | end) | 50 | end) |
51 | 51 | ||
52 | describe("LuaRocks build - basic testing set", function() | 52 | describe("basic testing set", function() |
53 | it("LuaRocks build invalid", function() | 53 | it("invalid", function() |
54 | assert.is_false(run.luarocks_bool("build invalid")) | 54 | assert.is_false(run.luarocks_bool("build invalid")) |
55 | end) | 55 | end) |
56 | 56 | ||
57 | it("LuaRocks build with no arguments behaves as luarocks make", function() | 57 | it("with no arguments behaves as luarocks make", function() |
58 | test_env.run_in_tmp(function(tmpdir) | 58 | test_env.run_in_tmp(function(tmpdir) |
59 | write_file("c_module-1.0-1.rockspec", [[ | 59 | write_file("c_module-1.0-1.rockspec", [[ |
60 | package = "c_module" | 60 | package = "c_module" |
@@ -77,18 +77,18 @@ describe("LuaRocks build tests #integration", function() | |||
77 | end) | 77 | end) |
78 | end) | 78 | end) |
79 | 79 | ||
80 | describe("LuaRocks build - building with flags", function() | 80 | describe("building with flags", function() |
81 | it("LuaRocks build fails if it doesn't have the permissions to access the specified tree #unix", function() | 81 | it("fails if it doesn't have the permissions to access the specified tree #unix", function() |
82 | assert.is_false(run.luarocks_bool("build --tree=/usr " .. testing_paths.fixtures_dir .. "/a_rock-1.0.1-rockspec")) | 82 | assert.is_false(run.luarocks_bool("build --tree=/usr " .. testing_paths.fixtures_dir .. "/a_rock-1.0.1-rockspec")) |
83 | assert.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) | 83 | assert.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) |
84 | end) | 84 | end) |
85 | 85 | ||
86 | it("LuaRocks build fails if it doesn't have the permissions to access the specified tree's parent #unix", function() | 86 | it("fails if it doesn't have the permissions to access the specified tree's parent #unix", function() |
87 | assert.is_false(run.luarocks_bool("build --tree=/usr/invalid " .. testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec")) | 87 | assert.is_false(run.luarocks_bool("build --tree=/usr/invalid " .. testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec")) |
88 | assert.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) | 88 | assert.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) |
89 | end) | 89 | end) |
90 | 90 | ||
91 | it("LuaRocks build verbose", function() | 91 | it("verbose", function() |
92 | test_env.run_in_tmp(function(tmpdir) | 92 | test_env.run_in_tmp(function(tmpdir) |
93 | write_file("test-1.0-1.rockspec", [[ | 93 | write_file("test-1.0-1.rockspec", [[ |
94 | package = "test" | 94 | package = "test" |
@@ -110,12 +110,12 @@ describe("LuaRocks build tests #integration", function() | |||
110 | end, finally) | 110 | end, finally) |
111 | end) | 111 | end) |
112 | 112 | ||
113 | it("LuaRocks build fails if the deps-mode argument is invalid", function() | 113 | it("fails if the deps-mode argument is invalid", function() |
114 | assert.is_false(run.luarocks_bool("build --deps-mode=123 " .. testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec")) | 114 | assert.is_false(run.luarocks_bool("build --deps-mode=123 " .. testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec")) |
115 | assert.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) | 115 | assert.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) |
116 | end) | 116 | end) |
117 | 117 | ||
118 | it("LuaRocks build with --only-sources", function() | 118 | it("with --only-sources", function() |
119 | assert.is_true(run.luarocks_bool("download --server=" .. testing_paths.fixtures_dir .. "/a_repo --rockspec a_rock")) | 119 | assert.is_true(run.luarocks_bool("download --server=" .. testing_paths.fixtures_dir .. "/a_repo --rockspec a_rock")) |
120 | assert.is_false(run.luarocks_bool("build --only-sources=\"http://example.com\" a_rock-1.0-1.rockspec")) | 120 | assert.is_false(run.luarocks_bool("build --only-sources=\"http://example.com\" a_rock-1.0-1.rockspec")) |
121 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) | 121 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) |
@@ -128,24 +128,24 @@ describe("LuaRocks build tests #integration", function() | |||
128 | assert.is_true(os.remove("a_rock-1.0-1.src.rock")) | 128 | assert.is_true(os.remove("a_rock-1.0-1.src.rock")) |
129 | end) | 129 | end) |
130 | 130 | ||
131 | it("LuaRocks build fails if an empty tree is given", function() | 131 | it("fails if an empty tree is given", function() |
132 | assert.is_false(run.luarocks_bool("build --tree=\"\" " .. testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec")) | 132 | assert.is_false(run.luarocks_bool("build --tree=\"\" " .. testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec")) |
133 | assert.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) | 133 | assert.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) |
134 | end) | 134 | end) |
135 | end) | 135 | end) |
136 | 136 | ||
137 | describe("LuaRocks build - basic builds", function() | 137 | describe("basic builds", function() |
138 | it("LuaRocks build luacov diff version", function() | 138 | it("luacov diff version", function() |
139 | assert.is_true(run.luarocks_bool("build luacov 0.13.0-1")) | 139 | assert.is_true(run.luarocks_bool("build luacov 0.13.0-1")) |
140 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luacov/0.13.0-1/luacov-0.13.0-1.rockspec")) | 140 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luacov/0.13.0-1/luacov-0.13.0-1.rockspec")) |
141 | end) | 141 | end) |
142 | 142 | ||
143 | it("LuaRocks build command stdlib", function() | 143 | it("command stdlib", function() |
144 | assert.is_true(run.luarocks_bool("build stdlib")) | 144 | assert.is_true(run.luarocks_bool("build stdlib")) |
145 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/stdlib/41.0.0-1/stdlib-41.0.0-1.rockspec")) | 145 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/stdlib/41.0.0-1/stdlib-41.0.0-1.rockspec")) |
146 | end) | 146 | end) |
147 | 147 | ||
148 | it("LuaRocks build fails if the current platform is not supported", function() | 148 | it("fails if the current platform is not supported", function() |
149 | test_env.run_in_tmp(function(tmpdir) | 149 | test_env.run_in_tmp(function(tmpdir) |
150 | write_file("test-1.0-1.rockspec", [[ | 150 | write_file("test-1.0-1.rockspec", [[ |
151 | package = "test" | 151 | package = "test" |
@@ -175,7 +175,7 @@ describe("LuaRocks build tests #integration", function() | |||
175 | end, finally) | 175 | end, finally) |
176 | end) | 176 | end) |
177 | 177 | ||
178 | it("LuaRocks build with skipping dependency checks", function() | 178 | it("with skipping dependency checks", function() |
179 | test_env.run_in_tmp(function(tmpdir) | 179 | test_env.run_in_tmp(function(tmpdir) |
180 | write_file("test-1.0-1.rockspec", [[ | 180 | write_file("test-1.0-1.rockspec", [[ |
181 | package = "test" | 181 | package = "test" |
@@ -200,7 +200,7 @@ describe("LuaRocks build tests #integration", function() | |||
200 | end) | 200 | end) |
201 | end) | 201 | end) |
202 | 202 | ||
203 | it("LuaRocks build lmathx deps partial match", function() | 203 | it("lmathx deps partial match", function() |
204 | assert.is_true(run.luarocks_bool("build lmathx")) | 204 | assert.is_true(run.luarocks_bool("build lmathx")) |
205 | 205 | ||
206 | if test_env.LUA_V == "5.1" or test_env.LUAJIT_V then | 206 | if test_env.LUA_V == "5.1" or test_env.LUAJIT_V then |
@@ -247,21 +247,21 @@ describe("LuaRocks build tests #integration", function() | |||
247 | end) | 247 | end) |
248 | end) | 248 | end) |
249 | 249 | ||
250 | describe("LuaRocks build - more complex tests", function() | 250 | describe("more complex tests", function() |
251 | if test_env.TYPE_TEST_ENV == "full" then | 251 | if test_env.TYPE_TEST_ENV == "full" then |
252 | it("LuaRocks build luacheck show downloads test_config", function() | 252 | it("luacheck show downloads test_config", function() |
253 | local output = run.luarocks("build luacheck", { LUAROCKS_CONFIG = testing_paths.testrun_dir .. "/testing_config_show_downloads.lua"} ) | 253 | local output = run.luarocks("build luacheck", { LUAROCKS_CONFIG = testing_paths.testrun_dir .. "/testing_config_show_downloads.lua"} ) |
254 | assert.is.truthy(output:match("%.%.%.")) | 254 | assert.is.truthy(output:match("%.%.%.")) |
255 | end) | 255 | end) |
256 | end | 256 | end |
257 | 257 | ||
258 | it("LuaRocks build luasec only deps", function() | 258 | it("luasec only deps", function() |
259 | assert.is_true(run.luarocks_bool("build luasec " .. test_env.openssl_dirs .. " --only-deps")) | 259 | assert.is_true(run.luarocks_bool("build luasec " .. test_env.openssl_dirs .. " --only-deps")) |
260 | assert.is_false(run.luarocks_bool("show luasec")) | 260 | assert.is_false(run.luarocks_bool("show luasec")) |
261 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasec/0.6-1/luasec-0.6-1.rockspec")) | 261 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasec/0.6-1/luasec-0.6-1.rockspec")) |
262 | end) | 262 | end) |
263 | 263 | ||
264 | it("LuaRocks build only deps of a given rockspec", function() | 264 | it("only deps of a given rockspec", function() |
265 | test_env.run_in_tmp(function(tmpdir) | 265 | test_env.run_in_tmp(function(tmpdir) |
266 | write_file("test-1.0-1.rockspec", [[ | 266 | write_file("test-1.0-1.rockspec", [[ |
267 | package = "test" | 267 | package = "test" |
@@ -287,7 +287,7 @@ describe("LuaRocks build tests #integration", function() | |||
287 | end, finally) | 287 | end, finally) |
288 | end) | 288 | end) |
289 | 289 | ||
290 | it("LuaRocks build only deps of a given rock", function() | 290 | it("only deps of a given rock", function() |
291 | test_env.run_in_tmp(function(tmpdir) | 291 | test_env.run_in_tmp(function(tmpdir) |
292 | write_file("test-1.0-1.rockspec", [[ | 292 | write_file("test-1.0-1.rockspec", [[ |
293 | package = "test" | 293 | package = "test" |
@@ -316,7 +316,7 @@ describe("LuaRocks build tests #integration", function() | |||
316 | end, finally) | 316 | end, finally) |
317 | end) | 317 | end) |
318 | 318 | ||
319 | it("LuaRocks build with https", function() | 319 | it("with https", function() |
320 | assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) | 320 | assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) |
321 | assert.is_true(run.luarocks_bool("install luasec " .. test_env.openssl_dirs)) | 321 | assert.is_true(run.luarocks_bool("install luasec " .. test_env.openssl_dirs)) |
322 | 322 | ||
@@ -326,7 +326,7 @@ describe("LuaRocks build tests #integration", function() | |||
326 | assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) | 326 | assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) |
327 | end) | 327 | end) |
328 | 328 | ||
329 | it("LuaRocks build fails if given an argument with an invalid patch", function() | 329 | it("fails if given an argument with an invalid patch", function() |
330 | assert.is_false(run.luarocks_bool("build " .. testing_paths.fixtures_dir .. "/invalid_patch-0.1-1.rockspec")) | 330 | assert.is_false(run.luarocks_bool("build " .. testing_paths.fixtures_dir .. "/invalid_patch-0.1-1.rockspec")) |
331 | end) | 331 | end) |
332 | end) | 332 | end) |
@@ -430,11 +430,11 @@ describe("LuaRocks build tests #integration", function() | |||
430 | end) | 430 | end) |
431 | 431 | ||
432 | describe("#mock external dependencies", function() | 432 | describe("#mock external dependencies", function() |
433 | setup(function() | 433 | lazy_setup(function() |
434 | test_env.mock_server_init() | 434 | test_env.mock_server_init() |
435 | end) | 435 | end) |
436 | 436 | ||
437 | teardown(function() | 437 | lazy_teardown(function() |
438 | test_env.mock_server_done() | 438 | test_env.mock_server_done() |
439 | end) | 439 | end) |
440 | 440 | ||
@@ -493,10 +493,10 @@ local path = require("luarocks.path") | |||
493 | local rockspecs = require("luarocks.rockspecs") | 493 | local rockspecs = require("luarocks.rockspecs") |
494 | local build_builtin = require("luarocks.build.builtin") | 494 | local build_builtin = require("luarocks.build.builtin") |
495 | 495 | ||
496 | describe("LuaRocks build tests #unit", function() | 496 | describe("LuaRocks build #unit", function() |
497 | local runner | 497 | local runner |
498 | 498 | ||
499 | setup(function() | 499 | lazy_setup(function() |
500 | runner = require("luacov.runner") | 500 | runner = require("luacov.runner") |
501 | runner.init(testing_paths.testrun_dir .. "/luacov.config") | 501 | runner.init(testing_paths.testrun_dir .. "/luacov.config") |
502 | runner.tick = true | 502 | runner.tick = true |
@@ -506,7 +506,7 @@ describe("LuaRocks build tests #unit", function() | |||
506 | deps.check_lua_libdir(cfg.variables) | 506 | deps.check_lua_libdir(cfg.variables) |
507 | end) | 507 | end) |
508 | 508 | ||
509 | teardown(function() | 509 | lazy_teardown(function() |
510 | runner.shutdown() | 510 | runner.shutdown() |
511 | end) | 511 | end) |
512 | 512 | ||
@@ -927,11 +927,11 @@ describe("LuaRocks build tests #unit", function() | |||
927 | describe("#unix build from #git", function() | 927 | describe("#unix build from #git", function() |
928 | local git | 928 | local git |
929 | 929 | ||
930 | setup(function() | 930 | lazy_setup(function() |
931 | git = git_repo.start() | 931 | git = git_repo.start() |
932 | end) | 932 | end) |
933 | 933 | ||
934 | teardown(function() | 934 | lazy_teardown(function() |
935 | if git then | 935 | if git then |
936 | git:stop() | 936 | git:stop() |
937 | end | 937 | end |
diff --git a/spec/test_spec.lua b/spec/test_spec.lua index 7a2399a9..ca1d5917 100644 --- a/spec/test_spec.lua +++ b/spec/test_spec.lua | |||
@@ -38,7 +38,7 @@ describe("luarocks test #integration", function() | |||
38 | 38 | ||
39 | describe("busted backend", function() | 39 | describe("busted backend", function() |
40 | 40 | ||
41 | 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 | os.execute("luarocks pack busted") | 43 | os.execute("luarocks pack busted") |
44 | os.execute("luarocks pack lua_cliargs") | 44 | os.execute("luarocks pack lua_cliargs") |
@@ -91,7 +91,7 @@ local test_command = require("luarocks.test.command") | |||
91 | describe("LuaRocks test #unit", function() | 91 | describe("LuaRocks test #unit", function() |
92 | local runner | 92 | local runner |
93 | 93 | ||
94 | setup(function() | 94 | lazy_setup(function() |
95 | cfg.init() | 95 | cfg.init() |
96 | fs.init() | 96 | fs.init() |
97 | runner = require("luacov.runner") | 97 | runner = require("luacov.runner") |
@@ -99,7 +99,7 @@ describe("LuaRocks test #unit", function() | |||
99 | runner.tick = true | 99 | runner.tick = true |
100 | end) | 100 | end) |
101 | 101 | ||
102 | teardown(function() | 102 | lazy_teardown(function() |
103 | runner.shutdown() | 103 | runner.shutdown() |
104 | end) | 104 | end) |
105 | 105 | ||