diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2021-03-16 13:36:26 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2021-03-16 16:32:45 -0300 |
commit | 8f3ce333e7a1abfc6bf0488817d9eff4a2fd443f (patch) | |
tree | f05d1a49995341a56e602ce2a3256b89372e9d04 /spec | |
parent | 2b56388e76952be52d849415b1ebae74b6dc4607 (diff) | |
download | luarocks-8f3ce333e7a1abfc6bf0488817d9eff4a2fd443f.tar.gz luarocks-8f3ce333e7a1abfc6bf0488817d9eff4a2fd443f.tar.bz2 luarocks-8f3ce333e7a1abfc6bf0488817d9eff4a2fd443f.zip |
editorconfig: trim trailing whitespace
Diffstat (limited to 'spec')
34 files changed, 359 insertions, 360 deletions
diff --git a/spec/add_spec.lua b/spec/add_spec.lua index b0b3a171..ea6274ba 100644 --- a/spec/add_spec.lua +++ b/spec/add_spec.lua | |||
@@ -23,20 +23,20 @@ describe("LuaRocks add tests #integration", function() | |||
23 | it("missing argument", function() | 23 | it("missing argument", function() |
24 | assert.is_false(run.luarocks_admin_bool("--server=testing add")) | 24 | assert.is_false(run.luarocks_admin_bool("--server=testing add")) |
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-3.0rc1-2.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-3.0rc1-2.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-3.0rc1-2.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-3.0rc1-2.src.rock")) |
42 | end) | 42 | end) |
diff --git a/spec/build_spec.lua b/spec/build_spec.lua index 7d18ae4c..7dc4af03 100644 --- a/spec/build_spec.lua +++ b/spec/build_spec.lua | |||
@@ -55,7 +55,7 @@ describe("LuaRocks build #integration", function() | |||
55 | it("invalid", function() | 55 | it("invalid", function() |
56 | assert.is_false(run.luarocks_bool("build invalid")) | 56 | assert.is_false(run.luarocks_bool("build invalid")) |
57 | end) | 57 | end) |
58 | 58 | ||
59 | it("with no arguments behaves as luarocks make", function() | 59 | it("with no arguments behaves as luarocks make", function() |
60 | test_env.run_in_tmp(function(tmpdir) | 60 | test_env.run_in_tmp(function(tmpdir) |
61 | write_file("c_module-1.0-1.rockspec", [[ | 61 | write_file("c_module-1.0-1.rockspec", [[ |
@@ -72,7 +72,7 @@ describe("LuaRocks build #integration", function() | |||
72 | } | 72 | } |
73 | ]], finally) | 73 | ]], finally) |
74 | write_file("c_module.c", c_module_source, finally) | 74 | write_file("c_module.c", c_module_source, finally) |
75 | 75 | ||
76 | assert.is_true(run.luarocks_bool("build")) | 76 | assert.is_true(run.luarocks_bool("build")) |
77 | assert.truthy(lfs.attributes(tmpdir .. "/c_module." .. test_env.lib_extension)) | 77 | assert.truthy(lfs.attributes(tmpdir .. "/c_module." .. test_env.lib_extension)) |
78 | end, finally) | 78 | end, finally) |
@@ -84,12 +84,12 @@ describe("LuaRocks build #integration", function() | |||
84 | assert.is_false(run.luarocks_bool("build --tree=/usr " .. testing_paths.fixtures_dir .. "/a_rock-1.0.1-rockspec")) | 84 | assert.is_false(run.luarocks_bool("build --tree=/usr " .. testing_paths.fixtures_dir .. "/a_rock-1.0.1-rockspec")) |
85 | assert.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) | 85 | assert.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) |
86 | end) | 86 | end) |
87 | 87 | ||
88 | it("fails if it doesn't have the permissions to access the specified tree's parent #unix", function() | 88 | it("fails if it doesn't have the permissions to access the specified tree's parent #unix", function() |
89 | assert.is_false(run.luarocks_bool("build --tree=/usr/invalid " .. testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec")) | 89 | assert.is_false(run.luarocks_bool("build --tree=/usr/invalid " .. testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec")) |
90 | assert.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) | 90 | assert.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) |
91 | end) | 91 | end) |
92 | 92 | ||
93 | it("verbose", function() | 93 | it("verbose", function() |
94 | test_env.run_in_tmp(function(tmpdir) | 94 | test_env.run_in_tmp(function(tmpdir) |
95 | write_file("test-1.0-1.rockspec", [[ | 95 | write_file("test-1.0-1.rockspec", [[ |
@@ -99,7 +99,7 @@ describe("LuaRocks build #integration", function() | |||
99 | url = "file://]] .. tmpdir:gsub("\\", "/") .. [[/test.lua" | 99 | url = "file://]] .. tmpdir:gsub("\\", "/") .. [[/test.lua" |
100 | } | 100 | } |
101 | build = { | 101 | build = { |
102 | type = "builtin", | 102 | type = "builtin", |
103 | modules = { | 103 | modules = { |
104 | test = "test.lua" | 104 | test = "test.lua" |
105 | } | 105 | } |
@@ -111,14 +111,14 @@ describe("LuaRocks build #integration", function() | |||
111 | assert.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/test/1.0-1/test-1.0-1.rockspec")) | 111 | assert.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/test/1.0-1/test-1.0-1.rockspec")) |
112 | end, finally) | 112 | end, finally) |
113 | end) | 113 | end) |
114 | 114 | ||
115 | it("fails if the deps-mode argument is invalid", function() | 115 | it("fails if the deps-mode argument is invalid", function() |
116 | assert.is_false(run.luarocks_bool("build --deps-mode=123 " .. testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec")) | 116 | assert.is_false(run.luarocks_bool("build --deps-mode=123 " .. testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec")) |
117 | assert.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) | 117 | assert.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) |
118 | end) | 118 | end) |
119 | 119 | ||
120 | it("with --only-sources", function() | 120 | it("with --only-sources", function() |
121 | assert.is_true(run.luarocks_bool("download --server=" .. testing_paths.fixtures_dir .. "/a_repo --rockspec a_rock 1.0")) | 121 | assert.is_true(run.luarocks_bool("download --server=" .. testing_paths.fixtures_dir .. "/a_repo --rockspec a_rock 1.0")) |
122 | assert.is_false(run.luarocks_bool("build --only-sources=\"http://example.com\" a_rock-1.0-1.rockspec")) | 122 | assert.is_false(run.luarocks_bool("build --only-sources=\"http://example.com\" a_rock-1.0-1.rockspec")) |
123 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) | 123 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) |
124 | 124 | ||
@@ -129,7 +129,7 @@ describe("LuaRocks build #integration", function() | |||
129 | assert.is_true(os.remove("a_rock-1.0-1.rockspec")) | 129 | assert.is_true(os.remove("a_rock-1.0-1.rockspec")) |
130 | assert.is_true(os.remove("a_rock-1.0-1.src.rock")) | 130 | assert.is_true(os.remove("a_rock-1.0-1.src.rock")) |
131 | end) | 131 | end) |
132 | 132 | ||
133 | it("fails if an empty tree is given", function() | 133 | it("fails if an empty tree is given", function() |
134 | assert.is_false(run.luarocks_bool("build --tree=\"\" " .. testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec")) | 134 | assert.is_false(run.luarocks_bool("build --tree=\"\" " .. testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec")) |
135 | assert.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) | 135 | assert.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) |
@@ -141,12 +141,12 @@ describe("LuaRocks build #integration", function() | |||
141 | assert.is_true(run.luarocks_bool("build luacov 0.13.0-1")) | 141 | assert.is_true(run.luarocks_bool("build luacov 0.13.0-1")) |
142 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luacov/0.13.0-1/luacov-0.13.0-1.rockspec")) | 142 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luacov/0.13.0-1/luacov-0.13.0-1.rockspec")) |
143 | end) | 143 | end) |
144 | 144 | ||
145 | it("command stdlib", function() | 145 | it("command stdlib", function() |
146 | assert.is_true(run.luarocks_bool("build stdlib")) | 146 | assert.is_true(run.luarocks_bool("build stdlib")) |
147 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/stdlib/41.0.0-1/stdlib-41.0.0-1.rockspec")) | 147 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/stdlib/41.0.0-1/stdlib-41.0.0-1.rockspec")) |
148 | end) | 148 | end) |
149 | 149 | ||
150 | it("fails if the current platform is not supported", function() | 150 | it("fails if the current platform is not supported", function() |
151 | test_env.run_in_tmp(function(tmpdir) | 151 | test_env.run_in_tmp(function(tmpdir) |
152 | write_file("test-1.0-1.rockspec", [[ | 152 | write_file("test-1.0-1.rockspec", [[ |
@@ -159,7 +159,7 @@ describe("LuaRocks build #integration", function() | |||
159 | "unix", "macosx" | 159 | "unix", "macosx" |
160 | } | 160 | } |
161 | build = { | 161 | build = { |
162 | type = "builtin", | 162 | type = "builtin", |
163 | modules = { | 163 | modules = { |
164 | test = "test.lua" | 164 | test = "test.lua" |
165 | } | 165 | } |
@@ -176,7 +176,7 @@ describe("LuaRocks build #integration", function() | |||
176 | end | 176 | end |
177 | end, finally) | 177 | end, finally) |
178 | end) | 178 | end) |
179 | 179 | ||
180 | it("with skipping dependency checks", function() | 180 | it("with skipping dependency checks", function() |
181 | test_env.run_in_tmp(function(tmpdir) | 181 | test_env.run_in_tmp(function(tmpdir) |
182 | write_file("test-1.0-1.rockspec", [[ | 182 | write_file("test-1.0-1.rockspec", [[ |
@@ -189,7 +189,7 @@ describe("LuaRocks build #integration", function() | |||
189 | "a_rock 1.0" | 189 | "a_rock 1.0" |
190 | } | 190 | } |
191 | build = { | 191 | build = { |
192 | type = "builtin", | 192 | type = "builtin", |
193 | modules = { | 193 | modules = { |
194 | test = "test.lua" | 194 | test = "test.lua" |
195 | } | 195 | } |
@@ -342,7 +342,7 @@ describe("LuaRocks build #integration", function() | |||
342 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/build_only_deps/0.1-1/build_only_deps-0.1-1.rockspec")) | 342 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/build_only_deps/0.1-1/build_only_deps-0.1-1.rockspec")) |
343 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) | 343 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) |
344 | end) | 344 | end) |
345 | 345 | ||
346 | it("only deps of a given rockspec", function() | 346 | it("only deps of a given rockspec", function() |
347 | test_env.run_in_tmp(function(tmpdir) | 347 | test_env.run_in_tmp(function(tmpdir) |
348 | write_file("test-1.0-1.rockspec", [[ | 348 | write_file("test-1.0-1.rockspec", [[ |
@@ -355,7 +355,7 @@ describe("LuaRocks build #integration", function() | |||
355 | "a_rock 1.0" | 355 | "a_rock 1.0" |
356 | } | 356 | } |
357 | build = { | 357 | build = { |
358 | type = "builtin", | 358 | type = "builtin", |
359 | modules = { | 359 | modules = { |
360 | test = "test.lua" | 360 | test = "test.lua" |
361 | } | 361 | } |
@@ -381,7 +381,7 @@ describe("LuaRocks build #integration", function() | |||
381 | "a_rock 1.0" | 381 | "a_rock 1.0" |
382 | } | 382 | } |
383 | build = { | 383 | build = { |
384 | type = "builtin", | 384 | type = "builtin", |
385 | modules = { | 385 | modules = { |
386 | test = "test.lua" | 386 | test = "test.lua" |
387 | } | 387 | } |
@@ -406,18 +406,18 @@ describe("LuaRocks build #integration", function() | |||
406 | describe("rockspec format 3.0 #rs3", function() | 406 | describe("rockspec format 3.0 #rs3", function() |
407 | local tmpdir | 407 | local tmpdir |
408 | local olddir | 408 | local olddir |
409 | 409 | ||
410 | before_each(function() | 410 | before_each(function() |
411 | tmpdir = get_tmp_path() | 411 | tmpdir = get_tmp_path() |
412 | olddir = lfs.currentdir() | 412 | olddir = lfs.currentdir() |
413 | lfs.mkdir(tmpdir) | 413 | lfs.mkdir(tmpdir) |
414 | lfs.chdir(tmpdir) | 414 | lfs.chdir(tmpdir) |
415 | 415 | ||
416 | lfs.mkdir("autodetect") | 416 | lfs.mkdir("autodetect") |
417 | write_file("autodetect/bla.lua", "return {}", finally) | 417 | write_file("autodetect/bla.lua", "return {}", finally) |
418 | write_file("c_module.c", c_module_source, finally) | 418 | write_file("c_module.c", c_module_source, finally) |
419 | end) | 419 | end) |
420 | 420 | ||
421 | after_each(function() | 421 | after_each(function() |
422 | if olddir then | 422 | if olddir then |
423 | lfs.chdir(olddir) | 423 | lfs.chdir(olddir) |
@@ -427,7 +427,7 @@ describe("LuaRocks build #integration", function() | |||
427 | end | 427 | end |
428 | end | 428 | end |
429 | end) | 429 | end) |
430 | 430 | ||
431 | it("defaults to build.type == 'builtin'", function() | 431 | it("defaults to build.type == 'builtin'", function() |
432 | local rockspec = "a_rock-1.0-1.rockspec" | 432 | local rockspec = "a_rock-1.0-1.rockspec" |
433 | test_env.write_file(rockspec, [[ | 433 | test_env.write_file(rockspec, [[ |
@@ -509,7 +509,7 @@ describe("LuaRocks build #integration", function() | |||
509 | lazy_teardown(function() | 509 | lazy_teardown(function() |
510 | test_env.mock_server_done() | 510 | test_env.mock_server_done() |
511 | end) | 511 | end) |
512 | 512 | ||
513 | it("fails when missing external dependency", function() | 513 | it("fails when missing external dependency", function() |
514 | test_env.run_in_tmp(function(tmpdir) | 514 | test_env.run_in_tmp(function(tmpdir) |
515 | write_file("missing_external-0.1-1.rockspec", [[ | 515 | write_file("missing_external-0.1-1.rockspec", [[ |
@@ -545,7 +545,7 @@ describe("LuaRocks build #integration", function() | |||
545 | assert.is.truthy(run.luarocks("show with_external_dep")) | 545 | assert.is.truthy(run.luarocks("show with_external_dep")) |
546 | end) | 546 | end) |
547 | end) | 547 | end) |
548 | 548 | ||
549 | describe("#build_dependencies", function() | 549 | describe("#build_dependencies", function() |
550 | it("builds with a build dependency", function() | 550 | it("builds with a build dependency", function() |
551 | assert(run.luarocks_bool("build has_build_dep --server=" .. testing_paths.fixtures_dir .. "/a_repo" )) | 551 | assert(run.luarocks_bool("build has_build_dep --server=" .. testing_paths.fixtures_dir .. "/a_repo" )) |
@@ -969,7 +969,7 @@ describe("LuaRocks build #unit", function() | |||
969 | elseif test_env.TEST_TARGET_OS == "osx" then | 969 | elseif test_env.TEST_TARGET_OS == "osx" then |
970 | os.execute("cc -dynamiclib -o " .. fdir .. "/libfixturedep.dylib " .. fdir .. "/fixturedep.c") | 970 | os.execute("cc -dynamiclib -o " .. fdir .. "/libfixturedep.dylib " .. fdir .. "/fixturedep.c") |
971 | end | 971 | end |
972 | 972 | ||
973 | local rockspec = { | 973 | local rockspec = { |
974 | rockspec_format = "3.0", | 974 | rockspec_format = "3.0", |
975 | package = "c_module", | 975 | package = "c_module", |
@@ -1026,7 +1026,7 @@ describe("LuaRocks build #unit", function() | |||
1026 | lazy_setup(function() | 1026 | lazy_setup(function() |
1027 | git = git_repo.start() | 1027 | git = git_repo.start() |
1028 | end) | 1028 | end) |
1029 | 1029 | ||
1030 | lazy_teardown(function() | 1030 | lazy_teardown(function() |
1031 | if git then | 1031 | if git then |
1032 | git:stop() | 1032 | git:stop() |
diff --git a/spec/cmd_spec.lua b/spec/cmd_spec.lua index ad6ae7ad..d28acdf6 100644 --- a/spec/cmd_spec.lua +++ b/spec/cmd_spec.lua | |||
@@ -5,7 +5,7 @@ local run = test_env.run | |||
5 | test_env.unload_luarocks() | 5 | test_env.unload_luarocks() |
6 | 6 | ||
7 | describe("LuaRocks command line #integration", function() | 7 | describe("LuaRocks command line #integration", function() |
8 | 8 | ||
9 | setup(function() | 9 | setup(function() |
10 | test_env.setup_specs() | 10 | test_env.setup_specs() |
11 | end) | 11 | end) |
diff --git a/spec/config_spec.lua b/spec/config_spec.lua index f4a793c4..a14b1ec0 100644 --- a/spec/config_spec.lua +++ b/spec/config_spec.lua | |||
@@ -9,7 +9,7 @@ local hardcoded | |||
9 | test_env.unload_luarocks() | 9 | test_env.unload_luarocks() |
10 | 10 | ||
11 | describe("LuaRocks config tests #integration", function() | 11 | describe("LuaRocks config tests #integration", function() |
12 | 12 | ||
13 | setup(function() | 13 | setup(function() |
14 | test_env.setup_specs() | 14 | test_env.setup_specs() |
15 | test_env.unload_luarocks() -- need to be required here, because hardcoded is created after first loading of specs | 15 | test_env.unload_luarocks() -- need to be required here, because hardcoded is created after first loading of specs |
@@ -55,12 +55,12 @@ describe("LuaRocks config tests #integration", function() | |||
55 | local output = run.luarocks("config --lua-incdir") | 55 | local output = run.luarocks("config --lua-incdir") |
56 | assert.match(hardcoded.LUA_DIR, output, 1, true) | 56 | assert.match(hardcoded.LUA_DIR, output, 1, true) |
57 | end) | 57 | end) |
58 | 58 | ||
59 | it("--lua-libdir returns a subdir of LUA_DIR", function() | 59 | it("--lua-libdir returns a subdir of LUA_DIR", function() |
60 | local output = run.luarocks("config --lua-libdir") | 60 | local output = run.luarocks("config --lua-libdir") |
61 | assert.match(hardcoded.LUA_DIR, output, 1, true) | 61 | assert.match(hardcoded.LUA_DIR, output, 1, true) |
62 | end) | 62 | end) |
63 | 63 | ||
64 | it("--lua-ver returns the Lua version", function() | 64 | it("--lua-ver returns the Lua version", function() |
65 | local output = run.luarocks("config --lua-ver") | 65 | local output = run.luarocks("config --lua-ver") |
66 | local lua_version = _VERSION:gsub("Lua ", "") | 66 | local lua_version = _VERSION:gsub("Lua ", "") |
@@ -69,17 +69,17 @@ describe("LuaRocks config tests #integration", function() | |||
69 | end | 69 | end |
70 | assert.are.same(lua_version, output) | 70 | assert.are.same(lua_version, output) |
71 | end) | 71 | end) |
72 | 72 | ||
73 | it("--rock-trees lists rock trees", function() | 73 | it("--rock-trees lists rock trees", function() |
74 | assert.is_true(run.luarocks_bool("config --rock-trees")) | 74 | assert.is_true(run.luarocks_bool("config --rock-trees")) |
75 | end) | 75 | end) |
76 | 76 | ||
77 | describe("--user-config", function() | 77 | describe("--user-config", function() |
78 | it("returns user config dir", function() | 78 | it("returns user config dir", function() |
79 | local user_config_path = run.luarocks("config --user-config") | 79 | local user_config_path = run.luarocks("config --user-config") |
80 | assert.is.truthy(lfs.attributes(user_config_path)) | 80 | assert.is.truthy(lfs.attributes(user_config_path)) |
81 | end) | 81 | end) |
82 | 82 | ||
83 | it("handles a missing user config", function() | 83 | it("handles a missing user config", function() |
84 | local output = run.luarocks("config --user-config", {LUAROCKS_CONFIG = "missing_file.lua"}) | 84 | local output = run.luarocks("config --user-config", {LUAROCKS_CONFIG = "missing_file.lua"}) |
85 | assert.match("Warning", output) | 85 | assert.match("Warning", output) |
@@ -89,7 +89,7 @@ describe("LuaRocks config tests #integration", function() | |||
89 | describe("--system-config", function() | 89 | describe("--system-config", function() |
90 | local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" | 90 | local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" |
91 | local configfile = scdir .. "/config-" .. env_variables.LUA_VERSION .. ".lua" | 91 | local configfile = scdir .. "/config-" .. env_variables.LUA_VERSION .. ".lua" |
92 | 92 | ||
93 | it("fails if system config doesn't exist", function() | 93 | it("fails if system config doesn't exist", function() |
94 | os.rename(configfile, configfile .. ".bak") | 94 | os.rename(configfile, configfile .. ".bak") |
95 | finally(function() | 95 | finally(function() |
@@ -97,28 +97,28 @@ describe("LuaRocks config tests #integration", function() | |||
97 | end) | 97 | end) |
98 | assert.is_false(run.luarocks_bool("config --system-config")) | 98 | assert.is_false(run.luarocks_bool("config --system-config")) |
99 | end) | 99 | end) |
100 | 100 | ||
101 | it("outputs the path of the system config", function() | 101 | it("outputs the path of the system config", function() |
102 | lfs.mkdir(testing_paths.testing_lrprefix) | 102 | lfs.mkdir(testing_paths.testing_lrprefix) |
103 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") | 103 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") |
104 | lfs.mkdir(scdir) | 104 | lfs.mkdir(scdir) |
105 | 105 | ||
106 | local sysconfig = io.open(configfile, "w+") | 106 | local sysconfig = io.open(configfile, "w+") |
107 | sysconfig:write(" ") | 107 | sysconfig:write(" ") |
108 | sysconfig:close() | 108 | sysconfig:close() |
109 | finally(function() | 109 | finally(function() |
110 | os.remove(configfile) | 110 | os.remove(configfile) |
111 | end) | 111 | end) |
112 | 112 | ||
113 | local output = run.luarocks("config --system-config") | 113 | local output = run.luarocks("config --system-config") |
114 | assert.are.same(configfile, output) | 114 | assert.are.same(configfile, output) |
115 | end) | 115 | end) |
116 | 116 | ||
117 | it("fails if system config is invalid", function() | 117 | it("fails if system config is invalid", function() |
118 | lfs.mkdir(testing_paths.testing_lrprefix) | 118 | lfs.mkdir(testing_paths.testing_lrprefix) |
119 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") | 119 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") |
120 | lfs.mkdir(scdir) | 120 | lfs.mkdir(scdir) |
121 | 121 | ||
122 | local sysconfig = io.open(configfile, "w+") | 122 | local sysconfig = io.open(configfile, "w+") |
123 | sysconfig:write("if if if") | 123 | sysconfig:write("if if if") |
124 | sysconfig:close() | 124 | sysconfig:close() |
@@ -176,7 +176,7 @@ describe("LuaRocks config tests #integration", function() | |||
176 | local myproject = tmpdir .. "/myproject" | 176 | local myproject = tmpdir .. "/myproject" |
177 | lfs.mkdir(myproject) | 177 | lfs.mkdir(myproject) |
178 | lfs.chdir(myproject) | 178 | lfs.chdir(myproject) |
179 | 179 | ||
180 | assert(run.luarocks("init")) | 180 | assert(run.luarocks("init")) |
181 | assert.truthy(run.luarocks_bool("config my_var my_value")) | 181 | assert.truthy(run.luarocks_bool("config my_var my_value")) |
182 | 182 | ||
@@ -206,7 +206,7 @@ describe("LuaRocks config tests #integration", function() | |||
206 | local myproject = tmpdir .. "/myproject" | 206 | local myproject = tmpdir .. "/myproject" |
207 | lfs.mkdir(myproject) | 207 | lfs.mkdir(myproject) |
208 | lfs.chdir(myproject) | 208 | lfs.chdir(myproject) |
209 | 209 | ||
210 | assert(run.luarocks("init")) | 210 | assert(run.luarocks("init")) |
211 | assert.truthy(run.luarocks_bool("config web_browser foo --scope=project")) | 211 | assert.truthy(run.luarocks_bool("config web_browser foo --scope=project")) |
212 | 212 | ||
@@ -220,7 +220,7 @@ describe("LuaRocks config tests #integration", function() | |||
220 | local myproject = tmpdir .. "/myproject" | 220 | local myproject = tmpdir .. "/myproject" |
221 | lfs.mkdir(myproject) | 221 | lfs.mkdir(myproject) |
222 | lfs.chdir(myproject) | 222 | lfs.chdir(myproject) |
223 | 223 | ||
224 | assert(run.luarocks("init")) | 224 | assert(run.luarocks("init")) |
225 | assert.truthy(run.luarocks_bool("config variables.FOO_DIR /foo/bar --scope=project")) | 225 | assert.truthy(run.luarocks_bool("config variables.FOO_DIR /foo/bar --scope=project")) |
226 | 226 | ||
@@ -234,7 +234,7 @@ describe("LuaRocks config tests #integration", function() | |||
234 | local myproject = tmpdir .. "/myproject" | 234 | local myproject = tmpdir .. "/myproject" |
235 | lfs.mkdir(myproject) | 235 | lfs.mkdir(myproject) |
236 | lfs.chdir(myproject) | 236 | lfs.chdir(myproject) |
237 | 237 | ||
238 | assert(run.luarocks("init")) | 238 | assert(run.luarocks("init")) |
239 | assert.truthy(run.luarocks_bool("config external_deps_patterns.lib[1] testtest --scope=project")) | 239 | assert.truthy(run.luarocks_bool("config external_deps_patterns.lib[1] testtest --scope=project")) |
240 | 240 | ||
diff --git a/spec/deps_spec.lua b/spec/deps_spec.lua index b677acc4..35fd8be5 100644 --- a/spec/deps_spec.lua +++ b/spec/deps_spec.lua | |||
@@ -22,7 +22,7 @@ describe("LuaRocks deps-mode #integration", function() | |||
22 | it("one", function() | 22 | it("one", 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/1.0.0-1/lpeg-1.0.0-1.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/1.0.0-1/lpeg-1.0.0-1.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/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
@@ -94,7 +94,7 @@ describe("LuaRocks deps-mode #integration", function() | |||
94 | assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) | 94 | assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
95 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) | 95 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
96 | end) | 96 | end) |
97 | 97 | ||
98 | it("make order sys", function() | 98 | it("make order sys", function() |
99 | assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg")) | 99 | 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")) | 100 | assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6")) |
diff --git a/spec/dir_spec.lua b/spec/dir_spec.lua index c5162b60..1b568c8f 100644 --- a/spec/dir_spec.lua +++ b/spec/dir_spec.lua | |||
@@ -7,17 +7,17 @@ local dir = require("luarocks.dir") | |||
7 | 7 | ||
8 | describe("luarocks.dir #unit", function() | 8 | describe("luarocks.dir #unit", function() |
9 | local runner | 9 | local runner |
10 | 10 | ||
11 | setup(function() | 11 | setup(function() |
12 | runner = require("luacov.runner") | 12 | runner = require("luacov.runner") |
13 | runner.init(testing_paths.testrun_dir .. "/luacov.config") | 13 | runner.init(testing_paths.testrun_dir .. "/luacov.config") |
14 | runner.tick = true | 14 | runner.tick = true |
15 | end) | 15 | end) |
16 | 16 | ||
17 | teardown(function() | 17 | teardown(function() |
18 | runner.shutdown() | 18 | runner.shutdown() |
19 | end) | 19 | end) |
20 | 20 | ||
21 | describe("dir.is_basic_protocol", function() | 21 | describe("dir.is_basic_protocol", function() |
22 | it("checks whether the arguments represent a valid protocol and returns the result of the check", function() | 22 | it("checks whether the arguments represent a valid protocol and returns the result of the check", function() |
23 | assert.truthy(dir.is_basic_protocol("http")) | 23 | assert.truthy(dir.is_basic_protocol("http")) |
diff --git a/spec/doc_spec.lua b/spec/doc_spec.lua index 19cfb26a..a10bb501 100644 --- a/spec/doc_spec.lua +++ b/spec/doc_spec.lua | |||
@@ -6,7 +6,7 @@ test_env.unload_luarocks() | |||
6 | 6 | ||
7 | describe("luarocks doc #integration", function() | 7 | describe("luarocks doc #integration", function() |
8 | before_each(function() | 8 | before_each(function() |
9 | test_env.setup_specs(extra_rocks) | 9 | test_env.setup_specs() |
10 | end) | 10 | end) |
11 | 11 | ||
12 | describe("basic tests", function() | 12 | describe("basic tests", function() |
@@ -74,7 +74,7 @@ describe("luarocks doc #integration", function() | |||
74 | assert.match("a_rock 2.0", run.luarocks("doc a_user/a_rock")) | 74 | assert.match("a_rock 2.0", run.luarocks("doc a_user/a_rock")) |
75 | end) | 75 | end) |
76 | end) | 76 | end) |
77 | 77 | ||
78 | describe("tests with flags", function() | 78 | describe("tests with flags", function() |
79 | it("of installed package", function() | 79 | it("of installed package", function() |
80 | test_env.run_in_tmp(function(tmpdir) | 80 | test_env.run_in_tmp(function(tmpdir) |
@@ -127,12 +127,12 @@ describe("luarocks doc #integration", function() | |||
127 | assert.is.truthy(output:find("doc2%.md")) | 127 | assert.is.truthy(output:find("doc2%.md")) |
128 | end, finally) | 128 | end, finally) |
129 | end) | 129 | end) |
130 | 130 | ||
131 | it("with --local", function() | 131 | it("with --local", function() |
132 | assert.is_true(run.luarocks_bool("install --server=" .. testing_paths.fixtures_dir .. "/a_repo a_rock")) | 132 | assert.is_true(run.luarocks_bool("install --server=" .. testing_paths.fixtures_dir .. "/a_repo a_rock")) |
133 | assert.is_true(run.luarocks_bool("doc --server=" .. testing_paths.fixtures_dir .. "/a_repo a_rock --local")) | 133 | assert.is_true(run.luarocks_bool("doc --server=" .. testing_paths.fixtures_dir .. "/a_repo a_rock --local")) |
134 | end) | 134 | end) |
135 | 135 | ||
136 | it("with --porcelain", function() | 136 | it("with --porcelain", function() |
137 | test_env.run_in_tmp(function(tmpdir) | 137 | test_env.run_in_tmp(function(tmpdir) |
138 | test_env.write_file("test-1.0-1.rockspec", [[ | 138 | test_env.write_file("test-1.0-1.rockspec", [[ |
diff --git a/spec/download_spec.lua b/spec/download_spec.lua index 42f72008..823e154f 100644 --- a/spec/download_spec.lua +++ b/spec/download_spec.lua | |||
@@ -28,7 +28,7 @@ describe("luarocks download #integration", function() | |||
28 | assert.is.truthy(lfs.attributes("validate-args-1.5.4-1.rockspec")) | 28 | assert.is.truthy(lfs.attributes("validate-args-1.5.4-1.rockspec")) |
29 | test_env.remove_files(lfs.currentdir(), "validate--args--") | 29 | test_env.remove_files(lfs.currentdir(), "validate--args--") |
30 | end) | 30 | end) |
31 | 31 | ||
32 | it("rockspec version", function() | 32 | it("rockspec version", function() |
33 | assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) | 33 | assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) |
34 | assert.is.truthy(lfs.attributes("validate-args-1.5.4-1.rockspec")) | 34 | assert.is.truthy(lfs.attributes("validate-args-1.5.4-1.rockspec")) |
diff --git a/spec/fetch_spec.lua b/spec/fetch_spec.lua index 6e23a8f2..8194a298 100644 --- a/spec/fetch_spec.lua +++ b/spec/fetch_spec.lua | |||
@@ -17,9 +17,9 @@ describe("luarocks fetch #unit #mock", function() | |||
17 | local are_same_files = function(file1, file2) | 17 | local are_same_files = function(file1, file2) |
18 | return file1 == file2 or lfs.attributes(file1).ino == lfs.attributes(file2).ino | 18 | return file1 == file2 or lfs.attributes(file1).ino == lfs.attributes(file2).ino |
19 | end | 19 | end |
20 | 20 | ||
21 | local runner | 21 | local runner |
22 | 22 | ||
23 | setup(function() | 23 | setup(function() |
24 | cfg.init() | 24 | cfg.init() |
25 | fs.init() | 25 | fs.init() |
@@ -29,15 +29,15 @@ describe("luarocks fetch #unit #mock", function() | |||
29 | runner.init(testing_paths.testrun_dir .. "/luacov.config") | 29 | runner.init(testing_paths.testrun_dir .. "/luacov.config") |
30 | runner.tick = true | 30 | runner.tick = true |
31 | end) | 31 | end) |
32 | 32 | ||
33 | teardown(function() | 33 | teardown(function() |
34 | test_env.mock_server_done() | 34 | test_env.mock_server_done() |
35 | 35 | ||
36 | runner.shutdown() | 36 | runner.shutdown() |
37 | end) | 37 | end) |
38 | 38 | ||
39 | describe("fetch.fetch_url", function() | 39 | describe("fetch.fetch_url", function() |
40 | 40 | ||
41 | it("fetches the url argument and returns the absolute path of the fetched file", function() | 41 | it("fetches the url argument and returns the absolute path of the fetched file", function() |
42 | local fetchedfile = fetch.fetch_url("http://localhost:8080/file/a_rock.lua") | 42 | local fetchedfile = fetch.fetch_url("http://localhost:8080/file/a_rock.lua") |
43 | assert.truthy(are_same_files(fetchedfile, lfs.currentdir() .. "/a_rock.lua")) | 43 | assert.truthy(are_same_files(fetchedfile, lfs.currentdir() .. "/a_rock.lua")) |
@@ -50,25 +50,25 @@ describe("luarocks fetch #unit #mock", function() | |||
50 | assert.same(fetchedcontent, filecontent) | 50 | assert.same(fetchedcontent, filecontent) |
51 | os.remove(fetchedfile) | 51 | os.remove(fetchedfile) |
52 | end) | 52 | end) |
53 | 53 | ||
54 | it("returns the absolute path of the filename argument if the url represents a file", function() | 54 | it("returns the absolute path of the filename argument if the url represents a file", function() |
55 | local file = fetch.fetch_url("file://a_rock.lua") | 55 | local file = fetch.fetch_url("file://a_rock.lua") |
56 | assert.truthy(are_same_files(file, lfs.currentdir() .. "/a_rock.lua")) | 56 | assert.truthy(are_same_files(file, lfs.currentdir() .. "/a_rock.lua")) |
57 | end) | 57 | end) |
58 | 58 | ||
59 | it("returns false and does nothing if the url argument contains a nonexistent file", function() | 59 | it("returns false and does nothing if the url argument contains a nonexistent file", function() |
60 | assert.falsy(fetch.fetch_url("http://localhost:8080/file/nonexistent")) | 60 | assert.falsy(fetch.fetch_url("http://localhost:8080/file/nonexistent")) |
61 | end) | 61 | end) |
62 | 62 | ||
63 | it("returns false and does nothing if the url argument is invalid", function() | 63 | it("returns false and does nothing if the url argument is invalid", function() |
64 | assert.falsy(fetch.fetch_url("invalid://url", "file")) | 64 | assert.falsy(fetch.fetch_url("invalid://url", "file")) |
65 | end) | 65 | end) |
66 | end) | 66 | end) |
67 | 67 | ||
68 | describe("fetch.fetch_url_at_temp_dir", function() | 68 | describe("fetch.fetch_url_at_temp_dir", function() |
69 | local tmpfile | 69 | local tmpfile |
70 | local tmpdir | 70 | local tmpdir |
71 | 71 | ||
72 | after_each(function() | 72 | after_each(function() |
73 | if tmpfile then | 73 | if tmpfile then |
74 | os.remove(tmpfile) | 74 | os.remove(tmpfile) |
@@ -89,7 +89,7 @@ describe("luarocks fetch #unit #mock", function() | |||
89 | assert.truthy(are_same_files(tmpfile, pathname)) | 89 | assert.truthy(are_same_files(tmpfile, pathname)) |
90 | assert.truthy(are_same_files(tmpdir, dirname)) | 90 | assert.truthy(are_same_files(tmpdir, dirname)) |
91 | end) | 91 | end) |
92 | 92 | ||
93 | it("returns true and fetches the url into a temporary dir", function() | 93 | it("returns true and fetches the url into a temporary dir", function() |
94 | local fetchedfile, tmpdir = fetch.fetch_url_at_temp_dir("http://localhost:8080/file/a_rock.lua", "test") | 94 | local fetchedfile, tmpdir = fetch.fetch_url_at_temp_dir("http://localhost:8080/file/a_rock.lua", "test") |
95 | assert.truthy(are_same_files(fetchedfile, tmpdir .. "/a_rock.lua")) | 95 | assert.truthy(are_same_files(fetchedfile, tmpdir .. "/a_rock.lua")) |
@@ -101,7 +101,7 @@ describe("luarocks fetch #unit #mock", function() | |||
101 | fd:close() | 101 | fd:close() |
102 | assert.same(fetchedcontent, filecontent) | 102 | assert.same(fetchedcontent, filecontent) |
103 | end) | 103 | end) |
104 | 104 | ||
105 | it("returns true and fetches the url into a temporary dir with custom filename", function() | 105 | it("returns true and fetches the url into a temporary dir with custom filename", function() |
106 | local fetchedfile, tmpdir = fetch.fetch_url_at_temp_dir("http://localhost:8080/file/a_rock.lua", "test", "my_a_rock.lua") | 106 | local fetchedfile, tmpdir = fetch.fetch_url_at_temp_dir("http://localhost:8080/file/a_rock.lua", "test", "my_a_rock.lua") |
107 | assert.truthy(are_same_files(fetchedfile, tmpdir .. "/my_a_rock.lua")) | 107 | assert.truthy(are_same_files(fetchedfile, tmpdir .. "/my_a_rock.lua")) |
@@ -114,12 +114,12 @@ describe("luarocks fetch #unit #mock", function() | |||
114 | fd:close() | 114 | fd:close() |
115 | assert.same(fetchedcontent, filecontent) | 115 | assert.same(fetchedcontent, filecontent) |
116 | end) | 116 | end) |
117 | 117 | ||
118 | it("returns false and does nothing if the file specified in the url is nonexistent", function() | 118 | it("returns false and does nothing if the file specified in the url is nonexistent", function() |
119 | assert.falsy(fetch.fetch_url_at_temp_dir("file://nonexistent", "test")) | 119 | assert.falsy(fetch.fetch_url_at_temp_dir("file://nonexistent", "test")) |
120 | assert.falsy(fetch.fetch_url_at_temp_dir("http://localhost:8080/file/nonexistent", "test")) | 120 | assert.falsy(fetch.fetch_url_at_temp_dir("http://localhost:8080/file/nonexistent", "test")) |
121 | end) | 121 | end) |
122 | 122 | ||
123 | it("returns false and does nothing if the url is invalid", function() | 123 | it("returns false and does nothing if the url is invalid", function() |
124 | assert.falsy(fetch.fetch_url_at_temp_dir("url://invalid", "test")) | 124 | assert.falsy(fetch.fetch_url_at_temp_dir("url://invalid", "test")) |
125 | end) | 125 | end) |
@@ -133,7 +133,7 @@ describe("luarocks fetch #unit #mock", function() | |||
133 | assert.truthy(are_same_files(inferreddir, founddir)) | 133 | assert.truthy(are_same_files(inferreddir, founddir)) |
134 | assert.truthy(lfs.attributes(tmpdir .. "/" .. founddir)) | 134 | assert.truthy(lfs.attributes(tmpdir .. "/" .. founddir)) |
135 | end) | 135 | end) |
136 | 136 | ||
137 | it("extracts the archive given by the file argument with given base directory and returns the inferred and the actual root directory in the archive", function() | 137 | it("extracts the archive given by the file argument with given base directory and returns the inferred and the actual root directory in the archive", function() |
138 | local url = "http://localhost:8080/file/an_upstream_tarball-0.1.tar.gz" | 138 | local url = "http://localhost:8080/file/an_upstream_tarball-0.1.tar.gz" |
139 | local file, tmpdir = assert(fetch.fetch_url_at_temp_dir(url, "test")) | 139 | local file, tmpdir = assert(fetch.fetch_url_at_temp_dir(url, "test")) |
@@ -142,29 +142,29 @@ describe("luarocks fetch #unit #mock", function() | |||
142 | assert.truthy(are_same_files(founddir, "an_upstream_tarball-0.1")) | 142 | assert.truthy(are_same_files(founddir, "an_upstream_tarball-0.1")) |
143 | assert.truthy(lfs.attributes(tmpdir .. "/" .. founddir)) | 143 | assert.truthy(lfs.attributes(tmpdir .. "/" .. founddir)) |
144 | end) | 144 | end) |
145 | 145 | ||
146 | it("returns false and does nothing if the temporary directory doesn't exist", function() | 146 | it("returns false and does nothing if the temporary directory doesn't exist", function() |
147 | assert.falsy(fetch.find_base_dir("file", "nonexistent", "url")) | 147 | assert.falsy(fetch.find_base_dir("file", "nonexistent", "url")) |
148 | end) | 148 | end) |
149 | end) | 149 | end) |
150 | 150 | ||
151 | describe("fetch.fetch_and_unpack_rock", function() | 151 | describe("fetch.fetch_and_unpack_rock", function() |
152 | local tmpdir | 152 | local tmpdir |
153 | 153 | ||
154 | after_each(function() | 154 | after_each(function() |
155 | if tmpdir then | 155 | if tmpdir then |
156 | lfs.rmdir(tmpdir) | 156 | lfs.rmdir(tmpdir) |
157 | tmpdir = nil | 157 | tmpdir = nil |
158 | end | 158 | end |
159 | end) | 159 | end) |
160 | 160 | ||
161 | it("unpacks the rock file from the url and returns its resulting temporary parent directory", function() | 161 | it("unpacks the rock file from the url and returns its resulting temporary parent directory", function() |
162 | tmpdir = fetch.fetch_and_unpack_rock("http://localhost:8080/file/a_rock-1.0-1.src.rock") | 162 | tmpdir = fetch.fetch_and_unpack_rock("http://localhost:8080/file/a_rock-1.0-1.src.rock") |
163 | assert.truthy(string.find(tmpdir, "a_rock%-1%.0%-1")) | 163 | assert.truthy(string.find(tmpdir, "a_rock%-1%.0%-1")) |
164 | assert.truthy(lfs.attributes(tmpdir .. "/a_rock-1.0-1.rockspec")) | 164 | assert.truthy(lfs.attributes(tmpdir .. "/a_rock-1.0-1.rockspec")) |
165 | assert.truthy(lfs.attributes(tmpdir .. "/a_rock.lua")) | 165 | assert.truthy(lfs.attributes(tmpdir .. "/a_rock.lua")) |
166 | end) | 166 | end) |
167 | 167 | ||
168 | it("unpacks the rock file from the url with custom unpacking directory", function() | 168 | it("unpacks the rock file from the url with custom unpacking directory", function() |
169 | tmpdir = get_tmp_path() | 169 | tmpdir = get_tmp_path() |
170 | lfs.mkdir(tmpdir) | 170 | lfs.mkdir(tmpdir) |
@@ -173,15 +173,15 @@ describe("luarocks fetch #unit #mock", function() | |||
173 | assert.truthy(lfs.attributes(resultingdir .. "/a_rock-1.0-1.rockspec")) | 173 | assert.truthy(lfs.attributes(resultingdir .. "/a_rock-1.0-1.rockspec")) |
174 | assert.truthy(lfs.attributes(resultingdir .. "/a_rock.lua")) | 174 | assert.truthy(lfs.attributes(resultingdir .. "/a_rock.lua")) |
175 | end) | 175 | end) |
176 | 176 | ||
177 | it("does nothing if the url doesn't represent a rock file", function() | 177 | it("does nothing if the url doesn't represent a rock file", function() |
178 | assert.falsy(pcall(fetch.fetch_and_unpack_rock, "http://localhost:8080/file/a_rock.lua")) | 178 | assert.falsy(pcall(fetch.fetch_and_unpack_rock, "http://localhost:8080/file/a_rock.lua")) |
179 | end) | 179 | end) |
180 | 180 | ||
181 | it("does nothing if the rock file url is invalid", function() | 181 | it("does nothing if the rock file url is invalid", function() |
182 | assert.falsy(pcall(fetch.fetch_and_unpack_rock, "url://invalid")) | 182 | assert.falsy(pcall(fetch.fetch_and_unpack_rock, "url://invalid")) |
183 | end) | 183 | end) |
184 | 184 | ||
185 | it("does nothing if the rock file url represents a nonexistent file", function() | 185 | it("does nothing if the rock file url represents a nonexistent file", function() |
186 | assert.falsy(pcall(fetch.fetch_and_unpack_rock, "url://invalid")) | 186 | assert.falsy(pcall(fetch.fetch_and_unpack_rock, "url://invalid")) |
187 | assert.falsy(pcall(fetch.fetch_and_unpack_rock, "http://localhost:8080/file/nonexistent")) | 187 | assert.falsy(pcall(fetch.fetch_and_unpack_rock, "http://localhost:8080/file/nonexistent")) |
@@ -191,7 +191,7 @@ describe("luarocks fetch #unit #mock", function() | |||
191 | describe("fetch.load_local_rockspec", function() | 191 | describe("fetch.load_local_rockspec", function() |
192 | local tmpdir | 192 | local tmpdir |
193 | local olddir | 193 | local olddir |
194 | 194 | ||
195 | before_each(function() | 195 | before_each(function() |
196 | tmpdir = get_tmp_path() | 196 | tmpdir = get_tmp_path() |
197 | olddir = lfs.currentdir() | 197 | olddir = lfs.currentdir() |
@@ -199,7 +199,7 @@ describe("luarocks fetch #unit #mock", function() | |||
199 | lfs.chdir(tmpdir) | 199 | lfs.chdir(tmpdir) |
200 | fs.change_dir(tmpdir) | 200 | fs.change_dir(tmpdir) |
201 | end) | 201 | end) |
202 | 202 | ||
203 | after_each(function() | 203 | after_each(function() |
204 | if olddir then | 204 | if olddir then |
205 | lfs.chdir(olddir) | 205 | lfs.chdir(olddir) |
@@ -208,14 +208,14 @@ describe("luarocks fetch #unit #mock", function() | |||
208 | end | 208 | end |
209 | end | 209 | end |
210 | end) | 210 | end) |
211 | 211 | ||
212 | it("returns a table representing the rockspec from the given file skipping some checks if the quick argument is enabled", function() | 212 | it("returns a table representing the rockspec from the given file skipping some checks if the quick argument is enabled", function() |
213 | local rockspec = fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec", true) | 213 | local rockspec = fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec", true) |
214 | assert.same(rockspec.name, "a_rock") | 214 | assert.same(rockspec.name, "a_rock") |
215 | assert.same(rockspec.version, "1.0-1") | 215 | assert.same(rockspec.version, "1.0-1") |
216 | assert.same(rockspec.source.url, "http://localhost:8080/file/a_rock.lua") | 216 | assert.same(rockspec.source.url, "http://localhost:8080/file/a_rock.lua") |
217 | assert.same(rockspec.description, { summary = "An example rockspec" }) | 217 | assert.same(rockspec.description, { summary = "An example rockspec" }) |
218 | 218 | ||
219 | write_file("missing_mandatory_field-1.0-1.rockspec", [[ | 219 | write_file("missing_mandatory_field-1.0-1.rockspec", [[ |
220 | package="missing_mandatory_field" | 220 | package="missing_mandatory_field" |
221 | version="1.0-1" | 221 | version="1.0-1" |
@@ -227,7 +227,7 @@ describe("luarocks fetch #unit #mock", function() | |||
227 | assert.same(rockspec.name, "missing_mandatory_field") | 227 | assert.same(rockspec.name, "missing_mandatory_field") |
228 | assert.same(rockspec.version, "1.0-1") | 228 | assert.same(rockspec.version, "1.0-1") |
229 | assert.same(rockspec.source.url, "http://example.com/foo.tar.gz") | 229 | assert.same(rockspec.source.url, "http://example.com/foo.tar.gz") |
230 | 230 | ||
231 | write_file("unknown_field-1.0-1.rockspec", [[ | 231 | write_file("unknown_field-1.0-1.rockspec", [[ |
232 | package="unknown_field" | 232 | package="unknown_field" |
233 | version="1.0-1" | 233 | version="1.0-1" |
@@ -246,7 +246,7 @@ describe("luarocks fetch #unit #mock", function() | |||
246 | assert.falsy(fetch.load_local_rockspec("missing_mandatory_field-1.0-1.rockspec")) | 246 | assert.falsy(fetch.load_local_rockspec("missing_mandatory_field-1.0-1.rockspec")) |
247 | assert.falsy(fetch.load_local_rockspec("unknown_field-1.0-1.rockspec")) | 247 | assert.falsy(fetch.load_local_rockspec("unknown_field-1.0-1.rockspec")) |
248 | end) | 248 | end) |
249 | 249 | ||
250 | it("returns a table representing the rockspec from the given file", function() | 250 | it("returns a table representing the rockspec from the given file", function() |
251 | path.use_tree(testing_paths.testing_tree) | 251 | path.use_tree(testing_paths.testing_tree) |
252 | local rockspec = fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec") | 252 | local rockspec = fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec") |
@@ -255,15 +255,15 @@ describe("luarocks fetch #unit #mock", function() | |||
255 | assert.same(rockspec.description, { summary = "An example rockspec" }) | 255 | assert.same(rockspec.description, { summary = "An example rockspec" }) |
256 | assert.same(rockspec.source.url, "http://localhost:8080/file/a_rock.lua") | 256 | assert.same(rockspec.source.url, "http://localhost:8080/file/a_rock.lua") |
257 | end) | 257 | end) |
258 | 258 | ||
259 | it("returns false if the rockspec in invalid", function() | 259 | it("returns false if the rockspec in invalid", function() |
260 | assert.falsy(fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/invalid_validate-args-1.5.4-1.rockspec")) | 260 | assert.falsy(fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/invalid_validate-args-1.5.4-1.rockspec")) |
261 | end) | 261 | end) |
262 | 262 | ||
263 | it("returns false if the rockspec version is not supported", function() | 263 | it("returns false if the rockspec version is not supported", function() |
264 | assert.falsy(fetch.load_local_rockspec("invalid_version.rockspec")) | 264 | assert.falsy(fetch.load_local_rockspec("invalid_version.rockspec")) |
265 | end) | 265 | end) |
266 | 266 | ||
267 | it("returns false if the rockspec doesn't pass the type checking", function() | 267 | it("returns false if the rockspec doesn't pass the type checking", function() |
268 | write_file("type_mismatch_string-1.0-1.rockspec", [[ | 268 | write_file("type_mismatch_string-1.0-1.rockspec", [[ |
269 | package="type_mismatch_version" | 269 | package="type_mismatch_version" |
@@ -271,7 +271,7 @@ describe("luarocks fetch #unit #mock", function() | |||
271 | ]], finally) | 271 | ]], finally) |
272 | assert.falsy(fetch.load_local_rockspec("type_mismatch_string-1.0-1.rockspec")) | 272 | assert.falsy(fetch.load_local_rockspec("type_mismatch_string-1.0-1.rockspec")) |
273 | end) | 273 | end) |
274 | 274 | ||
275 | it("returns false if the rockspec file name is not right", function() | 275 | it("returns false if the rockspec file name is not right", function() |
276 | write_file("invalid_rockspec_name.rockspec", [[ | 276 | write_file("invalid_rockspec_name.rockspec", [[ |
277 | package="invalid_rockspec_name" | 277 | package="invalid_rockspec_name" |
@@ -280,12 +280,12 @@ describe("luarocks fetch #unit #mock", function() | |||
280 | url = "http://example.com/foo.tar.gz" | 280 | url = "http://example.com/foo.tar.gz" |
281 | } | 281 | } |
282 | build = { | 282 | build = { |
283 | 283 | ||
284 | } | 284 | } |
285 | ]], finally) | 285 | ]], finally) |
286 | assert.falsy(fetch.load_local_rockspec("invalid_rockspec_name.rockspec")) | 286 | assert.falsy(fetch.load_local_rockspec("invalid_rockspec_name.rockspec")) |
287 | end) | 287 | end) |
288 | 288 | ||
289 | it("returns false if the version in the rockspec file name doesn't match the version declared in the rockspec", function() | 289 | it("returns false if the version in the rockspec file name doesn't match the version declared in the rockspec", function() |
290 | write_file("inconsistent_versions-1.0-1.rockspec", [[ | 290 | write_file("inconsistent_versions-1.0-1.rockspec", [[ |
291 | package="inconsistent_versions" | 291 | package="inconsistent_versions" |
@@ -294,13 +294,13 @@ describe("luarocks fetch #unit #mock", function() | |||
294 | url = "http://example.com/foo.tar.gz" | 294 | url = "http://example.com/foo.tar.gz" |
295 | } | 295 | } |
296 | build = { | 296 | build = { |
297 | 297 | ||
298 | } | 298 | } |
299 | ]], finally) | 299 | ]], finally) |
300 | assert.falsy(fetch.load_local_rockspec("inconsistent_versions-1.0-1.rockspec")) | 300 | assert.falsy(fetch.load_local_rockspec("inconsistent_versions-1.0-1.rockspec")) |
301 | end) | 301 | end) |
302 | end) | 302 | end) |
303 | 303 | ||
304 | describe("fetch.load_rockspec", function() | 304 | describe("fetch.load_rockspec", function() |
305 | it("returns a table containing the requested rockspec by downloading it into a temporary directory", function() | 305 | it("returns a table containing the requested rockspec by downloading it into a temporary directory", function() |
306 | path.use_tree(testing_paths.testing_tree) | 306 | path.use_tree(testing_paths.testing_tree) |
@@ -315,11 +315,11 @@ describe("luarocks fetch #unit #mock", function() | |||
315 | assert.same(rockspec.description, { summary = "An example rockspec" }) | 315 | assert.same(rockspec.description, { summary = "An example rockspec" }) |
316 | assert.same(rockspec.source.url, "http://localhost:8080/file/a_rock.lua") | 316 | assert.same(rockspec.source.url, "http://localhost:8080/file/a_rock.lua") |
317 | end) | 317 | end) |
318 | 318 | ||
319 | it("returns a table containing the requested rockspec by downloading it into a given directory", function() | 319 | it("returns a table containing the requested rockspec by downloading it into a given directory", function() |
320 | local tmpdir = get_tmp_path() | 320 | local tmpdir = get_tmp_path() |
321 | lfs.mkdir(tmpdir) | 321 | lfs.mkdir(tmpdir) |
322 | 322 | ||
323 | path.use_tree(testing_paths.testing_tree) | 323 | path.use_tree(testing_paths.testing_tree) |
324 | local rockspec = fetch.load_rockspec("http://localhost:8080/file/a_rock-1.0-1.rockspec", tmpdir) | 324 | local rockspec = fetch.load_rockspec("http://localhost:8080/file/a_rock-1.0-1.rockspec", tmpdir) |
325 | assert.same(rockspec.name, "a_rock") | 325 | assert.same(rockspec.name, "a_rock") |
@@ -327,23 +327,23 @@ describe("luarocks fetch #unit #mock", function() | |||
327 | assert.same(rockspec.description, { summary = "An example rockspec" }) | 327 | assert.same(rockspec.description, { summary = "An example rockspec" }) |
328 | assert.same(rockspec.source.url, "http://localhost:8080/file/a_rock.lua") | 328 | assert.same(rockspec.source.url, "http://localhost:8080/file/a_rock.lua") |
329 | assert.truthy(lfs.attributes(tmpdir .. "/a_rock-1.0-1.rockspec")) | 329 | assert.truthy(lfs.attributes(tmpdir .. "/a_rock-1.0-1.rockspec")) |
330 | 330 | ||
331 | lfs.rmdir(tmpdir) | 331 | lfs.rmdir(tmpdir) |
332 | end) | 332 | end) |
333 | 333 | ||
334 | it("returns false if the given download directory doesn't exist", function() | 334 | it("returns false if the given download directory doesn't exist", function() |
335 | assert.falsy(fetch.load_rockspec("http://localhost:8080/file/a_rock-1.0-1.rockspec", "nonexistent")) | 335 | assert.falsy(fetch.load_rockspec("http://localhost:8080/file/a_rock-1.0-1.rockspec", "nonexistent")) |
336 | end) | 336 | end) |
337 | 337 | ||
338 | it("returns false if the given filename is not a valid rockspec name", function() | 338 | it("returns false if the given filename is not a valid rockspec name", function() |
339 | assert.falsy(fetch.load_rockspec("http://localhost:8080/file/a_rock.lua")) | 339 | assert.falsy(fetch.load_rockspec("http://localhost:8080/file/a_rock.lua")) |
340 | end) | 340 | end) |
341 | end) | 341 | end) |
342 | 342 | ||
343 | describe("fetch.get_sources", function() | 343 | describe("fetch.get_sources", function() |
344 | local tmpdir | 344 | local tmpdir |
345 | local olddir | 345 | local olddir |
346 | 346 | ||
347 | before_each(function() | 347 | before_each(function() |
348 | tmpdir = get_tmp_path() | 348 | tmpdir = get_tmp_path() |
349 | olddir = lfs.currentdir() | 349 | olddir = lfs.currentdir() |
@@ -351,7 +351,7 @@ describe("luarocks fetch #unit #mock", function() | |||
351 | lfs.chdir(tmpdir) | 351 | lfs.chdir(tmpdir) |
352 | fs.change_dir(tmpdir) | 352 | fs.change_dir(tmpdir) |
353 | end) | 353 | end) |
354 | 354 | ||
355 | after_each(function() | 355 | after_each(function() |
356 | if olddir then | 356 | if olddir then |
357 | lfs.chdir(olddir) | 357 | lfs.chdir(olddir) |
@@ -360,13 +360,13 @@ describe("luarocks fetch #unit #mock", function() | |||
360 | end | 360 | end |
361 | end | 361 | end |
362 | end) | 362 | end) |
363 | 363 | ||
364 | it("downloads the sources for building a rock and returns the resulting source filename and its parent directory", function() | 364 | it("downloads the sources for building a rock and returns the resulting source filename and its parent directory", function() |
365 | local rockspec = assert(fetch.load_rockspec("http://localhost:8080/file/a_rock-1.0-1.rockspec")) | 365 | local rockspec = assert(fetch.load_rockspec("http://localhost:8080/file/a_rock-1.0-1.rockspec")) |
366 | local file, dir = fetch.get_sources(rockspec, false) | 366 | local file, dir = fetch.get_sources(rockspec, false) |
367 | assert.truthy(are_same_files(dir .. "/a_rock.lua", file)) | 367 | assert.truthy(are_same_files(dir .. "/a_rock.lua", file)) |
368 | end) | 368 | end) |
369 | 369 | ||
370 | it("downloads the sources for building a rock into a given directory and returns the resulting source filename and its parent directory", function() | 370 | it("downloads the sources for building a rock into a given directory and returns the resulting source filename and its parent directory", function() |
371 | local tmpdir = get_tmp_path() | 371 | local tmpdir = get_tmp_path() |
372 | lfs.mkdir(tmpdir) | 372 | lfs.mkdir(tmpdir) |
@@ -376,7 +376,7 @@ describe("luarocks fetch #unit #mock", function() | |||
376 | assert.truthy(are_same_files(dir .. "/a_rock.lua", file)) | 376 | assert.truthy(are_same_files(dir .. "/a_rock.lua", file)) |
377 | lfs.rmdir(tmpdir) | 377 | lfs.rmdir(tmpdir) |
378 | end) | 378 | end) |
379 | 379 | ||
380 | it("downloads the sources for building a rock, extracts the downloaded tarball and returns the resulting source filename and its parent directory", function() | 380 | it("downloads the sources for building a rock, extracts the downloaded tarball and returns the resulting source filename and its parent directory", function() |
381 | local rockspec = assert(fetch.load_rockspec("http://localhost:8080/file/busted_project-0.1-1.rockspec")) | 381 | local rockspec = assert(fetch.load_rockspec("http://localhost:8080/file/busted_project-0.1-1.rockspec")) |
382 | local file, dir = fetch.get_sources(rockspec, true) | 382 | local file, dir = fetch.get_sources(rockspec, true) |
@@ -385,12 +385,12 @@ describe("luarocks fetch #unit #mock", function() | |||
385 | assert.truthy(lfs.attributes(dir .. "/busted_project/sum.lua")) | 385 | assert.truthy(lfs.attributes(dir .. "/busted_project/sum.lua")) |
386 | assert.truthy(lfs.attributes(dir .. "/busted_project/spec/sum_spec.lua")) | 386 | assert.truthy(lfs.attributes(dir .. "/busted_project/spec/sum_spec.lua")) |
387 | end) | 387 | end) |
388 | 388 | ||
389 | it("returns false and does nothing if the destination directory doesn't exist", function() | 389 | it("returns false and does nothing if the destination directory doesn't exist", function() |
390 | local rockspec = assert(fetch.load_rockspec("http://localhost:8080/file/a_rock-1.0-1.rockspec")) | 390 | local rockspec = assert(fetch.load_rockspec("http://localhost:8080/file/a_rock-1.0-1.rockspec")) |
391 | assert.falsy(fetch.get_sources(rockspec, false, "nonexistent")) | 391 | assert.falsy(fetch.get_sources(rockspec, false, "nonexistent")) |
392 | end) | 392 | end) |
393 | 393 | ||
394 | it("returns false and does nothing if the rockspec source url is invalid", function() | 394 | it("returns false and does nothing if the rockspec source url is invalid", function() |
395 | write_file("invalid_url-1.0-1.rockspec", [[ | 395 | write_file("invalid_url-1.0-1.rockspec", [[ |
396 | package="invalid_url" | 396 | package="invalid_url" |
@@ -399,13 +399,13 @@ describe("luarocks fetch #unit #mock", function() | |||
399 | url = "http://localhost:8080/file/nonexistent" | 399 | url = "http://localhost:8080/file/nonexistent" |
400 | } | 400 | } |
401 | build = { | 401 | build = { |
402 | 402 | ||
403 | } | 403 | } |
404 | ]], finally) | 404 | ]], finally) |
405 | local rockspec = assert(fetch.load_rockspec("invalid_url-1.0-1.rockspec")) | 405 | local rockspec = assert(fetch.load_rockspec("invalid_url-1.0-1.rockspec")) |
406 | assert.falsy(fetch.get_sources(rockspec, false)) | 406 | assert.falsy(fetch.get_sources(rockspec, false)) |
407 | end) | 407 | end) |
408 | 408 | ||
409 | it("returns false and does nothing if the downloaded rockspec has an invalid md5 checksum", function() | 409 | it("returns false and does nothing if the downloaded rockspec has an invalid md5 checksum", function() |
410 | write_file("invalid_checksum-1.0-1.rockspec", [[ | 410 | write_file("invalid_checksum-1.0-1.rockspec", [[ |
411 | package="invalid_checksum" | 411 | package="invalid_checksum" |
@@ -415,7 +415,7 @@ describe("luarocks fetch #unit #mock", function() | |||
415 | md5 = "invalid" | 415 | md5 = "invalid" |
416 | } | 416 | } |
417 | build = { | 417 | build = { |
418 | 418 | ||
419 | } | 419 | } |
420 | ]], finally) | 420 | ]], finally) |
421 | local rockspec = assert(fetch.load_rockspec("invalid_checksum-1.0-1.rockspec")) | 421 | local rockspec = assert(fetch.load_rockspec("invalid_checksum-1.0-1.rockspec")) |
@@ -429,7 +429,7 @@ describe("luarocks fetch #unit #mock", function() | |||
429 | setup(function() | 429 | setup(function() |
430 | git = git_repo.start() | 430 | git = git_repo.start() |
431 | end) | 431 | end) |
432 | 432 | ||
433 | teardown(function() | 433 | teardown(function() |
434 | if git then | 434 | if git then |
435 | git:stop() | 435 | git:stop() |
diff --git a/spec/fs_spec.lua b/spec/fs_spec.lua index cc36d277..5410cff7 100644 --- a/spec/fs_spec.lua +++ b/spec/fs_spec.lua | |||
@@ -62,7 +62,7 @@ describe("luarocks.fs #unit", function() | |||
62 | end | 62 | end |
63 | 63 | ||
64 | local runner | 64 | local runner |
65 | 65 | ||
66 | setup(function() | 66 | setup(function() |
67 | cfg.init() | 67 | cfg.init() |
68 | fs.init() | 68 | fs.init() |
@@ -70,7 +70,7 @@ describe("luarocks.fs #unit", function() | |||
70 | runner.init(testing_paths.testrun_dir .. "/luacov.config") | 70 | runner.init(testing_paths.testrun_dir .. "/luacov.config") |
71 | runner.tick = true | 71 | runner.tick = true |
72 | end) | 72 | end) |
73 | 73 | ||
74 | teardown(function() | 74 | teardown(function() |
75 | runner.shutdown() | 75 | runner.shutdown() |
76 | end) | 76 | end) |
@@ -122,10 +122,10 @@ describe("luarocks.fs #unit", function() | |||
122 | end | 122 | end |
123 | end) | 123 | end) |
124 | end) | 124 | end) |
125 | 125 | ||
126 | describe("fs.execute_string", function() | 126 | describe("fs.execute_string", function() |
127 | local tmpdir | 127 | local tmpdir |
128 | 128 | ||
129 | after_each(function() | 129 | after_each(function() |
130 | if tmpdir then | 130 | if tmpdir then |
131 | lfs.rmdir(tmpdir) | 131 | lfs.rmdir(tmpdir) |
@@ -140,7 +140,7 @@ describe("luarocks.fs #unit", function() | |||
140 | assert.falsy(fs.execute_string("invalidcommand")) | 140 | assert.falsy(fs.execute_string("invalidcommand")) |
141 | end) | 141 | end) |
142 | end) | 142 | end) |
143 | 143 | ||
144 | describe("fs.dir_iterator", function() | 144 | describe("fs.dir_iterator", function() |
145 | local tmpfile1 | 145 | local tmpfile1 |
146 | local tmpfile2 | 146 | local tmpfile2 |
@@ -218,7 +218,7 @@ describe("luarocks.fs #unit", function() | |||
218 | end | 218 | end |
219 | end) | 219 | end) |
220 | end) | 220 | end) |
221 | 221 | ||
222 | describe("fs.is_writable", function() | 222 | describe("fs.is_writable", function() |
223 | local tmpfile | 223 | local tmpfile |
224 | local tmpdir | 224 | local tmpdir |
@@ -268,7 +268,7 @@ describe("luarocks.fs #unit", function() | |||
268 | assert.falsy(fs.is_writable("/nonexistent")) | 268 | assert.falsy(fs.is_writable("/nonexistent")) |
269 | end) | 269 | end) |
270 | end) | 270 | end) |
271 | 271 | ||
272 | describe("fs.set_time #unix", function() | 272 | describe("fs.set_time #unix", function() |
273 | local tmpfile | 273 | local tmpfile |
274 | local tmpdir | 274 | local tmpdir |
@@ -787,13 +787,13 @@ describe("luarocks.fs #unit", function() | |||
787 | assert.truthy(exists_file(tmpdir)) | 787 | assert.truthy(exists_file(tmpdir)) |
788 | end) | 788 | end) |
789 | end) | 789 | end) |
790 | 790 | ||
791 | describe("fs.list_dir", function() | 791 | describe("fs.list_dir", function() |
792 | local intfile1 | 792 | local intfile1 |
793 | local intfile2 | 793 | local intfile2 |
794 | local intdir | 794 | local intdir |
795 | local tmpdir | 795 | local tmpdir |
796 | 796 | ||
797 | before_each(function() | 797 | before_each(function() |
798 | if intfile1 then | 798 | if intfile1 then |
799 | os.remove(intfile1) | 799 | os.remove(intfile1) |
@@ -812,7 +812,7 @@ describe("luarocks.fs #unit", function() | |||
812 | tmpdir = nil | 812 | tmpdir = nil |
813 | end | 813 | end |
814 | end) | 814 | end) |
815 | 815 | ||
816 | it("returns a table with the contents of the given directory", function() | 816 | it("returns a table with the contents of the given directory", function() |
817 | tmpdir = get_tmp_path() | 817 | tmpdir = get_tmp_path() |
818 | lfs.mkdir(tmpdir) | 818 | lfs.mkdir(tmpdir) |
@@ -828,18 +828,18 @@ describe("luarocks.fs #unit", function() | |||
828 | assert.truthy(result[2] == "intfile1" or result[2] == "intdir") | 828 | assert.truthy(result[2] == "intfile1" or result[2] == "intdir") |
829 | assert.is_not.same(result[1], result[2]) | 829 | assert.is_not.same(result[1], result[2]) |
830 | end) | 830 | end) |
831 | 831 | ||
832 | it("returns an empty table if the argument is a file", function() | 832 | it("returns an empty table if the argument is a file", function() |
833 | intfile1 = get_tmp_path() | 833 | intfile1 = get_tmp_path() |
834 | create_file(intfile1) | 834 | create_file(intfile1) |
835 | local result = fs.list_dir(intfile1) | 835 | local result = fs.list_dir(intfile1) |
836 | assert.same(#result, 0) | 836 | assert.same(#result, 0) |
837 | end) | 837 | end) |
838 | 838 | ||
839 | it("does nothing if the argument is nonexistent", function() | 839 | it("does nothing if the argument is nonexistent", function() |
840 | assert.same(fs.list_dir("/nonexistent"), {}) | 840 | assert.same(fs.list_dir("/nonexistent"), {}) |
841 | end) | 841 | end) |
842 | 842 | ||
843 | it("does nothing if the argument doesn't have the proper permissions", function() | 843 | it("does nothing if the argument doesn't have the proper permissions", function() |
844 | tmpdir = get_tmp_path() | 844 | tmpdir = get_tmp_path() |
845 | lfs.mkdir(tmpdir) | 845 | lfs.mkdir(tmpdir) |
@@ -1017,13 +1017,13 @@ describe("luarocks.fs #unit", function() | |||
1017 | assert.falsy(exists_file(dstdir .. "/internalfile")) | 1017 | assert.falsy(exists_file(dstdir .. "/internalfile")) |
1018 | end) | 1018 | end) |
1019 | end) | 1019 | end) |
1020 | 1020 | ||
1021 | describe("fs.find", function() | 1021 | describe("fs.find", function() |
1022 | local tmpdir | 1022 | local tmpdir |
1023 | local intdir | 1023 | local intdir |
1024 | local intfile1 | 1024 | local intfile1 |
1025 | local intfile2 | 1025 | local intfile2 |
1026 | 1026 | ||
1027 | after_each(function() | 1027 | after_each(function() |
1028 | if intfile1 then | 1028 | if intfile1 then |
1029 | os.remove(intfile1) | 1029 | os.remove(intfile1) |
@@ -1042,7 +1042,7 @@ describe("luarocks.fs #unit", function() | |||
1042 | tmpdir = nil | 1042 | tmpdir = nil |
1043 | end | 1043 | end |
1044 | end) | 1044 | end) |
1045 | 1045 | ||
1046 | local create_dir_tree = function() | 1046 | local create_dir_tree = function() |
1047 | tmpdir = get_tmp_path() | 1047 | tmpdir = get_tmp_path() |
1048 | lfs.mkdir(tmpdir) | 1048 | lfs.mkdir(tmpdir) |
@@ -1053,7 +1053,7 @@ describe("luarocks.fs #unit", function() | |||
1053 | intfile2 = intdir .. "/intfile2" | 1053 | intfile2 = intdir .. "/intfile2" |
1054 | create_file(intfile2) | 1054 | create_file(intfile2) |
1055 | end | 1055 | end |
1056 | 1056 | ||
1057 | it("returns a table of all the contents in the directory given as argument", function() | 1057 | it("returns a table of all the contents in the directory given as argument", function() |
1058 | create_dir_tree() | 1058 | create_dir_tree() |
1059 | local contents = {} | 1059 | local contents = {} |
@@ -1068,7 +1068,7 @@ describe("luarocks.fs #unit", function() | |||
1068 | assert.same(contents["intdir"], true) | 1068 | assert.same(contents["intdir"], true) |
1069 | assert.same(contents["intdir/intfile2"], true) | 1069 | assert.same(contents["intdir/intfile2"], true) |
1070 | end) | 1070 | end) |
1071 | 1071 | ||
1072 | it("uses the current working directory if the argument is nil", function() | 1072 | it("uses the current working directory if the argument is nil", function() |
1073 | create_dir_tree() | 1073 | create_dir_tree() |
1074 | local olddir = fs.current_dir() | 1074 | local olddir = fs.current_dir() |
@@ -1085,7 +1085,7 @@ describe("luarocks.fs #unit", function() | |||
1085 | assert.same(contents["intfile2"], true) | 1085 | assert.same(contents["intfile2"], true) |
1086 | fs.change_dir(olddir) | 1086 | fs.change_dir(olddir) |
1087 | end) | 1087 | end) |
1088 | 1088 | ||
1089 | it("returns an empty table if the argument is nonexistent", function() | 1089 | it("returns an empty table if the argument is nonexistent", function() |
1090 | local contents = fs.find("/nonexistent") | 1090 | local contents = fs.find("/nonexistent") |
1091 | local count = 0 | 1091 | local count = 0 |
@@ -1094,7 +1094,7 @@ describe("luarocks.fs #unit", function() | |||
1094 | end | 1094 | end |
1095 | assert.same(count, 0) | 1095 | assert.same(count, 0) |
1096 | end) | 1096 | end) |
1097 | 1097 | ||
1098 | it("returns an empty table if the argument is a file", function() | 1098 | it("returns an empty table if the argument is a file", function() |
1099 | intfile1 = get_tmp_path() | 1099 | intfile1 = get_tmp_path() |
1100 | create_file(intfile1) | 1100 | create_file(intfile1) |
@@ -1105,7 +1105,7 @@ describe("luarocks.fs #unit", function() | |||
1105 | end | 1105 | end |
1106 | assert.same(count, 0) | 1106 | assert.same(count, 0) |
1107 | end) | 1107 | end) |
1108 | 1108 | ||
1109 | it("does nothing if the argument doesn't have the proper permissions", function() | 1109 | it("does nothing if the argument doesn't have the proper permissions", function() |
1110 | tmpdir = get_tmp_path() | 1110 | tmpdir = get_tmp_path() |
1111 | lfs.mkdir(tmpdir) | 1111 | lfs.mkdir(tmpdir) |
@@ -1113,12 +1113,12 @@ describe("luarocks.fs #unit", function() | |||
1113 | assert.same(fs.find(tmpdir), {}) | 1113 | assert.same(fs.find(tmpdir), {}) |
1114 | end) | 1114 | end) |
1115 | end) | 1115 | end) |
1116 | 1116 | ||
1117 | describe("fs.move", function() | 1117 | describe("fs.move", function() |
1118 | local srcfile | 1118 | local srcfile |
1119 | local dstfile | 1119 | local dstfile |
1120 | local tmpdir | 1120 | local tmpdir |
1121 | 1121 | ||
1122 | after_each(function() | 1122 | after_each(function() |
1123 | if srcfile then | 1123 | if srcfile then |
1124 | os.remove(srcfile) | 1124 | os.remove(srcfile) |
@@ -1133,7 +1133,7 @@ describe("luarocks.fs #unit", function() | |||
1133 | tmpdir = nil | 1133 | tmpdir = nil |
1134 | end | 1134 | end |
1135 | end) | 1135 | end) |
1136 | 1136 | ||
1137 | it("returns true and moves the source (together with its permissions) to the destination", function() | 1137 | it("returns true and moves the source (together with its permissions) to the destination", function() |
1138 | srcfile = get_tmp_path() | 1138 | srcfile = get_tmp_path() |
1139 | create_file(srcfile) | 1139 | create_file(srcfile) |
@@ -1149,7 +1149,7 @@ describe("luarocks.fs #unit", function() | |||
1149 | assert.same(oldperms, lfs.attributes(dstfile, "permissions")) | 1149 | assert.same(oldperms, lfs.attributes(dstfile, "permissions")) |
1150 | end | 1150 | end |
1151 | end) | 1151 | end) |
1152 | 1152 | ||
1153 | it("returns true and moves the source (with custom permissions) to the destination", function() | 1153 | it("returns true and moves the source (with custom permissions) to the destination", function() |
1154 | srcfile = get_tmp_path() | 1154 | srcfile = get_tmp_path() |
1155 | create_file(srcfile) | 1155 | create_file(srcfile) |
@@ -1161,13 +1161,13 @@ describe("luarocks.fs #unit", function() | |||
1161 | local dstcontents = assert(fd:read("*a")) | 1161 | local dstcontents = assert(fd:read("*a")) |
1162 | assert.same(dstcontents, "foo") | 1162 | assert.same(dstcontents, "foo") |
1163 | end) | 1163 | end) |
1164 | 1164 | ||
1165 | it("returns false and does nothing if the source doesn't exist", function() | 1165 | it("returns false and does nothing if the source doesn't exist", function() |
1166 | dstfile = get_tmp_path() | 1166 | dstfile = get_tmp_path() |
1167 | assert.falsy(fs.move("/nonexistent", dstfile)) | 1167 | assert.falsy(fs.move("/nonexistent", dstfile)) |
1168 | assert.falsy(fs.exists(dstfile)) | 1168 | assert.falsy(fs.exists(dstfile)) |
1169 | end) | 1169 | end) |
1170 | 1170 | ||
1171 | it("returns false and does nothing if the destination already exists", function() | 1171 | it("returns false and does nothing if the destination already exists", function() |
1172 | srcfile = get_tmp_path() | 1172 | srcfile = get_tmp_path() |
1173 | create_file(srcfile) | 1173 | create_file(srcfile) |
@@ -1179,7 +1179,7 @@ describe("luarocks.fs #unit", function() | |||
1179 | local dstcontents = assert(fd:read("*a")) | 1179 | local dstcontents = assert(fd:read("*a")) |
1180 | assert.same(dstcontents, "bar") | 1180 | assert.same(dstcontents, "bar") |
1181 | end) | 1181 | end) |
1182 | 1182 | ||
1183 | it("returns false and does nothing if the destination path doesn't have the proper permissions", function() | 1183 | it("returns false and does nothing if the destination path doesn't have the proper permissions", function() |
1184 | srcfile = get_tmp_path() | 1184 | srcfile = get_tmp_path() |
1185 | create_file(srcfile) | 1185 | create_file(srcfile) |
@@ -1190,17 +1190,17 @@ describe("luarocks.fs #unit", function() | |||
1190 | assert.falsy(fs.exists(tmpdir .. "/dstfile")) | 1190 | assert.falsy(fs.exists(tmpdir .. "/dstfile")) |
1191 | end) | 1191 | end) |
1192 | end) | 1192 | end) |
1193 | 1193 | ||
1194 | describe("fs.is_lua", function() | 1194 | describe("fs.is_lua", function() |
1195 | local tmpfile | 1195 | local tmpfile |
1196 | 1196 | ||
1197 | after_each(function() | 1197 | after_each(function() |
1198 | if tmpfile then | 1198 | if tmpfile then |
1199 | os.remove(tmpfile) | 1199 | os.remove(tmpfile) |
1200 | tmpfile = nil | 1200 | tmpfile = nil |
1201 | end | 1201 | end |
1202 | end) | 1202 | end) |
1203 | 1203 | ||
1204 | it("returns true if the argument is a valid lua script", function() | 1204 | it("returns true if the argument is a valid lua script", function() |
1205 | tmpfile = get_tmp_path() | 1205 | tmpfile = get_tmp_path() |
1206 | create_file(tmpfile, "print(\"foo\")") | 1206 | create_file(tmpfile, "print(\"foo\")") |
@@ -1212,13 +1212,13 @@ describe("luarocks.fs #unit", function() | |||
1212 | create_file(tmpfile, "#!/usr/bin/env lua\n\nprint(\"foo\")") | 1212 | create_file(tmpfile, "#!/usr/bin/env lua\n\nprint(\"foo\")") |
1213 | assert.truthy(fs.is_lua(tmpfile)) | 1213 | assert.truthy(fs.is_lua(tmpfile)) |
1214 | end) | 1214 | end) |
1215 | 1215 | ||
1216 | it("returns false if the argument is not a valid lua script", function() | 1216 | it("returns false if the argument is not a valid lua script", function() |
1217 | tmpfile = os.tmpname() | 1217 | tmpfile = os.tmpname() |
1218 | create_file(tmpfile) | 1218 | create_file(tmpfile) |
1219 | assert.falsy(fs.is_lua(tmpfile)) | 1219 | assert.falsy(fs.is_lua(tmpfile)) |
1220 | end) | 1220 | end) |
1221 | 1221 | ||
1222 | it("returns false if the argument is a valid lua script but doesn't have the proper permissions", function() | 1222 | it("returns false if the argument is a valid lua script but doesn't have the proper permissions", function() |
1223 | tmpfile = get_tmp_path() | 1223 | tmpfile = get_tmp_path() |
1224 | create_file(tmpfile, "print(\"foo\")") | 1224 | create_file(tmpfile, "print(\"foo\")") |
@@ -1281,15 +1281,15 @@ describe("luarocks.fs #unit", function() | |||
1281 | assert.falsy(exists_file(tmpdir)) | 1281 | assert.falsy(exists_file(tmpdir)) |
1282 | end) | 1282 | end) |
1283 | end) | 1283 | end) |
1284 | 1284 | ||
1285 | describe("fs.download #mock", function() | 1285 | describe("fs.download #mock", function() |
1286 | local tmpfile | 1286 | local tmpfile |
1287 | local tmpdir | 1287 | local tmpdir |
1288 | 1288 | ||
1289 | setup(function() | 1289 | setup(function() |
1290 | test_env.mock_server_init() | 1290 | test_env.mock_server_init() |
1291 | end) | 1291 | end) |
1292 | 1292 | ||
1293 | teardown(function() | 1293 | teardown(function() |
1294 | test_env.mock_server_done() | 1294 | test_env.mock_server_done() |
1295 | end) | 1295 | end) |
@@ -1304,7 +1304,7 @@ describe("luarocks.fs #unit", function() | |||
1304 | tmpdir = nil | 1304 | tmpdir = nil |
1305 | end | 1305 | end |
1306 | end) | 1306 | end) |
1307 | 1307 | ||
1308 | it("returns true and fetches the url argument into the specified filename", function() | 1308 | it("returns true and fetches the url argument into the specified filename", function() |
1309 | tmpfile = get_tmp_path() | 1309 | tmpfile = get_tmp_path() |
1310 | assert.truthy(fs.download("http://localhost:8080/file/a_rock.lua", tmpfile)) | 1310 | assert.truthy(fs.download("http://localhost:8080/file/a_rock.lua", tmpfile)) |
@@ -1316,7 +1316,7 @@ describe("luarocks.fs #unit", function() | |||
1316 | fd:close() | 1316 | fd:close() |
1317 | assert.same(downloadcontent, originalcontent) | 1317 | assert.same(downloadcontent, originalcontent) |
1318 | end) | 1318 | end) |
1319 | 1319 | ||
1320 | it("returns true and fetches the url argument into a file whose name matches the basename of the url if the filename argument is not given", function() | 1320 | it("returns true and fetches the url argument into a file whose name matches the basename of the url if the filename argument is not given", function() |
1321 | tmpdir = get_tmp_path() | 1321 | tmpdir = get_tmp_path() |
1322 | lfs.mkdir(tmpdir) | 1322 | lfs.mkdir(tmpdir) |
@@ -1332,33 +1332,33 @@ describe("luarocks.fs #unit", function() | |||
1332 | assert.same(downloadcontent, originalcontent) | 1332 | assert.same(downloadcontent, originalcontent) |
1333 | fs.pop_dir() | 1333 | fs.pop_dir() |
1334 | end) | 1334 | end) |
1335 | 1335 | ||
1336 | it("returns false and does nothing if the url argument contains a nonexistent file", function() | 1336 | it("returns false and does nothing if the url argument contains a nonexistent file", function() |
1337 | tmpfile = get_tmp_path() | 1337 | tmpfile = get_tmp_path() |
1338 | assert.falsy(fs.download("http://localhost:8080/file/nonexistent", tmpfile)) | 1338 | assert.falsy(fs.download("http://localhost:8080/file/nonexistent", tmpfile)) |
1339 | end) | 1339 | end) |
1340 | 1340 | ||
1341 | it("returns false and does nothing if the url argument is invalid", function() | 1341 | it("returns false and does nothing if the url argument is invalid", function() |
1342 | assert.falsy(fs.download("invalidurl")) | 1342 | assert.falsy(fs.download("invalidurl")) |
1343 | end) | 1343 | end) |
1344 | end) | 1344 | end) |
1345 | 1345 | ||
1346 | describe("fs.zip", function() | 1346 | describe("fs.zip", function() |
1347 | local tmpdir | 1347 | local tmpdir |
1348 | local olddir | 1348 | local olddir |
1349 | 1349 | ||
1350 | before_each(function() | 1350 | before_each(function() |
1351 | olddir = lfs.currentdir() | 1351 | olddir = lfs.currentdir() |
1352 | tmpdir = get_tmp_path() | 1352 | tmpdir = get_tmp_path() |
1353 | lfs.mkdir(tmpdir) | 1353 | lfs.mkdir(tmpdir) |
1354 | chdir(tmpdir) | 1354 | chdir(tmpdir) |
1355 | 1355 | ||
1356 | write_file("file1", "content1", finally) | 1356 | write_file("file1", "content1", finally) |
1357 | write_file("file2", "content2", finally) | 1357 | write_file("file2", "content2", finally) |
1358 | lfs.mkdir("dir") | 1358 | lfs.mkdir("dir") |
1359 | write_file("dir/file3", "content3", finally) | 1359 | write_file("dir/file3", "content3", finally) |
1360 | end) | 1360 | end) |
1361 | 1361 | ||
1362 | after_each(function() | 1362 | after_each(function() |
1363 | if olddir then | 1363 | if olddir then |
1364 | chdir(olddir) | 1364 | chdir(olddir) |
@@ -1368,12 +1368,12 @@ describe("luarocks.fs #unit", function() | |||
1368 | end | 1368 | end |
1369 | end | 1369 | end |
1370 | end) | 1370 | end) |
1371 | 1371 | ||
1372 | it("returns true and creates a zip archive of the given files", function() | 1372 | it("returns true and creates a zip archive of the given files", function() |
1373 | assert.truthy(fs.zip("archive.zip", "file1", "file2", "dir")) | 1373 | assert.truthy(fs.zip("archive.zip", "file1", "file2", "dir")) |
1374 | assert.truthy(exists_file("archive.zip")) | 1374 | assert.truthy(exists_file("archive.zip")) |
1375 | end) | 1375 | end) |
1376 | 1376 | ||
1377 | it("returns false and does nothing if the files specified in the arguments are invalid", function() | 1377 | it("returns false and does nothing if the files specified in the arguments are invalid", function() |
1378 | assert.falsy(fs.zip("archive.zip", "nonexistent")) | 1378 | assert.falsy(fs.zip("archive.zip", "nonexistent")) |
1379 | assert.falsy(exists_file("nonexistent")) | 1379 | assert.falsy(exists_file("nonexistent")) |
@@ -1381,7 +1381,7 @@ describe("luarocks.fs #unit", function() | |||
1381 | end) | 1381 | end) |
1382 | 1382 | ||
1383 | describe("fs.bunzip2", function() | 1383 | describe("fs.bunzip2", function() |
1384 | 1384 | ||
1385 | it("uncompresses a .bz2 file", function() | 1385 | it("uncompresses a .bz2 file", function() |
1386 | local input = testing_paths.fixtures_dir .. "/abc.bz2" | 1386 | local input = testing_paths.fixtures_dir .. "/abc.bz2" |
1387 | local output = os.tmpname() | 1387 | local output = os.tmpname() |
@@ -1393,25 +1393,25 @@ describe("luarocks.fs #unit", function() | |||
1393 | local abc = ("a"):rep(100000)..("b"):rep(100000)..("c"):rep(100000) | 1393 | local abc = ("a"):rep(100000)..("b"):rep(100000)..("c"):rep(100000) |
1394 | assert.same(abc, content) | 1394 | assert.same(abc, content) |
1395 | end) | 1395 | end) |
1396 | 1396 | ||
1397 | end) | 1397 | end) |
1398 | 1398 | ||
1399 | describe("fs.unzip", function() | 1399 | describe("fs.unzip", function() |
1400 | local tmpdir | 1400 | local tmpdir |
1401 | local olddir | 1401 | local olddir |
1402 | 1402 | ||
1403 | before_each(function() | 1403 | before_each(function() |
1404 | olddir = lfs.currentdir() | 1404 | olddir = lfs.currentdir() |
1405 | tmpdir = get_tmp_path() | 1405 | tmpdir = get_tmp_path() |
1406 | lfs.mkdir(tmpdir) | 1406 | lfs.mkdir(tmpdir) |
1407 | chdir(tmpdir) | 1407 | chdir(tmpdir) |
1408 | 1408 | ||
1409 | write_file("file1", "content1", finally) | 1409 | write_file("file1", "content1", finally) |
1410 | write_file("file2", "content2", finally) | 1410 | write_file("file2", "content2", finally) |
1411 | lfs.mkdir("dir") | 1411 | lfs.mkdir("dir") |
1412 | write_file("dir/file3", "content3", finally) | 1412 | write_file("dir/file3", "content3", finally) |
1413 | end) | 1413 | end) |
1414 | 1414 | ||
1415 | after_each(function() | 1415 | after_each(function() |
1416 | if olddir then | 1416 | if olddir then |
1417 | chdir(olddir) | 1417 | chdir(olddir) |
@@ -1421,33 +1421,33 @@ describe("luarocks.fs #unit", function() | |||
1421 | end | 1421 | end |
1422 | end | 1422 | end |
1423 | end) | 1423 | end) |
1424 | 1424 | ||
1425 | it("returns true and unzips the given zip archive", function() | 1425 | it("returns true and unzips the given zip archive", function() |
1426 | assert.truthy(fs.zip("archive.zip", "file1", "file2", "dir")) | 1426 | assert.truthy(fs.zip("archive.zip", "file1", "file2", "dir")) |
1427 | os.remove("file1") | 1427 | os.remove("file1") |
1428 | os.remove("file2") | 1428 | os.remove("file2") |
1429 | lfs.rmdir("dir") | 1429 | lfs.rmdir("dir") |
1430 | 1430 | ||
1431 | assert.truthy(fs.unzip("archive.zip")) | 1431 | assert.truthy(fs.unzip("archive.zip")) |
1432 | assert.truthy(exists_file("file1")) | 1432 | assert.truthy(exists_file("file1")) |
1433 | assert.truthy(exists_file("file2")) | 1433 | assert.truthy(exists_file("file2")) |
1434 | assert.truthy(exists_file("dir/file3")) | 1434 | assert.truthy(exists_file("dir/file3")) |
1435 | 1435 | ||
1436 | local fd | 1436 | local fd |
1437 | 1437 | ||
1438 | fd = assert(io.open("file1", "r")) | 1438 | fd = assert(io.open("file1", "r")) |
1439 | assert.same(fd:read("*a"), "content1") | 1439 | assert.same(fd:read("*a"), "content1") |
1440 | fd:close() | 1440 | fd:close() |
1441 | 1441 | ||
1442 | fd = assert(io.open("file2", "r")) | 1442 | fd = assert(io.open("file2", "r")) |
1443 | assert.same(fd:read("*a"), "content2") | 1443 | assert.same(fd:read("*a"), "content2") |
1444 | fd:close() | 1444 | fd:close() |
1445 | 1445 | ||
1446 | fd = assert(io.open("dir/file3", "r")) | 1446 | fd = assert(io.open("dir/file3", "r")) |
1447 | assert.same(fd:read("*a"), "content3") | 1447 | assert.same(fd:read("*a"), "content3") |
1448 | fd:close() | 1448 | fd:close() |
1449 | end) | 1449 | end) |
1450 | 1450 | ||
1451 | it("does nothing if the given archive is invalid", function() | 1451 | it("does nothing if the given archive is invalid", function() |
1452 | assert.falsy(fs.unzip("archive.zip")) | 1452 | assert.falsy(fs.unzip("archive.zip")) |
1453 | end) | 1453 | end) |
@@ -1456,14 +1456,14 @@ describe("luarocks.fs #unit", function() | |||
1456 | describe("fs.wrap_script", function() | 1456 | describe("fs.wrap_script", function() |
1457 | local tmpdir | 1457 | local tmpdir |
1458 | local olddir | 1458 | local olddir |
1459 | 1459 | ||
1460 | before_each(function() | 1460 | before_each(function() |
1461 | olddir = lfs.currentdir() | 1461 | olddir = lfs.currentdir() |
1462 | tmpdir = get_tmp_path() | 1462 | tmpdir = get_tmp_path() |
1463 | lfs.mkdir(tmpdir) | 1463 | lfs.mkdir(tmpdir) |
1464 | chdir(tmpdir) | 1464 | chdir(tmpdir) |
1465 | end) | 1465 | end) |
1466 | 1466 | ||
1467 | after_each(function() | 1467 | after_each(function() |
1468 | if olddir then | 1468 | if olddir then |
1469 | chdir(olddir) | 1469 | chdir(olddir) |
@@ -1484,20 +1484,20 @@ describe("luarocks.fs #unit", function() | |||
1484 | assert.same("Hello World", data) | 1484 | assert.same("Hello World", data) |
1485 | end) | 1485 | end) |
1486 | end) | 1486 | end) |
1487 | 1487 | ||
1488 | describe("fs.copy_binary", function() | 1488 | describe("fs.copy_binary", function() |
1489 | local tmpdir | 1489 | local tmpdir |
1490 | local olddir | 1490 | local olddir |
1491 | 1491 | ||
1492 | before_each(function() | 1492 | before_each(function() |
1493 | olddir = lfs.currentdir() | 1493 | olddir = lfs.currentdir() |
1494 | tmpdir = get_tmp_path() | 1494 | tmpdir = get_tmp_path() |
1495 | lfs.mkdir(tmpdir) | 1495 | lfs.mkdir(tmpdir) |
1496 | chdir(tmpdir) | 1496 | chdir(tmpdir) |
1497 | 1497 | ||
1498 | write_file("test.exe", "", finally) | 1498 | write_file("test.exe", "", finally) |
1499 | end) | 1499 | end) |
1500 | 1500 | ||
1501 | after_each(function() | 1501 | after_each(function() |
1502 | if olddir then | 1502 | if olddir then |
1503 | chdir(olddir) | 1503 | chdir(olddir) |
@@ -1506,7 +1506,7 @@ describe("luarocks.fs #unit", function() | |||
1506 | end | 1506 | end |
1507 | end | 1507 | end |
1508 | end) | 1508 | end) |
1509 | 1509 | ||
1510 | it("returns true and copies the given binary file to the file specified in the dest argument", function() | 1510 | it("returns true and copies the given binary file to the file specified in the dest argument", function() |
1511 | assert.truthy(fs.copy_binary("test.exe", lfs.currentdir() .. "/copy.exe")) | 1511 | assert.truthy(fs.copy_binary("test.exe", lfs.currentdir() .. "/copy.exe")) |
1512 | assert.truthy(exists_file("copy.exe")) | 1512 | assert.truthy(exists_file("copy.exe")) |
@@ -1519,17 +1519,17 @@ describe("luarocks.fs #unit", function() | |||
1519 | fd:close() | 1519 | fd:close() |
1520 | end | 1520 | end |
1521 | end) | 1521 | end) |
1522 | 1522 | ||
1523 | it("returns false and does nothing if the source file is invalid", function() | 1523 | it("returns false and does nothing if the source file is invalid", function() |
1524 | assert.falsy(fs.copy_binary("invalid.exe", "copy.exe")) | 1524 | assert.falsy(fs.copy_binary("invalid.exe", "copy.exe")) |
1525 | end) | 1525 | end) |
1526 | end) | 1526 | end) |
1527 | 1527 | ||
1528 | describe("fs.modules", function() | 1528 | describe("fs.modules", function() |
1529 | local tmpdir | 1529 | local tmpdir |
1530 | local olddir | 1530 | local olddir |
1531 | local oldpath | 1531 | local oldpath |
1532 | 1532 | ||
1533 | before_each(function() | 1533 | before_each(function() |
1534 | olddir = lfs.currentdir() | 1534 | olddir = lfs.currentdir() |
1535 | tmpdir = get_tmp_path() | 1535 | tmpdir = get_tmp_path() |
@@ -1547,7 +1547,7 @@ describe("luarocks.fs #unit", function() | |||
1547 | oldpath = package.path | 1547 | oldpath = package.path |
1548 | package.path = package.path .. tmpdir .. "/?.lua;" | 1548 | package.path = package.path .. tmpdir .. "/?.lua;" |
1549 | end) | 1549 | end) |
1550 | 1550 | ||
1551 | after_each(function() | 1551 | after_each(function() |
1552 | if olddir then | 1552 | if olddir then |
1553 | chdir(olddir) | 1553 | chdir(olddir) |
@@ -1583,7 +1583,7 @@ describe("luarocks.fs #unit", function() | |||
1583 | end) | 1583 | end) |
1584 | 1584 | ||
1585 | describe("#unix fs._unix_rwx_to_number", function() | 1585 | describe("#unix fs._unix_rwx_to_number", function() |
1586 | 1586 | ||
1587 | it("converts permissions in rwx notation to numeric ones", function() | 1587 | it("converts permissions in rwx notation to numeric ones", function() |
1588 | assert.same(tonumber("0644", 8), fs._unix_rwx_to_number("rw-r--r--")) | 1588 | assert.same(tonumber("0644", 8), fs._unix_rwx_to_number("rw-r--r--")) |
1589 | assert.same(tonumber("0755", 8), fs._unix_rwx_to_number("rwxr-xr-x")) | 1589 | assert.same(tonumber("0755", 8), fs._unix_rwx_to_number("rwxr-xr-x")) |
diff --git a/spec/fun_spec.lua b/spec/fun_spec.lua index b3589c12..9844ec27 100644 --- a/spec/fun_spec.lua +++ b/spec/fun_spec.lua | |||
@@ -6,17 +6,17 @@ local fun = require("luarocks.fun") | |||
6 | 6 | ||
7 | describe("luarocks.fun #unit", function() | 7 | describe("luarocks.fun #unit", function() |
8 | local runner | 8 | local runner |
9 | 9 | ||
10 | setup(function() | 10 | setup(function() |
11 | runner = require("luacov.runner") | 11 | runner = require("luacov.runner") |
12 | runner.init(testing_paths.testrun_dir .. "/luacov.config") | 12 | runner.init(testing_paths.testrun_dir .. "/luacov.config") |
13 | runner.tick = true | 13 | runner.tick = true |
14 | end) | 14 | end) |
15 | 15 | ||
16 | teardown(function() | 16 | teardown(function() |
17 | runner.shutdown() | 17 | runner.shutdown() |
18 | end) | 18 | end) |
19 | 19 | ||
20 | describe("fun.concat", function() | 20 | describe("fun.concat", function() |
21 | it("returns the concatenation of the two tables given as arguments", function() | 21 | it("returns the concatenation of the two tables given as arguments", function() |
22 | local t1, t2 | 22 | local t1, t2 |
diff --git a/spec/help_spec.lua b/spec/help_spec.lua index 70dc5a7e..08ce87a9 100644 --- a/spec/help_spec.lua +++ b/spec/help_spec.lua | |||
@@ -16,11 +16,11 @@ describe("luarocks help #integration", function() | |||
16 | it("invalid argument", function() | 16 | it("invalid argument", function() |
17 | assert.is_false(run.luarocks_bool("help invalid")) | 17 | assert.is_false(run.luarocks_bool("help invalid")) |
18 | end) | 18 | end) |
19 | 19 | ||
20 | it("config", function() | 20 | it("config", function() |
21 | assert.is_true(run.luarocks_bool("help config")) | 21 | assert.is_true(run.luarocks_bool("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(test_env.quiet("help"))) | 25 | assert.is_true(run.luarocks_admin_bool(test_env.quiet("help"))) |
26 | end) | 26 | end) |
diff --git a/spec/init_spec.lua b/spec/init_spec.lua index 4a9c9ab7..3bde313a 100644 --- a/spec/init_spec.lua +++ b/spec/init_spec.lua | |||
@@ -19,7 +19,7 @@ describe("luarocks init #integration", function() | |||
19 | local myproject = tmpdir .. "/myproject" | 19 | local myproject = tmpdir .. "/myproject" |
20 | lfs.mkdir(myproject) | 20 | lfs.mkdir(myproject) |
21 | lfs.chdir(myproject) | 21 | lfs.chdir(myproject) |
22 | 22 | ||
23 | assert(run.luarocks("init")) | 23 | assert(run.luarocks("init")) |
24 | if is_win then | 24 | if is_win then |
25 | assert.truthy(lfs.attributes(myproject .. "/lua.bat")) | 25 | assert.truthy(lfs.attributes(myproject .. "/lua.bat")) |
@@ -41,7 +41,7 @@ describe("luarocks init #integration", function() | |||
41 | local myproject = tmpdir .. "/myproject" | 41 | local myproject = tmpdir .. "/myproject" |
42 | lfs.mkdir(myproject) | 42 | lfs.mkdir(myproject) |
43 | lfs.chdir(myproject) | 43 | lfs.chdir(myproject) |
44 | 44 | ||
45 | assert(run.luarocks("init")) | 45 | assert(run.luarocks("init")) |
46 | if is_win then | 46 | if is_win then |
47 | assert.truthy(lfs.attributes(myproject .. "/lua.bat")) | 47 | assert.truthy(lfs.attributes(myproject .. "/lua.bat")) |
@@ -74,18 +74,18 @@ describe("luarocks init #integration", function() | |||
74 | end | 74 | end |
75 | end, finally) | 75 | end, finally) |
76 | end) | 76 | end) |
77 | 77 | ||
78 | it("with given arguments", function() | 78 | it("with given arguments", function() |
79 | test_env.run_in_tmp(function(tmpdir) | 79 | test_env.run_in_tmp(function(tmpdir) |
80 | local myproject = tmpdir .. "/myproject" | 80 | local myproject = tmpdir .. "/myproject" |
81 | lfs.mkdir(myproject) | 81 | lfs.mkdir(myproject) |
82 | lfs.chdir(myproject) | 82 | lfs.chdir(myproject) |
83 | 83 | ||
84 | assert(run.luarocks("init customname 1.0")) | 84 | assert(run.luarocks("init customname 1.0")) |
85 | assert.truthy(lfs.attributes(myproject .. "/customname-1.0-1.rockspec")) | 85 | assert.truthy(lfs.attributes(myproject .. "/customname-1.0-1.rockspec")) |
86 | end, finally) | 86 | end, finally) |
87 | end) | 87 | end) |
88 | 88 | ||
89 | it("with --lua-versions", function() | 89 | it("with --lua-versions", function() |
90 | test_env.run_in_tmp(function(tmpdir) | 90 | test_env.run_in_tmp(function(tmpdir) |
91 | local myproject = tmpdir .. "/myproject" | 91 | local myproject = tmpdir .. "/myproject" |
@@ -107,14 +107,14 @@ describe("luarocks init #integration", function() | |||
107 | local myproject = tmpdir .. "/myproject" | 107 | local myproject = tmpdir .. "/myproject" |
108 | copy_dir(testing_paths.fixtures_dir .. "/git_repo", myproject) | 108 | copy_dir(testing_paths.fixtures_dir .. "/git_repo", myproject) |
109 | lfs.chdir(myproject) | 109 | lfs.chdir(myproject) |
110 | 110 | ||
111 | assert(run.luarocks("init")) | 111 | assert(run.luarocks("init")) |
112 | local fd = assert(io.open(myproject .. "/myproject-dev-1.rockspec", "r")) | 112 | local fd = assert(io.open(myproject .. "/myproject-dev-1.rockspec", "r")) |
113 | local content = assert(fd:read("*a")) | 113 | local content = assert(fd:read("*a")) |
114 | assert.truthy(content:find("summary = \"Test repo\"")) | 114 | assert.truthy(content:find("summary = \"Test repo\"")) |
115 | assert.truthy(content:find("detailed = .+Test repo.+")) | 115 | assert.truthy(content:find("detailed = .+Test repo.+")) |
116 | assert.truthy(content:find("license = \"MIT\"")) | 116 | assert.truthy(content:find("license = \"MIT\"")) |
117 | 117 | ||
118 | fd = assert(io.open(myproject .. "/.gitignore", "r")) | 118 | fd = assert(io.open(myproject .. "/.gitignore", "r")) |
119 | content = assert(fd:read("*a")) | 119 | content = assert(fd:read("*a")) |
120 | assert.truthy(content:find("/foo")) | 120 | assert.truthy(content:find("/foo")) |
@@ -155,17 +155,17 @@ describe("luarocks init #integration", function() | |||
155 | 155 | ||
156 | os.remove(rockspec_filename) | 156 | os.remove(rockspec_filename) |
157 | os.remove("my_dependency-1.0-1.rockspec") | 157 | os.remove("my_dependency-1.0-1.rockspec") |
158 | 158 | ||
159 | -- re-run init | 159 | -- re-run init |
160 | assert(run.luarocks("init")) | 160 | assert(run.luarocks("init")) |
161 | 161 | ||
162 | -- file is recreated | 162 | -- file is recreated |
163 | assert.truthy(lfs.attributes(rockspec_filename)) | 163 | assert.truthy(lfs.attributes(rockspec_filename)) |
164 | 164 | ||
165 | local fd = assert(io.open(rockspec_filename, "rb")) | 165 | local fd = assert(io.open(rockspec_filename, "rb")) |
166 | local rockspec = assert(fd:read("*a")) | 166 | local rockspec = assert(fd:read("*a")) |
167 | fd:close() | 167 | fd:close() |
168 | 168 | ||
169 | assert.no.match("my_dependency", rockspec, 1, true) | 169 | assert.no.match("my_dependency", rockspec, 1, true) |
170 | assert.no.match("config", rockspec, 1, true) | 170 | assert.no.match("config", rockspec, 1, true) |
171 | 171 | ||
diff --git a/spec/install_spec.lua b/spec/install_spec.lua index 78b4b28d..9bc94eb6 100644 --- a/spec/install_spec.lua +++ b/spec/install_spec.lua | |||
@@ -46,7 +46,7 @@ describe("luarocks install #integration", function() | |||
46 | 46 | ||
47 | it("fails invalid patch", function() | 47 | it("fails invalid patch", function() |
48 | assert.is_false(run.luarocks_bool("install " .. testing_paths.fixtures_dir .. "/invalid_patch-0.1-1.rockspec")) | 48 | assert.is_false(run.luarocks_bool("install " .. testing_paths.fixtures_dir .. "/invalid_patch-0.1-1.rockspec")) |
49 | end) | 49 | end) |
50 | 50 | ||
51 | it("fails invalid rock", function() | 51 | it("fails invalid rock", function() |
52 | assert.is_false(run.luarocks_bool("install \"invalid.rock\" ")) | 52 | assert.is_false(run.luarocks_bool("install \"invalid.rock\" ")) |
@@ -101,7 +101,7 @@ describe("luarocks install #integration", function() | |||
101 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/wsapi/1.6-1/doc")) | 101 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/wsapi/1.6-1/doc")) |
102 | end) | 102 | end) |
103 | end) | 103 | end) |
104 | 104 | ||
105 | describe("#namespaces", function() | 105 | describe("#namespaces", function() |
106 | it("installs a namespaced package from the command-line", function() | 106 | it("installs a namespaced package from the command-line", function() |
107 | assert(run.luarocks_bool("install a_user/a_rock --server=" .. testing_paths.fixtures_dir .. "/a_repo" )) | 107 | assert(run.luarocks_bool("install a_user/a_rock --server=" .. testing_paths.fixtures_dir .. "/a_repo" )) |
@@ -191,7 +191,7 @@ describe("luarocks install #integration", function() | |||
191 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/sailor/blank-app/.htaccess")) | 191 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/sailor/blank-app/.htaccess")) |
192 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/sailor/blank-app/.htaccess~")) | 192 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/sailor/blank-app/.htaccess~")) |
193 | end) | 193 | end) |
194 | 194 | ||
195 | it("only-deps of luasocket packed rock", function() | 195 | it("only-deps of luasocket packed rock", function() |
196 | assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket 3.0rc1-2")) | 196 | assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket 3.0rc1-2")) |
197 | local output = run.luarocks("install --only-deps " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock") | 197 | local output = run.luarocks("install --only-deps " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock") |
@@ -256,20 +256,20 @@ describe("luarocks install #integration", function() | |||
256 | end) | 256 | end) |
257 | 257 | ||
258 | describe("New install functionality based on pull request 552", function() | 258 | describe("New install functionality based on pull request 552", function() |
259 | it("break dependencies warning", function() | 259 | it("break dependencies warning", function() |
260 | assert.is_true(run.luarocks_bool("install say 1.2")) | 260 | assert.is_true(run.luarocks_bool("install say 1.2")) |
261 | assert.is_true(run.luarocks_bool("install luassert")) | 261 | assert.is_true(run.luarocks_bool("install luassert")) |
262 | assert.is_true(run.luarocks_bool("install say 1.0")) | 262 | assert.is_true(run.luarocks_bool("install say 1.0")) |
263 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/say/1.2-1")) | 263 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/say/1.2-1")) |
264 | end) | 264 | end) |
265 | it("break dependencies force", function() | 265 | it("break dependencies force", function() |
266 | assert.is_true(run.luarocks_bool("install say 1.2")) | 266 | assert.is_true(run.luarocks_bool("install say 1.2")) |
267 | assert.is_true(run.luarocks_bool("install luassert")) | 267 | assert.is_true(run.luarocks_bool("install luassert")) |
268 | local output = run.luarocks("install --force say 1.0") | 268 | local output = run.luarocks("install --force say 1.0") |
269 | assert.is.truthy(output:find("Checking stability of dependencies")) | 269 | assert.is.truthy(output:find("Checking stability of dependencies")) |
270 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/say/1.2-1")) | 270 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/say/1.2-1")) |
271 | end) | 271 | end) |
272 | it("break dependencies force fast", function() | 272 | it("break dependencies force fast", function() |
273 | assert.is_true(run.luarocks_bool("install say 1.2")) | 273 | assert.is_true(run.luarocks_bool("install say 1.2")) |
274 | assert.is_true(run.luarocks_bool("install luassert")) | 274 | assert.is_true(run.luarocks_bool("install luassert")) |
275 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/say/1.2-1")) | 275 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/say/1.2-1")) |
@@ -337,7 +337,7 @@ describe("luarocks install #integration", function() | |||
337 | setup(function() | 337 | setup(function() |
338 | git = git_repo.start() | 338 | git = git_repo.start() |
339 | end) | 339 | end) |
340 | 340 | ||
341 | teardown(function() | 341 | teardown(function() |
342 | if git then | 342 | if git then |
343 | git:stop() | 343 | git:stop() |
diff --git a/spec/lint_spec.lua b/spec/lint_spec.lua index 75774061..ff7a03e9 100644 --- a/spec/lint_spec.lua +++ b/spec/lint_spec.lua | |||
@@ -1,7 +1,6 @@ | |||
1 | local test_env = require("spec.util.test_env") | 1 | local test_env = require("spec.util.test_env") |
2 | local run = test_env.run | 2 | local run = test_env.run |
3 | local get_tmp_path = test_env.get_tmp_path | 3 | local get_tmp_path = test_env.get_tmp_path |
4 | local testing_paths = test_env.testing_paths | ||
5 | local write_file = test_env.write_file | 4 | local write_file = test_env.write_file |
6 | 5 | ||
7 | test_env.unload_luarocks() | 6 | test_env.unload_luarocks() |
@@ -12,7 +11,7 @@ local extra_rocks = { | |||
12 | } | 11 | } |
13 | 12 | ||
14 | describe("luarocks lint #integration", function() | 13 | describe("luarocks lint #integration", function() |
15 | 14 | ||
16 | before_each(function() | 15 | before_each(function() |
17 | test_env.setup_specs(extra_rocks) | 16 | test_env.setup_specs(extra_rocks) |
18 | end) | 17 | end) |
@@ -24,25 +23,25 @@ describe("luarocks lint #integration", function() | |||
24 | it("invalid argument", function() | 23 | it("invalid argument", function() |
25 | assert.is_false(run.luarocks_bool("lint invalid")) | 24 | assert.is_false(run.luarocks_bool("lint invalid")) |
26 | end) | 25 | end) |
27 | 26 | ||
28 | it("OK", function() | 27 | it("OK", function() |
29 | assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) | 28 | assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) |
30 | local output = run.luarocks("lint validate-args-1.5.4-1.rockspec") | 29 | local output = run.luarocks("lint validate-args-1.5.4-1.rockspec") |
31 | assert.are.same(output, "") | 30 | assert.are.same(output, "") |
32 | assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) | 31 | assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) |
33 | end) | 32 | end) |
34 | 33 | ||
35 | describe("mismatch set", function() | 34 | describe("mismatch set", function() |
36 | local tmpdir | 35 | local tmpdir |
37 | local olddir | 36 | local olddir |
38 | 37 | ||
39 | before_each(function() | 38 | before_each(function() |
40 | tmpdir = get_tmp_path() | 39 | tmpdir = get_tmp_path() |
41 | olddir = lfs.currentdir() | 40 | olddir = lfs.currentdir() |
42 | lfs.mkdir(tmpdir) | 41 | lfs.mkdir(tmpdir) |
43 | lfs.chdir(tmpdir) | 42 | lfs.chdir(tmpdir) |
44 | end) | 43 | end) |
45 | 44 | ||
46 | after_each(function() | 45 | after_each(function() |
47 | if olddir then | 46 | if olddir then |
48 | lfs.chdir(olddir) | 47 | lfs.chdir(olddir) |
@@ -51,7 +50,7 @@ describe("luarocks lint #integration", function() | |||
51 | end | 50 | end |
52 | end | 51 | end |
53 | end) | 52 | end) |
54 | 53 | ||
55 | it("mismatch string", function() | 54 | it("mismatch string", function() |
56 | write_file("type_mismatch_string-1.0-1.rockspec", [[ | 55 | write_file("type_mismatch_string-1.0-1.rockspec", [[ |
57 | package="type_mismatch_version" | 56 | package="type_mismatch_version" |
@@ -59,7 +58,7 @@ describe("luarocks lint #integration", function() | |||
59 | ]], finally) | 58 | ]], finally) |
60 | assert.is_false(run.luarocks_bool("lint type_mismatch_string-1.0-1.rockspec")) | 59 | assert.is_false(run.luarocks_bool("lint type_mismatch_string-1.0-1.rockspec")) |
61 | end) | 60 | end) |
62 | 61 | ||
63 | it("mismatch version", function() | 62 | it("mismatch version", function() |
64 | write_file("type_mismatch_version-1.0-1.rockspec", [[ | 63 | write_file("type_mismatch_version-1.0-1.rockspec", [[ |
65 | package="type_mismatch_version" | 64 | package="type_mismatch_version" |
@@ -67,7 +66,7 @@ describe("luarocks lint #integration", function() | |||
67 | ]], finally) | 66 | ]], finally) |
68 | assert.is_false(run.luarocks_bool("lint type_mismatch_version-1.0-1.rockspec")) | 67 | assert.is_false(run.luarocks_bool("lint type_mismatch_version-1.0-1.rockspec")) |
69 | end) | 68 | end) |
70 | 69 | ||
71 | it("mismatch table", function() | 70 | it("mismatch table", function() |
72 | write_file("type_mismatch_table-1.0-1.rockspec", [[ | 71 | write_file("type_mismatch_table-1.0-1.rockspec", [[ |
73 | package="type_mismatch_table" | 72 | package="type_mismatch_table" |
@@ -77,7 +76,7 @@ describe("luarocks lint #integration", function() | |||
77 | ]], finally) | 76 | ]], finally) |
78 | assert.is_false(run.luarocks_bool("lint type_mismatch_table-1.0-1.rockspec")) | 77 | assert.is_false(run.luarocks_bool("lint type_mismatch_table-1.0-1.rockspec")) |
79 | end) | 78 | end) |
80 | 79 | ||
81 | it("mismatch no build table", function() | 80 | it("mismatch no build table", function() |
82 | write_file("no_build_table-1.0-1.rockspec", [[ | 81 | write_file("no_build_table-1.0-1.rockspec", [[ |
83 | package = "no_build_table" | 82 | package = "no_build_table" |
diff --git a/spec/list_spec.lua b/spec/list_spec.lua index 20af7164..a3580094 100644 --- a/spec/list_spec.lua +++ b/spec/list_spec.lua | |||
@@ -37,7 +37,7 @@ describe("luarocks list #integration", function() | |||
37 | assert.is.truthy(output:find("say")) | 37 | assert.is.truthy(output:find("say")) |
38 | assert.matches("1.0-1 < ", output, 1, true) | 38 | assert.matches("1.0-1 < ", output, 1, true) |
39 | end) | 39 | end) |
40 | 40 | ||
41 | it("invalid tree", function() | 41 | it("invalid tree", function() |
42 | local output = run.luarocks("--tree=/some/invalid/tree list") | 42 | local output = run.luarocks("--tree=/some/invalid/tree list") |
43 | assert(output:find("Rocks installed for Lua "..test_env.lua_version.." in /some/invalid/tree", 1, true)) | 43 | assert(output:find("Rocks installed for Lua "..test_env.lua_version.." in /some/invalid/tree", 1, true)) |
diff --git a/spec/make_spec.lua b/spec/make_spec.lua index c9410cce..791eeb89 100644 --- a/spec/make_spec.lua +++ b/spec/make_spec.lua | |||
@@ -38,7 +38,7 @@ describe("luarocks make #integration", function() | |||
38 | test_env.remove_dir("luasocket-3.0rc1-2") | 38 | test_env.remove_dir("luasocket-3.0rc1-2") |
39 | os.remove("luasocket-3.0rc1-2.src.rock") | 39 | os.remove("luasocket-3.0rc1-2.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 3.0rc1-2")) |
44 | assert.is_true(run.luarocks_bool("unpack luasocket-3.0rc1-2.src.rock")) | 44 | assert.is_true(run.luarocks_bool("unpack luasocket-3.0rc1-2.src.rock")) |
@@ -85,13 +85,13 @@ describe("luarocks make #integration", function() | |||
85 | assert.is_true(run.luarocks_bool("unpack lxsh-0.8.6-2.src.rock")) | 85 | assert.is_true(run.luarocks_bool("unpack lxsh-0.8.6-2.src.rock")) |
86 | assert.is_true(lfs.chdir("lxsh-0.8.6-2/lxsh-0.8.6-1/")) | 86 | assert.is_true(lfs.chdir("lxsh-0.8.6-2/lxsh-0.8.6-1/")) |
87 | end) | 87 | end) |
88 | 88 | ||
89 | -- delete downloaded and unpacked files | 89 | -- delete downloaded and unpacked files |
90 | after_each(function() | 90 | after_each(function() |
91 | assert(lfs.chdir(testing_paths.testrun_dir)) | 91 | assert(lfs.chdir(testing_paths.testrun_dir)) |
92 | test_env.remove_dir("lxsh-0.8.6-2") | 92 | test_env.remove_dir("lxsh-0.8.6-2") |
93 | assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) | 93 | assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) |
94 | end) | 94 | end) |
95 | 95 | ||
96 | it("default rockspec", function() | 96 | it("default rockspec", function() |
97 | assert.is_true(run.luarocks_bool("new_version lxsh-0.8.6-2.rockspec")) | 97 | assert.is_true(run.luarocks_bool("new_version lxsh-0.8.6-2.rockspec")) |
@@ -105,14 +105,14 @@ describe("luarocks make #integration", function() | |||
105 | finally(function() | 105 | finally(function() |
106 | os.remove("rockspec") | 106 | os.remove("rockspec") |
107 | end) | 107 | end) |
108 | 108 | ||
109 | test_env.copy("lxsh-0.8.6-2.rockspec", "rockspec") | 109 | test_env.copy("lxsh-0.8.6-2.rockspec", "rockspec") |
110 | assert.is_true(run.luarocks_bool("make")) | 110 | assert.is_true(run.luarocks_bool("make")) |
111 | 111 | ||
112 | assert.is_true(run.luarocks_bool("show lxsh")) | 112 | assert.is_true(run.luarocks_bool("show lxsh")) |
113 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) | 113 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
114 | end) | 114 | end) |
115 | 115 | ||
116 | it("ambiguous rockspec", function() | 116 | it("ambiguous rockspec", function() |
117 | assert.is.truthy(os.rename("lxsh-0.8.6-2.rockspec", "lxsh2-0.8.6-2.rockspec")) | 117 | assert.is.truthy(os.rename("lxsh-0.8.6-2.rockspec", "lxsh2-0.8.6-2.rockspec")) |
118 | local output = run.luarocks("make") | 118 | local output = run.luarocks("make") |
@@ -131,7 +131,7 @@ describe("luarocks make #integration", function() | |||
131 | assert.is_false(run.luarocks_bool("show lxsh")) | 131 | assert.is_false(run.luarocks_bool("show lxsh")) |
132 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) | 132 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
133 | end) | 133 | end) |
134 | 134 | ||
135 | it("pack binary rock", function() | 135 | it("pack binary rock", function() |
136 | assert.is_true(run.luarocks_bool("make --deps-mode=none --pack-binary-rock")) | 136 | assert.is_true(run.luarocks_bool("make --deps-mode=none --pack-binary-rock")) |
137 | assert.is.truthy(lfs.attributes("lxsh-0.8.6-2.all.rock")) | 137 | assert.is.truthy(lfs.attributes("lxsh-0.8.6-2.all.rock")) |
@@ -150,7 +150,7 @@ describe("luarocks make #integration", function() | |||
150 | "a_rock 1.0" | 150 | "a_rock 1.0" |
151 | } | 151 | } |
152 | build = { | 152 | build = { |
153 | type = "builtin", | 153 | type = "builtin", |
154 | modules = { | 154 | modules = { |
155 | test = "test.lua" | 155 | test = "test.lua" |
156 | } | 156 | } |
@@ -185,7 +185,7 @@ describe("luarocks make #integration", function() | |||
185 | "a_rock >= 0.8" | 185 | "a_rock >= 0.8" |
186 | } | 186 | } |
187 | build = { | 187 | build = { |
188 | type = "builtin", | 188 | type = "builtin", |
189 | modules = { | 189 | modules = { |
190 | test = "test.lua" | 190 | test = "test.lua" |
191 | } | 191 | } |
@@ -226,7 +226,7 @@ describe("luarocks make #integration", function() | |||
226 | "a_rock >= 0.8" | 226 | "a_rock >= 0.8" |
227 | } | 227 | } |
228 | build = { | 228 | build = { |
229 | type = "builtin", | 229 | type = "builtin", |
230 | modules = { | 230 | modules = { |
231 | test = "test.lua" | 231 | test = "test.lua" |
232 | } | 232 | } |
@@ -260,7 +260,7 @@ describe("luarocks make #integration", function() | |||
260 | local deploy_lib_dir = testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION | 260 | local deploy_lib_dir = testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION |
261 | local deploy_lua_dir = testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION | 261 | local deploy_lua_dir = testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION |
262 | local so = test_env.lib_extension | 262 | local so = test_env.lib_extension |
263 | 263 | ||
264 | before_each(function() | 264 | before_each(function() |
265 | test_env.copy_dir(testing_paths.fixtures_dir .. "/double_deploy_type", "ddt") | 265 | test_env.copy_dir(testing_paths.fixtures_dir .. "/double_deploy_type", "ddt") |
266 | end) | 266 | end) |
@@ -279,7 +279,7 @@ describe("luarocks make #integration", function() | |||
279 | assert.is.falsy(lfs.attributes(deploy_lib_dir.."/ddt."..so.."~")) | 279 | assert.is.falsy(lfs.attributes(deploy_lib_dir.."/ddt."..so.."~")) |
280 | assert.is.falsy(lfs.attributes(deploy_lua_dir.."/ddt.lua~")) | 280 | assert.is.falsy(lfs.attributes(deploy_lua_dir.."/ddt.lua~")) |
281 | assert.is.falsy(lfs.attributes(deploy_lua_dir.."/ddt_file~")) | 281 | assert.is.falsy(lfs.attributes(deploy_lua_dir.."/ddt_file~")) |
282 | 282 | ||
283 | assert.is_true(run.luarocks_bool("make ddt/double_deploy_type-0.2.0-1.rockspec")) | 283 | assert.is_true(run.luarocks_bool("make ddt/double_deploy_type-0.2.0-1.rockspec")) |
284 | assert.is.truthy(lfs.attributes(deploy_lib_dir.."/ddt."..so)) | 284 | assert.is.truthy(lfs.attributes(deploy_lib_dir.."/ddt."..so)) |
285 | assert.is.truthy(lfs.attributes(deploy_lua_dir.."/ddt.lua")) | 285 | assert.is.truthy(lfs.attributes(deploy_lua_dir.."/ddt.lua")) |
diff --git a/spec/new_version_spec.lua b/spec/new_version_spec.lua index 2f628242..830e4d11 100644 --- a/spec/new_version_spec.lua +++ b/spec/new_version_spec.lua | |||
@@ -15,7 +15,7 @@ describe("luarocks new_version #integration", function() | |||
15 | setup(function() | 15 | setup(function() |
16 | test_env.setup_specs(extra_rocks) | 16 | test_env.setup_specs(extra_rocks) |
17 | end) | 17 | end) |
18 | 18 | ||
19 | describe("basic tests", function() | 19 | describe("basic tests", function() |
20 | it("with no flags/arguments", function() | 20 | it("with no flags/arguments", function() |
21 | finally(function() | 21 | finally(function() |
@@ -26,7 +26,7 @@ describe("luarocks new_version #integration", function() | |||
26 | assert(lfs.chdir("empty")) | 26 | assert(lfs.chdir("empty")) |
27 | assert.is_false(run.luarocks_bool("new_version")) | 27 | assert.is_false(run.luarocks_bool("new_version")) |
28 | end) | 28 | end) |
29 | 29 | ||
30 | it("with invalid", function() | 30 | it("with invalid", function() |
31 | assert.is_false(run.luarocks_bool("new_version invalid")) | 31 | assert.is_false(run.luarocks_bool("new_version invalid")) |
32 | end) | 32 | end) |
@@ -53,7 +53,7 @@ describe("luarocks new_version #integration", function() | |||
53 | assert.is.truthy(lfs.attributes("abelhas-1.2-1.rockspec")) | 53 | assert.is.truthy(lfs.attributes("abelhas-1.2-1.rockspec")) |
54 | test_env.remove_files(lfs.currentdir(), "abelhas%-") | 54 | test_env.remove_files(lfs.currentdir(), "abelhas%-") |
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.13.0")) | 58 | assert.is_true(run.luarocks_bool("download --rockspec luacov 0.13.0")) |
59 | assert.is_true(run.luarocks_bool("new_version luacov-0.13.0-1.rockspec --tag v0.3")) | 59 | assert.is_true(run.luarocks_bool("new_version luacov-0.13.0-1.rockspec --tag v0.3")) |
diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua index a0b302a3..0790c801 100644 --- a/spec/pack_spec.lua +++ b/spec/pack_spec.lua | |||
@@ -35,7 +35,7 @@ describe("luarocks pack #integration", function() | |||
35 | it("not installed rock", function() | 35 | it("not installed rock", function() |
36 | assert.is_false(run.luarocks_bool("pack cjson")) | 36 | assert.is_false(run.luarocks_bool("pack cjson")) |
37 | end) | 37 | end) |
38 | 38 | ||
39 | it("not installed rock from non existing manifest", function() | 39 | it("not installed rock from non existing manifest", function() |
40 | assert.is_false(run.luarocks_bool("pack /non/exist/temp.manif")) | 40 | assert.is_false(run.luarocks_bool("pack /non/exist/temp.manif")) |
41 | end) | 41 | end) |
@@ -66,7 +66,7 @@ describe("luarocks pack #integration", function() | |||
66 | setup(function() | 66 | setup(function() |
67 | test_env.mock_server_init() | 67 | test_env.mock_server_init() |
68 | end) | 68 | end) |
69 | 69 | ||
70 | teardown(function() | 70 | teardown(function() |
71 | test_env.mock_server_done() | 71 | test_env.mock_server_done() |
72 | end) | 72 | end) |
@@ -79,7 +79,7 @@ describe("luarocks pack #integration", function() | |||
79 | assert(run.luarocks_bool("pack a_rock-1.0-1.rockspec")) | 79 | assert(run.luarocks_bool("pack a_rock-1.0-1.rockspec")) |
80 | assert.is_truthy(lfs.attributes("a_rock-1.0-1.src.rock")) | 80 | assert.is_truthy(lfs.attributes("a_rock-1.0-1.src.rock")) |
81 | end) | 81 | end) |
82 | 82 | ||
83 | describe("namespaced dependencies", function() | 83 | describe("namespaced dependencies", function() |
84 | it("can pack rockspec with namespaced dependencies", function() | 84 | it("can pack rockspec with namespaced dependencies", function() |
85 | finally(function() | 85 | finally(function() |
diff --git a/spec/path_spec.lua b/spec/path_spec.lua index 7736741c..9b2a2854 100644 --- a/spec/path_spec.lua +++ b/spec/path_spec.lua | |||
@@ -16,7 +16,7 @@ describe("luarocks path #integration", function() | |||
16 | 16 | ||
17 | if _VERSION:match("[23]") then | 17 | if _VERSION:match("[23]") then |
18 | local v = _VERSION:gsub("Lua (%d+)%.(%d+)", "%1_%2") | 18 | local v = _VERSION:gsub("Lua (%d+)%.(%d+)", "%1_%2") |
19 | 19 | ||
20 | it("with LUA_PATH_"..v, function() | 20 | it("with LUA_PATH_"..v, function() |
21 | local output = run.luarocks("path", { | 21 | local output = run.luarocks("path", { |
22 | ["LUA_PATH_"..v] = package.path, | 22 | ["LUA_PATH_"..v] = package.path, |
@@ -49,23 +49,23 @@ describe("luarocks path #integration", function() | |||
49 | it("--lr-path", function() | 49 | it("--lr-path", function() |
50 | assert.is_true(run.luarocks_bool("path --lr-path")) | 50 | assert.is_true(run.luarocks_bool("path --lr-path")) |
51 | end) | 51 | end) |
52 | 52 | ||
53 | it("--lr-cpath", function() | 53 | it("--lr-cpath", function() |
54 | assert.is_true(run.luarocks_bool("path --lr-cpath")) | 54 | assert.is_true(run.luarocks_bool("path --lr-cpath")) |
55 | end) | 55 | end) |
56 | 56 | ||
57 | it("--tree", function() | 57 | it("--tree", function() |
58 | assert.is_true(run.luarocks_bool("path --tree=lua_modules")) | 58 | assert.is_true(run.luarocks_bool("path --tree=lua_modules")) |
59 | end) | 59 | end) |
60 | 60 | ||
61 | it("--project-tree", function() | 61 | it("--project-tree", function() |
62 | local path1 = "/share/lua/5%." .. test_env.lua_version:sub(3, 3) .. "/%?%.lua" | 62 | local path1 = "/share/lua/5%." .. test_env.lua_version:sub(3, 3) .. "/%?%.lua" |
63 | local path2 = "/share/lua/5%." .. test_env.lua_version:sub(3, 3) .. "/%?/init%.lua" | 63 | local path2 = "/share/lua/5%." .. test_env.lua_version:sub(3, 3) .. "/%?/init%.lua" |
64 | 64 | ||
65 | local path = run.luarocks("path --project-tree=foo") | 65 | local path = run.luarocks("path --project-tree=foo") |
66 | assert.truthy(path:find("foo" .. path1)) | 66 | assert.truthy(path:find("foo" .. path1)) |
67 | assert.truthy(path:find("foo" .. path2)) | 67 | assert.truthy(path:find("foo" .. path2)) |
68 | 68 | ||
69 | path = run.luarocks("path --project-tree=foo --tree=bar") | 69 | path = run.luarocks("path --project-tree=foo --tree=bar") |
70 | assert.falsy(path:find("foo" .. path1)) | 70 | assert.falsy(path:find("foo" .. path1)) |
71 | assert.falsy(path:find("foo" .. path2)) | 71 | assert.falsy(path:find("foo" .. path2)) |
diff --git a/spec/persist_spec.lua b/spec/persist_spec.lua index 722331b8..f426fd83 100644 --- a/spec/persist_spec.lua +++ b/spec/persist_spec.lua | |||
@@ -6,17 +6,17 @@ local persist = require("luarocks.persist") | |||
6 | 6 | ||
7 | describe("luarocks.persist #unit", function() | 7 | describe("luarocks.persist #unit", function() |
8 | local runner | 8 | local runner |
9 | 9 | ||
10 | setup(function() | 10 | setup(function() |
11 | runner = require("luacov.runner") | 11 | runner = require("luacov.runner") |
12 | runner.init(testing_paths.testrun_dir .. "/luacov.config") | 12 | runner.init(testing_paths.testrun_dir .. "/luacov.config") |
13 | runner.tick = true | 13 | runner.tick = true |
14 | end) | 14 | end) |
15 | 15 | ||
16 | teardown(function() | 16 | teardown(function() |
17 | runner.shutdown() | 17 | runner.shutdown() |
18 | end) | 18 | end) |
19 | 19 | ||
20 | describe("persist.save_from_table_to_string", function() | 20 | describe("persist.save_from_table_to_string", function() |
21 | it("simple table", function() | 21 | it("simple table", function() |
22 | assert.are.same([[ | 22 | assert.are.same([[ |
diff --git a/spec/remove_spec.lua b/spec/remove_spec.lua index cdac5c01..91b6a460 100644 --- a/spec/remove_spec.lua +++ b/spec/remove_spec.lua | |||
@@ -26,11 +26,11 @@ describe("luarocks remove #integration", function() | |||
26 | it("invalid rock", function() | 26 | it("invalid rock", function() |
27 | assert.is_false(run.luarocks_bool("remove invalid.rock")) | 27 | assert.is_false(run.luarocks_bool("remove invalid.rock")) |
28 | end) | 28 | end) |
29 | 29 | ||
30 | it("missing rock", function() | 30 | it("missing rock", function() |
31 | assert.is_false(run.luarocks_bool("remove missing_rock")) | 31 | assert.is_false(run.luarocks_bool("remove missing_rock")) |
32 | end) | 32 | end) |
33 | 33 | ||
34 | it("invalid argument", function() | 34 | it("invalid argument", function() |
35 | assert.is_false(run.luarocks_bool("remove luacov --deps-mode")) | 35 | assert.is_false(run.luarocks_bool("remove luacov --deps-mode")) |
36 | end) | 36 | end) |
@@ -62,7 +62,7 @@ describe("luarocks remove #integration", function() | |||
62 | assert.is_false(run.luarocks_bool("remove coxpcall")) | 62 | assert.is_false(run.luarocks_bool("remove coxpcall")) |
63 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/coxpcall")) | 63 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/coxpcall")) |
64 | end) | 64 | end) |
65 | 65 | ||
66 | it("force", function() | 66 | it("force", function() |
67 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/coxpcall")) | 67 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/coxpcall")) |
68 | assert.is_true(run.luarocks_bool("build copas")) | 68 | assert.is_true(run.luarocks_bool("build copas")) |
@@ -71,7 +71,7 @@ describe("luarocks remove #integration", function() | |||
71 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/coxpcall")) | 71 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/coxpcall")) |
72 | assert.is.truthy(output:find("Checking stability of dependencies")) | 72 | assert.is.truthy(output:find("Checking stability of dependencies")) |
73 | end) | 73 | end) |
74 | 74 | ||
75 | it("force fast", function() | 75 | it("force fast", function() |
76 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/coxpcall")) | 76 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/coxpcall")) |
77 | assert.is_true(run.luarocks_bool("build copas")) | 77 | assert.is_true(run.luarocks_bool("build copas")) |
@@ -85,7 +85,7 @@ describe("luarocks remove #integration", function() | |||
85 | it("#admin remove #ssh", function() | 85 | it("#admin remove #ssh", function() |
86 | assert.is_true(run.luarocks_admin_bool("--server=testing remove coxpcall-1.16.0-1.src.rock")) | 86 | assert.is_true(run.luarocks_admin_bool("--server=testing remove coxpcall-1.16.0-1.src.rock")) |
87 | end) | 87 | end) |
88 | 88 | ||
89 | it("#admin remove missing", function() | 89 | it("#admin remove missing", function() |
90 | assert.is_false(run.luarocks_admin_bool("--server=testing remove")) | 90 | assert.is_false(run.luarocks_admin_bool("--server=testing remove")) |
91 | end) | 91 | end) |
diff --git a/spec/search_spec.lua b/spec/search_spec.lua index 1b5d79fa..bb6adf3e 100644 --- a/spec/search_spec.lua +++ b/spec/search_spec.lua | |||
@@ -8,7 +8,7 @@ local extra_rocks = { | |||
8 | } | 8 | } |
9 | 9 | ||
10 | describe("luarocks search #integration", function() | 10 | describe("luarocks search #integration", function() |
11 | 11 | ||
12 | before_each(function() | 12 | before_each(function() |
13 | test_env.setup_specs(extra_rocks) | 13 | test_env.setup_specs(extra_rocks) |
14 | end) | 14 | end) |
@@ -20,15 +20,15 @@ describe("luarocks search #integration", function() | |||
20 | it("zlib", function() | 20 | it("zlib", function() |
21 | assert.is_true(run.luarocks_bool("search zlib")) | 21 | assert.is_true(run.luarocks_bool("search zlib")) |
22 | end) | 22 | end) |
23 | 23 | ||
24 | it("zlib 1.1", function() | 24 | it("zlib 1.1", function() |
25 | assert.is_true(run.luarocks_bool("search zlib 1.1")) | 25 | assert.is_true(run.luarocks_bool("search zlib 1.1")) |
26 | end) | 26 | end) |
27 | 27 | ||
28 | it("missing rock", function() | 28 | it("missing rock", function() |
29 | assert.is_true(run.luarocks_bool("search missing_rock")) | 29 | assert.is_true(run.luarocks_bool("search missing_rock")) |
30 | end) | 30 | end) |
31 | 31 | ||
32 | it("with flag all", function() | 32 | it("with flag all", function() |
33 | assert.is_true(run.luarocks_bool("search --all")) | 33 | assert.is_true(run.luarocks_bool("search --all")) |
34 | end) | 34 | end) |
diff --git a/spec/show_spec.lua b/spec/show_spec.lua index e4937157..380c2441 100644 --- a/spec/show_spec.lua +++ b/spec/show_spec.lua | |||
@@ -5,7 +5,7 @@ local testing_paths = test_env.testing_paths | |||
5 | test_env.unload_luarocks() | 5 | test_env.unload_luarocks() |
6 | 6 | ||
7 | describe("luarocks show #integration", function() | 7 | describe("luarocks show #integration", function() |
8 | 8 | ||
9 | before_each(function() | 9 | before_each(function() |
10 | test_env.setup_specs() | 10 | test_env.setup_specs() |
11 | end) | 11 | end) |
@@ -13,12 +13,12 @@ describe("luarocks show #integration", function() | |||
13 | it("with no flags/arguments", function() | 13 | it("with no flags/arguments", function() |
14 | assert.is_false(run.luarocks_bool("show")) | 14 | assert.is_false(run.luarocks_bool("show")) |
15 | end) | 15 | end) |
16 | 16 | ||
17 | describe("basic tests with flags", function() | 17 | describe("basic tests with flags", function() |
18 | it("invalid", function() | 18 | it("invalid", function() |
19 | assert.is_false(run.luarocks_bool("show invalid")) | 19 | assert.is_false(run.luarocks_bool("show invalid")) |
20 | end) | 20 | end) |
21 | 21 | ||
22 | it("luacov", function() | 22 | it("luacov", function() |
23 | local output = run.luarocks("show luacov") | 23 | local output = run.luarocks("show luacov") |
24 | assert.is.truthy(output:match("LuaCov")) | 24 | assert.is.truthy(output:match("LuaCov")) |
@@ -28,12 +28,12 @@ describe("luarocks show #integration", function() | |||
28 | local output = run.luarocks("show LuaCov") | 28 | local output = run.luarocks("show LuaCov") |
29 | assert.is.truthy(output:match("LuaCov")) | 29 | assert.is.truthy(output:match("LuaCov")) |
30 | end) | 30 | end) |
31 | 31 | ||
32 | it("modules of luacov", function() | 32 | it("modules of luacov", function() |
33 | local output = run.luarocks("show --modules luacov") | 33 | local output = run.luarocks("show --modules luacov") |
34 | assert.match("luacov.*luacov.defaults.*luacov.reporter.*luacov.reporter.default.*luacov.runner.*luacov.stats.*luacov.tick", output) | 34 | assert.match("luacov.*luacov.defaults.*luacov.reporter.*luacov.reporter.default.*luacov.runner.*luacov.stats.*luacov.tick", output) |
35 | end) | 35 | end) |
36 | 36 | ||
37 | it("--deps", function() | 37 | it("--deps", function() |
38 | assert(run.luarocks_bool("build has_namespaced_dep --server=" .. testing_paths.fixtures_dir .. "/a_repo" )) | 38 | assert(run.luarocks_bool("build has_namespaced_dep --server=" .. testing_paths.fixtures_dir .. "/a_repo" )) |
39 | local output = run.luarocks("show --deps has_namespaced_dep") | 39 | local output = run.luarocks("show --deps has_namespaced_dep") |
@@ -45,21 +45,21 @@ describe("luarocks show #integration", function() | |||
45 | local output = run.luarocks("show has_namespaced_dep") | 45 | local output = run.luarocks("show has_namespaced_dep") |
46 | assert.match("a_user/a_rock.*2.0", output) | 46 | assert.match("a_user/a_rock.*2.0", output) |
47 | end) | 47 | end) |
48 | 48 | ||
49 | it("rockspec of luacov", function() | 49 | it("rockspec of luacov", function() |
50 | local output = run.luarocks("show --rockspec luacov") | 50 | local output = run.luarocks("show --rockspec luacov") |
51 | assert.is.truthy(output:match("luacov--0.13.0--1.rockspec")) | 51 | assert.is.truthy(output:match("luacov--0.13.0--1.rockspec")) |
52 | end) | 52 | end) |
53 | 53 | ||
54 | it("mversion of luacov", function() | 54 | it("mversion of luacov", function() |
55 | local output = run.luarocks("show --mversion luacov") | 55 | local output = run.luarocks("show --mversion luacov") |
56 | assert.is.truthy(output:match("0.13.0--1")) | 56 | assert.is.truthy(output:match("0.13.0--1")) |
57 | end) | 57 | end) |
58 | 58 | ||
59 | it("rock tree of luacov", function() | 59 | it("rock tree of luacov", function() |
60 | local output = run.luarocks("show --rock-tree luacov") | 60 | local output = run.luarocks("show --rock-tree luacov") |
61 | end) | 61 | end) |
62 | 62 | ||
63 | it("rock directory of luacov", function() | 63 | it("rock directory of luacov", function() |
64 | local output = run.luarocks("show --rock-dir luacov") | 64 | local output = run.luarocks("show --rock-dir luacov") |
65 | end) | 65 | end) |
@@ -67,7 +67,7 @@ describe("luarocks show #integration", function() | |||
67 | it("issues URL of luacov", function() | 67 | it("issues URL of luacov", function() |
68 | local output = run.luarocks("show --issues luacov") | 68 | local output = run.luarocks("show --issues luacov") |
69 | end) | 69 | end) |
70 | 70 | ||
71 | it("labels of luacov", function() | 71 | it("labels of luacov", function() |
72 | local output = run.luarocks("show --labels luacov") | 72 | local output = run.luarocks("show --labels luacov") |
73 | end) | 73 | end) |
diff --git a/spec/sysdetect_spec.lua b/spec/sysdetect_spec.lua index 1e73d5d6..7f9cf1be 100644 --- a/spec/sysdetect_spec.lua +++ b/spec/sysdetect_spec.lua | |||
@@ -8,7 +8,7 @@ describe("luarocks.core.sysdetect #unix #unit", function() | |||
8 | os.execute("[ -e binary-samples ] || git clone --depth=1 https://github.com/hishamhm/binary-samples") | 8 | os.execute("[ -e binary-samples ] || git clone --depth=1 https://github.com/hishamhm/binary-samples") |
9 | os.execute("cd binary-samples && git pull") | 9 | os.execute("cd binary-samples && git pull") |
10 | end) | 10 | end) |
11 | 11 | ||
12 | local files = { | 12 | local files = { |
13 | ["."] = "ignore", | 13 | ["."] = "ignore", |
14 | [".."] = "ignore", | 14 | [".."] = "ignore", |
@@ -56,7 +56,7 @@ describe("luarocks.core.sysdetect #unix #unit", function() | |||
56 | ["elf-Haiku-GCC7-WebPositive"] = {"haiku", "x86"}, | 56 | ["elf-Haiku-GCC7-WebPositive"] = {"haiku", "x86"}, |
57 | ["pe-cygwin-ls.exe"] = {"cygwin", "x86"}, | 57 | ["pe-cygwin-ls.exe"] = {"cygwin", "x86"}, |
58 | } | 58 | } |
59 | 59 | ||
60 | describe("detect_file", function() | 60 | describe("detect_file", function() |
61 | it("detects system and processor", function() | 61 | it("detects system and processor", function() |
62 | for f in lfs.dir("binary-samples") do | 62 | for f in lfs.dir("binary-samples") do |
diff --git a/spec/test_spec.lua b/spec/test_spec.lua index ddb64b0e..220ae632 100644 --- a/spec/test_spec.lua +++ b/spec/test_spec.lua | |||
@@ -17,7 +17,7 @@ local extra_rocks = { | |||
17 | "/luassert-1.8.0-0.rockspec", | 17 | "/luassert-1.8.0-0.rockspec", |
18 | "/lua-term-0.7-1.rockspec", | 18 | "/lua-term-0.7-1.rockspec", |
19 | "/penlight-1.5.4-1.rockspec", | 19 | "/penlight-1.5.4-1.rockspec", |
20 | "/mediator_lua-1.1.2-0.rockspec", | 20 | "/mediator_lua-1.1.2-0.rockspec", |
21 | } | 21 | } |
22 | 22 | ||
23 | describe("luarocks test #integration", function() | 23 | describe("luarocks test #integration", function() |
@@ -59,7 +59,7 @@ describe("luarocks test #integration", function() | |||
59 | test_env.remove_dir("busted_project-0.1-1") | 59 | test_env.remove_dir("busted_project-0.1-1") |
60 | os.remove("busted_project-0.1-1.src.rock") | 60 | os.remove("busted_project-0.1-1.src.rock") |
61 | end) | 61 | end) |
62 | 62 | ||
63 | -- make luassert | 63 | -- make luassert |
64 | assert.is_true(run.luarocks_bool("download --server="..testing_paths.fixtures_repo_dir.." busted_project 0.1-1")) | 64 | assert.is_true(run.luarocks_bool("download --server="..testing_paths.fixtures_repo_dir.." busted_project 0.1-1")) |
65 | assert.is_true(run.luarocks_bool("unpack busted_project-0.1-1.src.rock")) | 65 | assert.is_true(run.luarocks_bool("unpack busted_project-0.1-1.src.rock")) |
@@ -84,7 +84,7 @@ local test_command = require("luarocks.test.command") | |||
84 | 84 | ||
85 | describe("LuaRocks test #unit", function() | 85 | describe("LuaRocks test #unit", function() |
86 | local runner | 86 | local runner |
87 | 87 | ||
88 | lazy_setup(function() | 88 | lazy_setup(function() |
89 | cfg.init() | 89 | cfg.init() |
90 | fs.init() | 90 | fs.init() |
@@ -92,14 +92,14 @@ describe("LuaRocks test #unit", function() | |||
92 | runner.init(testing_paths.testrun_dir .. "/luacov.config") | 92 | runner.init(testing_paths.testrun_dir .. "/luacov.config") |
93 | runner.tick = true | 93 | runner.tick = true |
94 | end) | 94 | end) |
95 | 95 | ||
96 | lazy_teardown(function() | 96 | lazy_teardown(function() |
97 | runner.shutdown() | 97 | runner.shutdown() |
98 | end) | 98 | end) |
99 | 99 | ||
100 | local tmpdir | 100 | local tmpdir |
101 | local olddir | 101 | local olddir |
102 | 102 | ||
103 | local create_tmp_dir = function() | 103 | local create_tmp_dir = function() |
104 | tmpdir = get_tmp_path() | 104 | tmpdir = get_tmp_path() |
105 | olddir = lfs.currentdir() | 105 | olddir = lfs.currentdir() |
@@ -107,7 +107,7 @@ describe("LuaRocks test #unit", function() | |||
107 | lfs.chdir(tmpdir) | 107 | lfs.chdir(tmpdir) |
108 | fs.change_dir(tmpdir) | 108 | fs.change_dir(tmpdir) |
109 | end | 109 | end |
110 | 110 | ||
111 | local destroy_tmp_dir = function() | 111 | local destroy_tmp_dir = function() |
112 | if olddir then | 112 | if olddir then |
113 | lfs.chdir(olddir) | 113 | lfs.chdir(olddir) |
@@ -116,47 +116,47 @@ describe("LuaRocks test #unit", function() | |||
116 | end | 116 | end |
117 | end | 117 | end |
118 | end | 118 | end |
119 | 119 | ||
120 | describe("test.command", function() | 120 | describe("test.command", function() |
121 | describe("command.detect_type", function() | 121 | describe("command.detect_type", function() |
122 | before_each(function() | 122 | before_each(function() |
123 | create_tmp_dir() | 123 | create_tmp_dir() |
124 | end) | 124 | end) |
125 | 125 | ||
126 | after_each(function() | 126 | after_each(function() |
127 | destroy_tmp_dir() | 127 | destroy_tmp_dir() |
128 | end) | 128 | end) |
129 | 129 | ||
130 | it("returns true if test.lua exists", function() | 130 | it("returns true if test.lua exists", function() |
131 | write_file("test.lua", "", finally) | 131 | write_file("test.lua", "", finally) |
132 | assert.truthy(test_command.detect_type()) | 132 | assert.truthy(test_command.detect_type()) |
133 | end) | 133 | end) |
134 | 134 | ||
135 | it("returns false if test.lua doesn't exist", function() | 135 | it("returns false if test.lua doesn't exist", function() |
136 | assert.falsy(test_command.detect_type()) | 136 | assert.falsy(test_command.detect_type()) |
137 | end) | 137 | end) |
138 | end) | 138 | end) |
139 | 139 | ||
140 | describe("command.run_tests", function() | 140 | describe("command.run_tests", function() |
141 | before_each(function() | 141 | before_each(function() |
142 | create_tmp_dir() | 142 | create_tmp_dir() |
143 | end) | 143 | end) |
144 | 144 | ||
145 | after_each(function() | 145 | after_each(function() |
146 | destroy_tmp_dir() | 146 | destroy_tmp_dir() |
147 | end) | 147 | end) |
148 | 148 | ||
149 | it("returns the result of the executed tests", function() | 149 | it("returns the result of the executed tests", function() |
150 | write_file("test.lua", "assert(1==1)", finally) | 150 | write_file("test.lua", "assert(1==1)", finally) |
151 | assert.truthy(test_command.run_tests(nil, {})) | 151 | assert.truthy(test_command.run_tests(nil, {})) |
152 | 152 | ||
153 | write_file("test.lua", "assert(1==2)", finally) | 153 | write_file("test.lua", "assert(1==2)", finally) |
154 | assert.falsy(test_command.run_tests(nil, {})) | 154 | assert.falsy(test_command.run_tests(nil, {})) |
155 | end) | 155 | end) |
156 | 156 | ||
157 | it("returns the result of the executed tests with custom arguments and test command", function() | 157 | it("returns the result of the executed tests with custom arguments and test command", function() |
158 | write_file("test.lua", "assert(1==1)", finally) | 158 | write_file("test.lua", "assert(1==1)", finally) |
159 | 159 | ||
160 | local test = { | 160 | local test = { |
161 | script = "test.lua", | 161 | script = "test.lua", |
162 | flags = { | 162 | flags = { |
@@ -167,76 +167,76 @@ describe("LuaRocks test #unit", function() | |||
167 | } | 167 | } |
168 | assert.truthy(test_command.run_tests(test, {})) | 168 | assert.truthy(test_command.run_tests(test, {})) |
169 | end) | 169 | end) |
170 | 170 | ||
171 | it("returns false and does nothing if the test script doesn't exist", function() | 171 | it("returns false and does nothing if the test script doesn't exist", function() |
172 | assert.falsy(test_command.run_tests(nil, {})) | 172 | assert.falsy(test_command.run_tests(nil, {})) |
173 | end) | 173 | end) |
174 | end) | 174 | end) |
175 | end) | 175 | end) |
176 | 176 | ||
177 | describe("test.busted", function() | 177 | describe("test.busted", function() |
178 | describe("busted.detect_type", function() | 178 | describe("busted.detect_type", function() |
179 | before_each(function() | 179 | before_each(function() |
180 | create_tmp_dir() | 180 | create_tmp_dir() |
181 | end) | 181 | end) |
182 | 182 | ||
183 | after_each(function() | 183 | after_each(function() |
184 | destroy_tmp_dir() | 184 | destroy_tmp_dir() |
185 | end) | 185 | end) |
186 | 186 | ||
187 | it("returns true if .busted exists", function() | 187 | it("returns true if .busted exists", function() |
188 | write_file(".busted", "", finally) | 188 | write_file(".busted", "", finally) |
189 | assert.truthy(test_busted.detect_type()) | 189 | assert.truthy(test_busted.detect_type()) |
190 | end) | 190 | end) |
191 | 191 | ||
192 | it("returns false if .busted doesn't exist", function() | 192 | it("returns false if .busted doesn't exist", function() |
193 | assert.falsy(test_busted.detect_type()) | 193 | assert.falsy(test_busted.detect_type()) |
194 | end) | 194 | end) |
195 | end) | 195 | end) |
196 | 196 | ||
197 | describe("busted.run_tests", function() | 197 | describe("busted.run_tests", function() |
198 | before_each(function() | 198 | before_each(function() |
199 | path.use_tree(testing_paths.testing_sys_tree) | 199 | path.use_tree(testing_paths.testing_sys_tree) |
200 | create_tmp_dir() | 200 | create_tmp_dir() |
201 | end) | 201 | end) |
202 | 202 | ||
203 | after_each(function() | 203 | after_each(function() |
204 | destroy_tmp_dir() | 204 | destroy_tmp_dir() |
205 | end) | 205 | end) |
206 | 206 | ||
207 | pending("returns the result of the executed tests", function() | 207 | pending("returns the result of the executed tests", function() |
208 | -- FIXME: busted issue | 208 | -- FIXME: busted issue |
209 | write_file("test_spec.lua", "assert(1==1)", finally) | 209 | write_file("test_spec.lua", "assert(1==1)", finally) |
210 | assert.truthy(test_busted.run_tests(nil, {})) | 210 | assert.truthy(test_busted.run_tests(nil, {})) |
211 | 211 | ||
212 | write_file("test_spec.lua", "assert(1==2)", finally) | 212 | write_file("test_spec.lua", "assert(1==2)", finally) |
213 | assert.falsy(test_busted.run_tests()) | 213 | assert.falsy(test_busted.run_tests()) |
214 | end) | 214 | end) |
215 | end) | 215 | end) |
216 | end) | 216 | end) |
217 | 217 | ||
218 | describe("test", function() | 218 | describe("test", function() |
219 | describe("test.run_test_suite", function() | 219 | describe("test.run_test_suite", function() |
220 | before_each(function() | 220 | before_each(function() |
221 | create_tmp_dir() | 221 | create_tmp_dir() |
222 | end) | 222 | end) |
223 | 223 | ||
224 | after_each(function() | 224 | after_each(function() |
225 | destroy_tmp_dir() | 225 | destroy_tmp_dir() |
226 | end) | 226 | end) |
227 | 227 | ||
228 | it("returns false if the given rockspec cannot be loaded", function() | 228 | it("returns false if the given rockspec cannot be loaded", function() |
229 | assert.falsy(test.run_test_suite("invalid", nil, {})) | 229 | assert.falsy(test.run_test_suite("invalid", nil, {})) |
230 | end) | 230 | end) |
231 | 231 | ||
232 | it("returns false if no test type was detected", function() | 232 | it("returns false if no test type was detected", function() |
233 | assert.falsy(test.run_test_suite({ package = "test" }, nil, {})) | 233 | assert.falsy(test.run_test_suite({ package = "test" }, nil, {})) |
234 | end) | 234 | end) |
235 | 235 | ||
236 | it("returns the result of executing the tests specified in the given rockspec", function() | 236 | it("returns the result of executing the tests specified in the given rockspec", function() |
237 | write_file("test.lua", "assert(1==1)", finally) | 237 | write_file("test.lua", "assert(1==1)", finally) |
238 | assert.truthy(test.run_test_suite({ test_dependencies = {} }, nil, {})) | 238 | assert.truthy(test.run_test_suite({ test_dependencies = {} }, nil, {})) |
239 | 239 | ||
240 | write_file("test.lua", "assert(1==2)", finally) | 240 | write_file("test.lua", "assert(1==2)", finally) |
241 | assert.falsy(test.run_test_suite({ test_dependencies = {} }, nil, {})) | 241 | assert.falsy(test.run_test_suite({ test_dependencies = {} }, nil, {})) |
242 | end) | 242 | end) |
diff --git a/spec/tools_spec.lua b/spec/tools_spec.lua index c84dbab3..29e21740 100644 --- a/spec/tools_spec.lua +++ b/spec/tools_spec.lua | |||
@@ -8,7 +8,7 @@ local fs = require("luarocks.fs") | |||
8 | local cfg = require("luarocks.core.cfg") | 8 | local cfg = require("luarocks.core.cfg") |
9 | local patch = require("luarocks.tools.patch") | 9 | local patch = require("luarocks.tools.patch") |
10 | 10 | ||
11 | local lao = | 11 | local lao = |
12 | [[The Nameless is the origin of Heaven and Earth; | 12 | [[The Nameless is the origin of Heaven and Earth; |
13 | The named is the mother of all things. | 13 | The named is the mother of all things. |
14 | 14 | ||
@@ -23,7 +23,7 @@ They both may be called deep and profound. | |||
23 | Deeper and more profound, | 23 | Deeper and more profound, |
24 | The door of all subtleties!]] | 24 | The door of all subtleties!]] |
25 | 25 | ||
26 | local tzu = | 26 | local tzu = |
27 | [[The Way that can be told of is not the eternal Way; | 27 | [[The Way that can be told of is not the eternal Way; |
28 | The name that can be named is not the eternal name. | 28 | The name that can be named is not the eternal name. |
29 | The Nameless is the origin of Heaven and Earth; | 29 | The Nameless is the origin of Heaven and Earth; |
@@ -36,7 +36,7 @@ The two are the same, | |||
36 | But after they are produced, | 36 | But after they are produced, |
37 | they have different names.]] | 37 | they have different names.]] |
38 | 38 | ||
39 | local valid_patch1 = | 39 | local valid_patch1 = |
40 | [[--- lao 2002-02-21 23:30:39.942229878 -0800 | 40 | [[--- lao 2002-02-21 23:30:39.942229878 -0800 |
41 | +++ tzu 2002-02-21 23:30:50.442260588 -0800 | 41 | +++ tzu 2002-02-21 23:30:50.442260588 -0800 |
42 | @@ -1,7 +1,6 @@ | 42 | @@ -1,7 +1,6 @@ |
@@ -57,7 +57,7 @@ local valid_patch1 = | |||
57 | +Deeper and more profound, | 57 | +Deeper and more profound, |
58 | +The door of all subtleties!]] | 58 | +The door of all subtleties!]] |
59 | 59 | ||
60 | local valid_patch2 = | 60 | local valid_patch2 = |
61 | [[--- /dev/null 1969-02-21 23:30:39.942229878 -0800 | 61 | [[--- /dev/null 1969-02-21 23:30:39.942229878 -0800 |
62 | +++ tzu 2002-02-21 23:30:50.442260588 -0800 | 62 | +++ tzu 2002-02-21 23:30:50.442260588 -0800 |
63 | @@ -1,7 +1,6 @@ | 63 | @@ -1,7 +1,6 @@ |
@@ -78,7 +78,7 @@ local valid_patch2 = | |||
78 | +Deeper and more profound, | 78 | +Deeper and more profound, |
79 | +The door of all subtleties!]] | 79 | +The door of all subtleties!]] |
80 | 80 | ||
81 | local invalid_patch1 = | 81 | local invalid_patch1 = |
82 | [[--- lao 2002-02-21 23:30:39.942229878 -0800 | 82 | [[--- lao 2002-02-21 23:30:39.942229878 -0800 |
83 | +++ tzu 2002-02-21 23:30:50.442260588 -0800 | 83 | +++ tzu 2002-02-21 23:30:50.442260588 -0800 |
84 | @@ -1,7 +1,6 @@ | 84 | @@ -1,7 +1,6 @@ |
@@ -101,7 +101,7 @@ local invalid_patch1 = | |||
101 | +Deeper and more profound, | 101 | +Deeper and more profound, |
102 | +The door of all subtleties!]] | 102 | +The door of all subtleties!]] |
103 | 103 | ||
104 | local invalid_patch2 = | 104 | local invalid_patch2 = |
105 | [[--- lao 2002-02-21 23:30:39.942229878 -0800 | 105 | [[--- lao 2002-02-21 23:30:39.942229878 -0800 |
106 | +++ tzu 2002-02-21 23:30:50.442260588 -0800 | 106 | +++ tzu 2002-02-21 23:30:50.442260588 -0800 |
107 | @@ -1,7 +1,6 @@ | 107 | @@ -1,7 +1,6 @@ |
@@ -123,7 +123,7 @@ local invalid_patch2 = | |||
123 | ? ... | 123 | ? ... |
124 | +The door of all subtleties!]] | 124 | +The door of all subtleties!]] |
125 | 125 | ||
126 | local invalid_patch3 = | 126 | local invalid_patch3 = |
127 | [[--- lao 2002-02-21 23:30:39.942229878 -0800 | 127 | [[--- lao 2002-02-21 23:30:39.942229878 -0800 |
128 | +++ tzu 2002-02-21 23:30:50.442260588 -0800 | 128 | +++ tzu 2002-02-21 23:30:50.442260588 -0800 |
129 | @@ -1,7 +1,6 @@ | 129 | @@ -1,7 +1,6 @@ |
@@ -147,7 +147,7 @@ local invalid_patch3 = | |||
147 | 147 | ||
148 | describe("Luarocks patch test #unit", function() | 148 | describe("Luarocks patch test #unit", function() |
149 | local runner | 149 | local runner |
150 | 150 | ||
151 | setup(function() | 151 | setup(function() |
152 | cfg.init() | 152 | cfg.init() |
153 | fs.init() | 153 | fs.init() |
@@ -155,51 +155,51 @@ describe("Luarocks patch test #unit", function() | |||
155 | runner.init(testing_paths.testrun_dir .. "/luacov.config") | 155 | runner.init(testing_paths.testrun_dir .. "/luacov.config") |
156 | runner.tick = true | 156 | runner.tick = true |
157 | end) | 157 | end) |
158 | 158 | ||
159 | teardown(function() | 159 | teardown(function() |
160 | runner.shutdown() | 160 | runner.shutdown() |
161 | end) | 161 | end) |
162 | 162 | ||
163 | describe("patch.read_patch", function() | 163 | describe("patch.read_patch", function() |
164 | it("returns a table with the patch file info and the result of parsing the file", function() | 164 | it("returns a table with the patch file info and the result of parsing the file", function() |
165 | local t, result | 165 | local t, result |
166 | 166 | ||
167 | write_file("test.patch", valid_patch1, finally) | 167 | write_file("test.patch", valid_patch1, finally) |
168 | t, result = patch.read_patch("test.patch") | 168 | t, result = patch.read_patch("test.patch") |
169 | assert.truthy(result) | 169 | assert.truthy(result) |
170 | assert.truthy(t) | 170 | assert.truthy(t) |
171 | 171 | ||
172 | write_file("test.patch", invalid_patch1, finally) | 172 | write_file("test.patch", invalid_patch1, finally) |
173 | t, result = patch.read_patch("test.patch") | 173 | t, result = patch.read_patch("test.patch") |
174 | assert.falsy(result) | 174 | assert.falsy(result) |
175 | assert.truthy(t) | 175 | assert.truthy(t) |
176 | 176 | ||
177 | write_file("test.patch", invalid_patch2, finally) | 177 | write_file("test.patch", invalid_patch2, finally) |
178 | t, result = patch.read_patch("test.patch") | 178 | t, result = patch.read_patch("test.patch") |
179 | assert.falsy(result) | 179 | assert.falsy(result) |
180 | assert.truthy(t) | 180 | assert.truthy(t) |
181 | 181 | ||
182 | write_file("test.patch", invalid_patch3, finally) | 182 | write_file("test.patch", invalid_patch3, finally) |
183 | t, result = patch.read_patch("test.patch") | 183 | t, result = patch.read_patch("test.patch") |
184 | assert.falsy(result) | 184 | assert.falsy(result) |
185 | assert.truthy(t) | 185 | assert.truthy(t) |
186 | end) | 186 | end) |
187 | end) | 187 | end) |
188 | 188 | ||
189 | describe("patch.apply_patch", function() | 189 | describe("patch.apply_patch", function() |
190 | local tmpdir | 190 | local tmpdir |
191 | local olddir | 191 | local olddir |
192 | 192 | ||
193 | before_each(function() | 193 | before_each(function() |
194 | tmpdir = get_tmp_path() | 194 | tmpdir = get_tmp_path() |
195 | olddir = lfs.currentdir() | 195 | olddir = lfs.currentdir() |
196 | lfs.mkdir(tmpdir) | 196 | lfs.mkdir(tmpdir) |
197 | lfs.chdir(tmpdir) | 197 | lfs.chdir(tmpdir) |
198 | 198 | ||
199 | write_file("lao", tzu, finally) | 199 | write_file("lao", tzu, finally) |
200 | write_file("tzu", lao, finally) | 200 | write_file("tzu", lao, finally) |
201 | end) | 201 | end) |
202 | 202 | ||
203 | after_each(function() | 203 | after_each(function() |
204 | if olddir then | 204 | if olddir then |
205 | lfs.chdir(olddir) | 205 | lfs.chdir(olddir) |
@@ -208,44 +208,44 @@ describe("Luarocks patch test #unit", function() | |||
208 | end | 208 | end |
209 | end | 209 | end |
210 | end) | 210 | end) |
211 | 211 | ||
212 | it("applies the given patch and returns the result of patching", function() | 212 | it("applies the given patch and returns the result of patching", function() |
213 | write_file("test.patch", valid_patch1, finally) | 213 | write_file("test.patch", valid_patch1, finally) |
214 | local p = patch.read_patch("test.patch") | 214 | local p = patch.read_patch("test.patch") |
215 | local result = patch.apply_patch(p) | 215 | local result = patch.apply_patch(p) |
216 | assert.truthy(result) | 216 | assert.truthy(result) |
217 | end) | 217 | end) |
218 | 218 | ||
219 | it("applies the given patch with custom arguments and returns the result of patching", function() | 219 | it("applies the given patch with custom arguments and returns the result of patching", function() |
220 | write_file("test.patch", valid_patch2, finally) | 220 | write_file("test.patch", valid_patch2, finally) |
221 | local p = patch.read_patch("test.patch") | 221 | local p = patch.read_patch("test.patch") |
222 | local result = patch.apply_patch(p, nil, true) | 222 | local result = patch.apply_patch(p, nil, true) |
223 | assert.truthy(result) | 223 | assert.truthy(result) |
224 | end) | 224 | end) |
225 | 225 | ||
226 | it("fails if the patch file is invalid", function() | 226 | it("fails if the patch file is invalid", function() |
227 | write_file("test.patch", invalid_patch1, finally) | 227 | write_file("test.patch", invalid_patch1, finally) |
228 | local p = patch.read_patch("test.patch") | 228 | local p = patch.read_patch("test.patch") |
229 | local result = pcall(patch.apply_patch, p) | 229 | local result = pcall(patch.apply_patch, p) |
230 | assert.falsy(result) | 230 | assert.falsy(result) |
231 | end) | 231 | end) |
232 | 232 | ||
233 | it("returns false if the files from the patch doesn't exist", function() | 233 | it("returns false if the files from the patch doesn't exist", function() |
234 | os.remove("lao") | 234 | os.remove("lao") |
235 | os.remove("tzu") | 235 | os.remove("tzu") |
236 | 236 | ||
237 | write_file("test.patch", valid_patch1, finally) | 237 | write_file("test.patch", valid_patch1, finally) |
238 | local p = patch.read_patch("test.patch") | 238 | local p = patch.read_patch("test.patch") |
239 | local result = patch.apply_patch(p) | 239 | local result = patch.apply_patch(p) |
240 | assert.falsy(result) | 240 | assert.falsy(result) |
241 | end) | 241 | end) |
242 | 242 | ||
243 | it("returns false if the target file was already patched", function() | 243 | it("returns false if the target file was already patched", function() |
244 | write_file("test.patch", valid_patch1, finally) | 244 | write_file("test.patch", valid_patch1, finally) |
245 | local p = patch.read_patch("test.patch") | 245 | local p = patch.read_patch("test.patch") |
246 | local result = patch.apply_patch(p) | 246 | local result = patch.apply_patch(p) |
247 | assert.truthy(result) | 247 | assert.truthy(result) |
248 | 248 | ||
249 | result = patch.apply_patch(p) | 249 | result = patch.apply_patch(p) |
250 | assert.falsy(result) | 250 | assert.falsy(result) |
251 | end) | 251 | end) |
diff --git a/spec/unpack_spec.lua b/spec/unpack_spec.lua index 489e01e6..9b1e2b9a 100644 --- a/spec/unpack_spec.lua +++ b/spec/unpack_spec.lua | |||
@@ -11,7 +11,7 @@ local extra_rocks = { | |||
11 | } | 11 | } |
12 | 12 | ||
13 | describe("luarocks unpack #integration", function() | 13 | describe("luarocks unpack #integration", function() |
14 | 14 | ||
15 | before_each(function() | 15 | before_each(function() |
16 | test_env.setup_specs(extra_rocks) | 16 | test_env.setup_specs(extra_rocks) |
17 | end) | 17 | end) |
@@ -20,11 +20,11 @@ describe("luarocks unpack #integration", function() | |||
20 | it("with no flags/arguments", function() | 20 | it("with no flags/arguments", function() |
21 | assert.is_false(run.luarocks_bool("unpack")) | 21 | assert.is_false(run.luarocks_bool("unpack")) |
22 | end) | 22 | end) |
23 | 23 | ||
24 | it("with invalid rockspec", function() | 24 | it("with invalid rockspec", function() |
25 | assert.is_false(run.luarocks_bool("unpack invalid.rockspec")) | 25 | assert.is_false(run.luarocks_bool("unpack invalid.rockspec")) |
26 | end) | 26 | end) |
27 | 27 | ||
28 | it("with invalid patch", function() | 28 | it("with invalid patch", function() |
29 | assert.is_false(run.luarocks_bool("unpack " .. testing_paths.fixtures_dir .. "/invalid_patch-0.1-1.rockspec")) | 29 | assert.is_false(run.luarocks_bool("unpack " .. testing_paths.fixtures_dir .. "/invalid_patch-0.1-1.rockspec")) |
30 | end) | 30 | end) |
@@ -35,14 +35,14 @@ describe("luarocks unpack #integration", function() | |||
35 | assert.is_true(run.luarocks_bool("unpack cprint")) | 35 | assert.is_true(run.luarocks_bool("unpack cprint")) |
36 | test_env.remove_dir("cprint-0.1-2") | 36 | test_env.remove_dir("cprint-0.1-2") |
37 | end) | 37 | end) |
38 | 38 | ||
39 | it("src", function() | 39 | it("src", function() |
40 | assert.is_true(run.luarocks_bool("download --source cprint")) | 40 | assert.is_true(run.luarocks_bool("download --source cprint")) |
41 | assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.src.rock")) | 41 | assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.src.rock")) |
42 | os.remove("cprint-0.1-2.src.rock") | 42 | os.remove("cprint-0.1-2.src.rock") |
43 | test_env.remove_dir("cprint-0.1-2") | 43 | test_env.remove_dir("cprint-0.1-2") |
44 | end) | 44 | end) |
45 | 45 | ||
46 | it("src", function() | 46 | it("src", function() |
47 | assert.is_true(run.luarocks_bool("download --rockspec cprint")) | 47 | assert.is_true(run.luarocks_bool("download --rockspec cprint")) |
48 | assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.rockspec")) | 48 | assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.rockspec")) |
diff --git a/spec/upload_spec.lua b/spec/upload_spec.lua index dc073c18..e1215d2c 100644 --- a/spec/upload_spec.lua +++ b/spec/upload_spec.lua | |||
@@ -17,15 +17,15 @@ describe("luarocks upload #integration", function() | |||
17 | it("invalid rockspec", function() | 17 | it("invalid rockspec", function() |
18 | assert.is_false(run.luarocks_bool("upload invalid.rockspec")) | 18 | assert.is_false(run.luarocks_bool("upload invalid.rockspec")) |
19 | end) | 19 | end) |
20 | 20 | ||
21 | it("api key invalid", function() | 21 | it("api key invalid", function() |
22 | assert.is_false(run.luarocks_bool("upload --api-key=invalid invalid.rockspec")) | 22 | assert.is_false(run.luarocks_bool("upload --api-key=invalid invalid.rockspec")) |
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-3.0rc1-2.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-3.0rc1-2.rockspec")) |
@@ -33,7 +33,7 @@ describe("luarocks upload #integration", function() | |||
33 | 33 | ||
34 | describe("tests with Xavante server #mock", function() | 34 | describe("tests with Xavante server #mock", function() |
35 | before_each(test_env.mock_server_init) | 35 | before_each(test_env.mock_server_init) |
36 | 36 | ||
37 | after_each(test_env.mock_server_done) | 37 | after_each(test_env.mock_server_done) |
38 | 38 | ||
39 | it("rockspec with api-key", function() | 39 | it("rockspec with api-key", function() |
diff --git a/spec/util/mock-server.lua b/spec/util/mock-server.lua index 8e498d57..1b09cd6b 100644 --- a/spec/util/mock-server.lua +++ b/spec/util/mock-server.lua | |||
@@ -95,4 +95,4 @@ server:add_resource("/shutdown", { | |||
95 | }) | 95 | }) |
96 | 96 | ||
97 | -- This loads the restserver.xavante plugin | 97 | -- This loads the restserver.xavante plugin |
98 | server:enable("restserver.xavante"):start() \ No newline at end of file | 98 | server:enable("restserver.xavante"):start() |
diff --git a/spec/util/test_env.lua b/spec/util/test_env.lua index 8aebd74e..1585adac 100644 --- a/spec/util/test_env.lua +++ b/spec/util/test_env.lua | |||
@@ -55,7 +55,7 @@ local function Q(arg) | |||
55 | if arg:match("^"..drive_letter) then | 55 | if arg:match("^"..drive_letter) then |
56 | arg = arg:gsub("/", "\\") | 56 | arg = arg:gsub("/", "\\") |
57 | end | 57 | end |
58 | 58 | ||
59 | if arg == "\\" then | 59 | if arg == "\\" then |
60 | return '\\' -- CHDIR needs special handling for root dir | 60 | return '\\' -- CHDIR needs special handling for root dir |
61 | end | 61 | end |
@@ -128,10 +128,10 @@ end | |||
128 | function test_env.execute_helper(command, print_command, env_variables) | 128 | function test_env.execute_helper(command, print_command, env_variables) |
129 | local final_command = "" | 129 | local final_command = "" |
130 | 130 | ||
131 | if print_command then | 131 | if print_command then |
132 | print("[EXECUTING]: " .. command) | 132 | print("[EXECUTING]: " .. command) |
133 | end | 133 | end |
134 | 134 | ||
135 | local unset_variables = { | 135 | local unset_variables = { |
136 | "LUA_PATH", | 136 | "LUA_PATH", |
137 | "LUA_CPATH", | 137 | "LUA_CPATH", |
@@ -178,7 +178,7 @@ end | |||
178 | -- @return true/false boolean: status of the command execution | 178 | -- @return true/false boolean: status of the command execution |
179 | local function execute_bool(command, print_command, env_variables) | 179 | local function execute_bool(command, print_command, env_variables) |
180 | command = test_env.execute_helper(command, print_command, env_variables) | 180 | command = test_env.execute_helper(command, print_command, env_variables) |
181 | 181 | ||
182 | local redirect_filename | 182 | local redirect_filename |
183 | local redirect = "" | 183 | local redirect = "" |
184 | if print_command ~= nil then | 184 | if print_command ~= nil then |
@@ -438,11 +438,11 @@ end | |||
438 | -- @return env_variables table: table with created environment variables | 438 | -- @return env_variables table: table with created environment variables |
439 | local function create_env(testing_paths) | 439 | local function create_env(testing_paths) |
440 | local luaversion_short = _VERSION:gsub("Lua ", "") | 440 | local luaversion_short = _VERSION:gsub("Lua ", "") |
441 | 441 | ||
442 | if test_env.LUAJIT_V then | 442 | if test_env.LUAJIT_V then |
443 | luaversion_short="5.1" | 443 | luaversion_short="5.1" |
444 | end | 444 | end |
445 | 445 | ||
446 | local env_variables = {} | 446 | local env_variables = {} |
447 | env_variables.GNUPGHOME = testing_paths.gpg_dir | 447 | env_variables.GNUPGHOME = testing_paths.gpg_dir |
448 | env_variables.LUA_VERSION = luaversion_short | 448 | env_variables.LUA_VERSION = luaversion_short |
@@ -481,7 +481,7 @@ local function make_run_function(cmd_name, exec_function, with_coverage, do_prin | |||
481 | if with_coverage then | 481 | if with_coverage then |
482 | cmd_prefix = cmd_prefix .. "-e \"require('luacov.runner')('" .. test_env.testing_paths.testrun_dir .. "/luacov.config')\" " | 482 | cmd_prefix = cmd_prefix .. "-e \"require('luacov.runner')('" .. test_env.testing_paths.testrun_dir .. "/luacov.config')\" " |
483 | end | 483 | end |
484 | 484 | ||
485 | if cmd_name then | 485 | if cmd_name then |
486 | cmd_prefix = cmd_prefix .. test_env.testing_paths.src_dir .. "/bin/" .. cmd_name .. " " | 486 | cmd_prefix = cmd_prefix .. test_env.testing_paths.src_dir .. "/bin/" .. cmd_name .. " " |
487 | end | 487 | end |
@@ -547,7 +547,7 @@ local function build_environment(rocks, env_variables) | |||
547 | move_file(rock .. "-*.rock", testing_paths.testing_cache) | 547 | move_file(rock .. "-*.rock", testing_paths.testing_cache) |
548 | end | 548 | end |
549 | end | 549 | end |
550 | 550 | ||
551 | test_env.copy_dir(testing_paths.testing_tree, testing_paths.testing_tree_copy) | 551 | test_env.copy_dir(testing_paths.testing_tree, testing_paths.testing_tree_copy) |
552 | test_env.copy_dir(testing_paths.testing_sys_tree, testing_paths.testing_sys_tree_copy) | 552 | test_env.copy_dir(testing_paths.testing_sys_tree, testing_paths.testing_sys_tree_copy) |
553 | end | 553 | end |
@@ -653,7 +653,7 @@ function test_env.setup_specs(extra_rocks) | |||
653 | end | 653 | end |
654 | 654 | ||
655 | test_env.main() | 655 | test_env.main() |
656 | 656 | ||
657 | -- preload before meddling with package.path | 657 | -- preload before meddling with package.path |
658 | require("spec.util.git_repo") | 658 | require("spec.util.git_repo") |
659 | 659 | ||
@@ -666,8 +666,8 @@ function test_env.setup_specs(extra_rocks) | |||
666 | test_env.setup_done = true | 666 | test_env.setup_done = true |
667 | title("RUNNING TESTS") | 667 | title("RUNNING TESTS") |
668 | end | 668 | end |
669 | 669 | ||
670 | if extra_rocks then | 670 | if extra_rocks then |
671 | local make_manifest = download_rocks(extra_rocks, test_env.testing_paths.testing_server) | 671 | local make_manifest = download_rocks(extra_rocks, test_env.testing_paths.testing_server) |
672 | if make_manifest then | 672 | if make_manifest then |
673 | test_env.run.luarocks_admin_nocov("make_manifest " .. test_env.testing_paths.testing_server) | 673 | test_env.run.luarocks_admin_nocov("make_manifest " .. test_env.testing_paths.testing_server) |
@@ -677,7 +677,7 @@ function test_env.setup_specs(extra_rocks) | |||
677 | if test_env.RESET_ENV then | 677 | if test_env.RESET_ENV then |
678 | reset_environment(test_env.testing_paths, test_env.md5sums, test_env.env_variables) | 678 | reset_environment(test_env.testing_paths, test_env.md5sums, test_env.env_variables) |
679 | end | 679 | end |
680 | 680 | ||
681 | lfs.chdir(test_env.testing_paths.testrun_dir) | 681 | lfs.chdir(test_env.testing_paths.testrun_dir) |
682 | end | 682 | end |
683 | 683 | ||
@@ -903,7 +903,7 @@ local function prepare_mock_server_binary_rocks() | |||
903 | end | 903 | end |
904 | 904 | ||
905 | --- | 905 | --- |
906 | -- Main function to create config files and testing environment | 906 | -- Main function to create config files and testing environment |
907 | function test_env.main() | 907 | function test_env.main() |
908 | local testing_paths = test_env.testing_paths | 908 | local testing_paths = test_env.testing_paths |
909 | 909 | ||
@@ -954,7 +954,7 @@ function test_env.main() | |||
954 | local env_vars = { | 954 | local env_vars = { |
955 | LUAROCKS_CONFIG = test_env.testing_paths.testrun_dir .. "/testing_config.lua" | 955 | LUAROCKS_CONFIG = test_env.testing_paths.testrun_dir .. "/testing_config.lua" |
956 | } | 956 | } |
957 | 957 | ||
958 | build_environment(rocks, env_vars) | 958 | build_environment(rocks, env_vars) |
959 | 959 | ||
960 | prepare_mock_server_binary_rocks() | 960 | prepare_mock_server_binary_rocks() |
diff --git a/spec/util_spec.lua b/spec/util_spec.lua index 3970a57c..5aa49b4c 100644 --- a/spec/util_spec.lua +++ b/spec/util_spec.lua | |||
@@ -33,7 +33,7 @@ describe("Basic tests #integration", function() | |||
33 | local delete_path = lfs.currentdir() | 33 | local delete_path = lfs.currentdir() |
34 | assert.is_true(os.remove(delete_path)) | 34 | assert.is_true(os.remove(delete_path)) |
35 | 35 | ||
36 | local output = run.luarocks("") | 36 | local output = run.luarocks("") |
37 | assert.is.falsy(output:find("the Lua package manager")) | 37 | assert.is.falsy(output:find("the Lua package manager")) |
38 | assert.is_true(lfs.chdir(main_path)) | 38 | assert.is_true(lfs.chdir(main_path)) |
39 | 39 | ||
@@ -44,7 +44,7 @@ describe("Basic tests #integration", function() | |||
44 | it("--timeout", function() | 44 | it("--timeout", function() |
45 | assert.is.truthy(run.luarocks("--timeout=10")) | 45 | assert.is.truthy(run.luarocks("--timeout=10")) |
46 | end) | 46 | end) |
47 | 47 | ||
48 | it("--timeout invalid", function() | 48 | it("--timeout invalid", function() |
49 | assert.is_false(run.luarocks_bool("--timeout=abc")) | 49 | assert.is_false(run.luarocks_bool("--timeout=abc")) |
50 | end) | 50 | end) |
@@ -61,17 +61,17 @@ local core_util = require("luarocks.core.util") | |||
61 | 61 | ||
62 | describe("luarocks.util #unit", function() | 62 | describe("luarocks.util #unit", function() |
63 | local runner | 63 | local runner |
64 | 64 | ||
65 | setup(function() | 65 | setup(function() |
66 | runner = require("luacov.runner") | 66 | runner = require("luacov.runner") |
67 | runner.init(testing_paths.testrun_dir .. "/luacov.config") | 67 | runner.init(testing_paths.testrun_dir .. "/luacov.config") |
68 | runner.tick = true | 68 | runner.tick = true |
69 | end) | 69 | end) |
70 | 70 | ||
71 | teardown(function() | 71 | teardown(function() |
72 | runner.shutdown() | 72 | runner.shutdown() |
73 | end) | 73 | end) |
74 | 74 | ||
75 | describe("util.sortedpairs", function() | 75 | describe("util.sortedpairs", function() |
76 | local function collect(iter, state, var) | 76 | local function collect(iter, state, var) |
77 | local collected = {} | 77 | local collected = {} |
@@ -122,30 +122,30 @@ describe("luarocks.util #unit", function() | |||
122 | }, {"k3", {"k2", {"sub order"}}, "k1"}))) | 122 | }, {"k3", {"k2", {"sub order"}}, "k1"}))) |
123 | end) | 123 | end) |
124 | end) | 124 | end) |
125 | 125 | ||
126 | describe("core.util.show_table", function() | 126 | describe("core.util.show_table", function() |
127 | it("returns a pretty-printed string containing the representation of the given table", function() | 127 | it("returns a pretty-printed string containing the representation of the given table", function() |
128 | local result | 128 | local result |
129 | 129 | ||
130 | local t1 = {1, 2, 3} | 130 | local t1 = {1, 2, 3} |
131 | result = core_util.show_table(t1) | 131 | result = core_util.show_table(t1) |
132 | assert.truthy(result:find("[1] = 1", 1, true)) | 132 | assert.truthy(result:find("[1] = 1", 1, true)) |
133 | assert.truthy(result:find("[2] = 2", 1, true)) | 133 | assert.truthy(result:find("[2] = 2", 1, true)) |
134 | assert.truthy(result:find("[3] = 3", 1, true)) | 134 | assert.truthy(result:find("[3] = 3", 1, true)) |
135 | 135 | ||
136 | local t2 = {a = 1, b = 2, c = 3} | 136 | local t2 = {a = 1, b = 2, c = 3} |
137 | result = core_util.show_table(t2) | 137 | result = core_util.show_table(t2) |
138 | assert.truthy(result:find("[\"a\"] = 1", 1, true)) | 138 | assert.truthy(result:find("[\"a\"] = 1", 1, true)) |
139 | assert.truthy(result:find("[\"b\"] = 2", 1, true)) | 139 | assert.truthy(result:find("[\"b\"] = 2", 1, true)) |
140 | assert.truthy(result:find("[\"c\"] = 3", 1, true)) | 140 | assert.truthy(result:find("[\"c\"] = 3", 1, true)) |
141 | 141 | ||
142 | local t3 = {a = 1, b = "2", c = {3}} | 142 | local t3 = {a = 1, b = "2", c = {3}} |
143 | result = core_util.show_table(t3) | 143 | result = core_util.show_table(t3) |
144 | assert.truthy(result:find("[\"a\"] = 1", 1, true)) | 144 | assert.truthy(result:find("[\"a\"] = 1", 1, true)) |
145 | assert.truthy(result:find("[\"b\"] = \"2\"", 1, true)) | 145 | assert.truthy(result:find("[\"b\"] = \"2\"", 1, true)) |
146 | assert.truthy(result:find("[\"c\"] = {", 1, true)) | 146 | assert.truthy(result:find("[\"c\"] = {", 1, true)) |
147 | assert.truthy(result:find("[1] = 3", 1, true)) | 147 | assert.truthy(result:find("[1] = 3", 1, true)) |
148 | 148 | ||
149 | local t4 = {a = 1, b = {c = 2, d = {e = "4"}}} | 149 | local t4 = {a = 1, b = {c = 2, d = {e = "4"}}} |
150 | result = core_util.show_table(t4) | 150 | result = core_util.show_table(t4) |
151 | assert.truthy(result:find("[\"a\"] = 1", 1, true)) | 151 | assert.truthy(result:find("[\"a\"] = 1", 1, true)) |
@@ -155,7 +155,7 @@ describe("luarocks.util #unit", function() | |||
155 | assert.truthy(result:find("[\"e\"] = \"4\"", 1, true)) | 155 | assert.truthy(result:find("[\"e\"] = \"4\"", 1, true)) |
156 | end) | 156 | end) |
157 | end) | 157 | end) |
158 | 158 | ||
159 | describe("core.util.cleanup_path", function() | 159 | describe("core.util.cleanup_path", function() |
160 | it("does not change order of existing items of prepended path", function() | 160 | it("does not change order of existing items of prepended path", function() |
161 | local sys_path = '/usr/local/bin;/usr/bin' | 161 | local sys_path = '/usr/local/bin;/usr/bin' |
diff --git a/spec/which_spec.lua b/spec/which_spec.lua index 4e9bdaf4..d6e07eb7 100644 --- a/spec/which_spec.lua +++ b/spec/which_spec.lua | |||
@@ -13,7 +13,7 @@ local extra_rocks = { | |||
13 | } | 13 | } |
14 | 14 | ||
15 | describe("luarocks which #integration", function() | 15 | describe("luarocks which #integration", function() |
16 | 16 | ||
17 | setup(function() | 17 | setup(function() |
18 | test_env.setup_specs(extra_rocks) | 18 | test_env.setup_specs(extra_rocks) |
19 | test_env.unload_luarocks() -- need to be required here, because hardcoded is created after first loading of specs | 19 | test_env.unload_luarocks() -- need to be required here, because hardcoded is created after first loading of specs |
diff --git a/spec/write_rockspec_spec.lua b/spec/write_rockspec_spec.lua index 3031cf10..5f9faa6e 100644 --- a/spec/write_rockspec_spec.lua +++ b/spec/write_rockspec_spec.lua | |||
@@ -12,18 +12,18 @@ describe("luarocks write_rockspec tests #integration", function() | |||
12 | it("fails with invalid argument", function() | 12 | it("fails with invalid argument", function() |
13 | assert.is_false(run.luarocks_bool("write_rockspec invalid")) | 13 | assert.is_false(run.luarocks_bool("write_rockspec invalid")) |
14 | end) | 14 | end) |
15 | 15 | ||
16 | it("fails with invalid zip", function() | 16 | it("fails with invalid zip", function() |
17 | assert.is_false(run.luarocks_bool("write_rockspec http://example.com/invalid.zip")) | 17 | assert.is_false(run.luarocks_bool("write_rockspec http://example.com/invalid.zip")) |
18 | end) | 18 | end) |
19 | 19 | ||
20 | describe("from #git #unix", function() | 20 | describe("from #git #unix", function() |
21 | local git | 21 | local git |
22 | 22 | ||
23 | setup(function() | 23 | setup(function() |
24 | git = git_repo.start() | 24 | git = git_repo.start() |
25 | end) | 25 | end) |
26 | 26 | ||
27 | teardown(function() | 27 | teardown(function() |
28 | git:stop() | 28 | git:stop() |
29 | end) | 29 | end) |
@@ -46,21 +46,21 @@ describe("luarocks write_rockspec tests #integration", function() | |||
46 | assert.is_true(run.luarocks_bool("write_rockspec git://localhost/testrock")) | 46 | assert.is_true(run.luarocks_bool("write_rockspec git://localhost/testrock")) |
47 | assert.is.truthy(lfs.attributes("testrock-dev-1.rockspec")) | 47 | assert.is.truthy(lfs.attributes("testrock-dev-1.rockspec")) |
48 | end) | 48 | end) |
49 | 49 | ||
50 | it("runs with --tag", function() | 50 | it("runs with --tag", function() |
51 | finally(function() os.remove("testrock-2.3.0-1.rockspec") end) | 51 | finally(function() os.remove("testrock-2.3.0-1.rockspec") end) |
52 | assert.is_true(run.luarocks_bool("write_rockspec git://localhost/testrock --tag=v2.3.0")) | 52 | assert.is_true(run.luarocks_bool("write_rockspec git://localhost/testrock --tag=v2.3.0")) |
53 | assert.is.truthy(lfs.attributes("testrock-2.3.0-1.rockspec")) | 53 | assert.is.truthy(lfs.attributes("testrock-2.3.0-1.rockspec")) |
54 | -- TODO check contents | 54 | -- TODO check contents |
55 | end) | 55 | end) |
56 | 56 | ||
57 | it("runs with format flag", function() | 57 | it("runs with format flag", function() |
58 | finally(function() os.remove("testrock-dev-1.rockspec") end) | 58 | finally(function() os.remove("testrock-dev-1.rockspec") end) |
59 | assert.is_true(run.luarocks_bool("write_rockspec git://localhost/testrock --rockspec-format=1.1 --lua-versions=5.1,5.2")) | 59 | assert.is_true(run.luarocks_bool("write_rockspec git://localhost/testrock --rockspec-format=1.1 --lua-versions=5.1,5.2")) |
60 | assert.is.truthy(lfs.attributes("testrock-dev-1.rockspec")) | 60 | assert.is.truthy(lfs.attributes("testrock-dev-1.rockspec")) |
61 | -- TODO check contents | 61 | -- TODO check contents |
62 | end) | 62 | end) |
63 | 63 | ||
64 | it("runs with full flags", function() | 64 | it("runs with full flags", function() |
65 | finally(function() os.remove("testrock-dev-1.rockspec") end) | 65 | finally(function() os.remove("testrock-dev-1.rockspec") end) |
66 | assert.is_true(run.luarocks_bool("write_rockspec git://localhost/testrock --lua-versions=5.1,5.2 --license=\"MIT/X11\" " | 66 | assert.is_true(run.luarocks_bool("write_rockspec git://localhost/testrock --lua-versions=5.1,5.2 --license=\"MIT/X11\" " |