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 | |
parent | 2b56388e76952be52d849415b1ebae74b6dc4607 (diff) | |
download | luarocks-8f3ce333e7a1abfc6bf0488817d9eff4a2fd443f.tar.gz luarocks-8f3ce333e7a1abfc6bf0488817d9eff4a2fd443f.tar.bz2 luarocks-8f3ce333e7a1abfc6bf0488817d9eff4a2fd443f.zip |
editorconfig: trim trailing whitespace
103 files changed, 674 insertions, 673 deletions
diff --git a/.editorconfig b/.editorconfig index 4a191367..dc5519a7 100644 --- a/.editorconfig +++ b/.editorconfig | |||
@@ -1,6 +1,8 @@ | |||
1 | root = true | 1 | root = true |
2 | 2 | ||
3 | [*] | 3 | [*] |
4 | insert_final_newline = true | ||
5 | trim_trailing_whitespace = true | ||
4 | end_of_line = lf | 6 | end_of_line = lf |
5 | charset = utf-8 | 7 | charset = utf-8 |
6 | 8 | ||
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\" " |
diff --git a/src/luarocks/admin/cache.lua b/src/luarocks/admin/cache.lua index 1fd4d55a..10b273ea 100644 --- a/src/luarocks/admin/cache.lua +++ b/src/luarocks/admin/cache.lua | |||
@@ -24,7 +24,7 @@ function cache.get_server_urls(server, upload_server) | |||
24 | elseif upload_server.http then download_url = "http://"..upload_server.http | 24 | elseif upload_server.http then download_url = "http://"..upload_server.http |
25 | elseif upload_server.ftp then download_url = "ftp://"..upload_server.ftp | 25 | elseif upload_server.ftp then download_url = "ftp://"..upload_server.ftp |
26 | end | 26 | end |
27 | 27 | ||
28 | if upload_server.ftp then login_url = "ftp://"..upload_server.ftp | 28 | if upload_server.ftp then login_url = "ftp://"..upload_server.ftp |
29 | elseif upload_server.sftp then login_url = "sftp://"..upload_server.sftp | 29 | elseif upload_server.sftp then login_url = "sftp://"..upload_server.sftp |
30 | end | 30 | end |
@@ -57,7 +57,7 @@ local function download_cache(protocol, server_path, user, password) | |||
57 | return fs.execute(cfg.variables.RSYNC.." "..cfg.variables.RSYNCFLAGS.." -e ssh "..user.."@"..srv..":"..path.."/ ./") | 57 | return fs.execute(cfg.variables.RSYNC.." "..cfg.variables.RSYNCFLAGS.." -e ssh "..user.."@"..srv..":"..path.."/ ./") |
58 | elseif protocol == "file" then | 58 | elseif protocol == "file" then |
59 | return fs.copy_contents(server_path, ".") | 59 | return fs.copy_contents(server_path, ".") |
60 | else | 60 | else |
61 | local login_info = "" | 61 | local login_info = "" |
62 | if user then login_info = " --user="..user end | 62 | if user then login_info = " --user="..user end |
63 | if password then login_info = login_info .. " --password="..password end | 63 | if password then login_info = login_info .. " --password="..password end |
@@ -74,7 +74,7 @@ function cache.refresh_local_cache(url, given_user, given_password) | |||
74 | end | 74 | end |
75 | 75 | ||
76 | fs.change_dir(local_cache) | 76 | fs.change_dir(local_cache) |
77 | 77 | ||
78 | util.printout("Refreshing cache "..local_cache.."...") | 78 | util.printout("Refreshing cache "..local_cache.."...") |
79 | 79 | ||
80 | ok = download_cache(protocol, server_path, user, password) | 80 | ok = download_cache(protocol, server_path, user, password) |
diff --git a/src/luarocks/admin/cmd/add.lua b/src/luarocks/admin/cmd/add.lua index 5011c680..aa444c50 100644 --- a/src/luarocks/admin/cmd/add.lua +++ b/src/luarocks/admin/cmd/add.lua | |||
@@ -40,23 +40,23 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server, do | |||
40 | assert(type(rockfiles) == "table") | 40 | assert(type(rockfiles) == "table") |
41 | assert(type(server) == "string") | 41 | assert(type(server) == "string") |
42 | assert(type(upload_server) == "table" or not upload_server) | 42 | assert(type(upload_server) == "table" or not upload_server) |
43 | 43 | ||
44 | local download_url, login_url = cache.get_server_urls(server, upload_server) | 44 | local download_url, login_url = cache.get_server_urls(server, upload_server) |
45 | local at = fs.current_dir() | 45 | local at = fs.current_dir() |
46 | local refresh_fn = refresh and cache.refresh_local_cache or cache.split_server_url | 46 | local refresh_fn = refresh and cache.refresh_local_cache or cache.split_server_url |
47 | 47 | ||
48 | local local_cache, protocol, server_path, user, password = refresh_fn(download_url, cfg.upload_user, cfg.upload_password) | 48 | local local_cache, protocol, server_path, user, password = refresh_fn(download_url, cfg.upload_user, cfg.upload_password) |
49 | if not local_cache then | 49 | if not local_cache then |
50 | return nil, protocol | 50 | return nil, protocol |
51 | end | 51 | end |
52 | 52 | ||
53 | if not login_url then | 53 | if not login_url then |
54 | login_url = protocol.."://"..server_path | 54 | login_url = protocol.."://"..server_path |
55 | end | 55 | end |
56 | 56 | ||
57 | local ok, err = fs.change_dir(at) | 57 | local ok, err = fs.change_dir(at) |
58 | if not ok then return nil, err end | 58 | if not ok then return nil, err end |
59 | 59 | ||
60 | local files = {} | 60 | local files = {} |
61 | for _, rockfile in ipairs(rockfiles) do | 61 | for _, rockfile in ipairs(rockfiles) do |
62 | if fs.exists(rockfile) then | 62 | if fs.exists(rockfile) then |
@@ -77,9 +77,9 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server, do | |||
77 | 77 | ||
78 | util.printout("Updating manifest...") | 78 | util.printout("Updating manifest...") |
79 | writer.make_manifest(local_cache, "one", true) | 79 | writer.make_manifest(local_cache, "one", true) |
80 | 80 | ||
81 | zip_manifests() | 81 | zip_manifests() |
82 | 82 | ||
83 | if fs.exists("index.html") then | 83 | if fs.exists("index.html") then |
84 | do_index = true | 84 | do_index = true |
85 | end | 85 | end |
diff --git a/src/luarocks/admin/cmd/make_manifest.lua b/src/luarocks/admin/cmd/make_manifest.lua index b4f2ca5b..18f74b5d 100644 --- a/src/luarocks/admin/cmd/make_manifest.lua +++ b/src/luarocks/admin/cmd/make_manifest.lua | |||
@@ -27,13 +27,13 @@ end | |||
27 | -- or nil and an error message. | 27 | -- or nil and an error message. |
28 | function make_manifest.command(args) | 28 | function make_manifest.command(args) |
29 | local repo = args.repository or cfg.rocks_dir | 29 | local repo = args.repository or cfg.rocks_dir |
30 | 30 | ||
31 | util.printout("Making manifest for "..repo) | 31 | util.printout("Making manifest for "..repo) |
32 | 32 | ||
33 | if repo:match("/lib/luarocks") and not args.local_tree then | 33 | if repo:match("/lib/luarocks") and not args.local_tree then |
34 | util.warning("This looks like a local rocks tree, but you did not pass --local-tree.") | 34 | util.warning("This looks like a local rocks tree, but you did not pass --local-tree.") |
35 | end | 35 | end |
36 | 36 | ||
37 | local ok, err = writer.make_manifest(repo, deps.get_deps_mode(args), not args.local_tree) | 37 | local ok, err = writer.make_manifest(repo, deps.get_deps_mode(args), not args.local_tree) |
38 | if ok and not args.local_tree then | 38 | if ok and not args.local_tree then |
39 | util.printout("Generating index.html for "..repo) | 39 | util.printout("Generating index.html for "..repo) |
diff --git a/src/luarocks/admin/cmd/refresh_cache.lua b/src/luarocks/admin/cmd/refresh_cache.lua index 81959953..f8d51893 100644 --- a/src/luarocks/admin/cmd/refresh_cache.lua +++ b/src/luarocks/admin/cmd/refresh_cache.lua | |||
@@ -18,7 +18,7 @@ function refresh_cache.command(args) | |||
18 | local server, upload_server = cache.get_upload_server(args.server) | 18 | local server, upload_server = cache.get_upload_server(args.server) |
19 | if not server then return nil, upload_server end | 19 | if not server then return nil, upload_server end |
20 | local download_url = cache.get_server_urls(server, upload_server) | 20 | local download_url = cache.get_server_urls(server, upload_server) |
21 | 21 | ||
22 | local ok, err = cache.refresh_local_cache(download_url, cfg.upload_user, cfg.upload_password) | 22 | local ok, err = cache.refresh_local_cache(download_url, cfg.upload_user, cfg.upload_password) |
23 | if not ok then | 23 | if not ok then |
24 | return nil, err | 24 | return nil, err |
diff --git a/src/luarocks/admin/cmd/remove.lua b/src/luarocks/admin/cmd/remove.lua index de58f7a3..5d4c5fbb 100644 --- a/src/luarocks/admin/cmd/remove.lua +++ b/src/luarocks/admin/cmd/remove.lua | |||
@@ -32,7 +32,7 @@ local function remove_files_from_server(refresh, rockfiles, server, upload_serve | |||
32 | local download_url, login_url = cache.get_server_urls(server, upload_server) | 32 | local download_url, login_url = cache.get_server_urls(server, upload_server) |
33 | local at = fs.current_dir() | 33 | local at = fs.current_dir() |
34 | local refresh_fn = refresh and cache.refresh_local_cache or cache.split_server_url | 34 | local refresh_fn = refresh and cache.refresh_local_cache or cache.split_server_url |
35 | 35 | ||
36 | local local_cache, protocol, server_path, user, password = refresh_fn(download_url, cfg.upload_user, cfg.upload_password) | 36 | local local_cache, protocol, server_path, user, password = refresh_fn(download_url, cfg.upload_user, cfg.upload_password) |
37 | if not local_cache then | 37 | if not local_cache then |
38 | return nil, protocol | 38 | return nil, protocol |
@@ -40,10 +40,10 @@ local function remove_files_from_server(refresh, rockfiles, server, upload_serve | |||
40 | if protocol ~= "rsync" then | 40 | if protocol ~= "rsync" then |
41 | return nil, "This command requires 'rsync', check your configuration." | 41 | return nil, "This command requires 'rsync', check your configuration." |
42 | end | 42 | end |
43 | 43 | ||
44 | local ok, err = fs.change_dir(at) | 44 | local ok, err = fs.change_dir(at) |
45 | if not ok then return nil, err end | 45 | if not ok then return nil, err end |
46 | 46 | ||
47 | local nr_files = 0 | 47 | local nr_files = 0 |
48 | for _, rockfile in ipairs(rockfiles) do | 48 | for _, rockfile in ipairs(rockfiles) do |
49 | local basename = dir.base_name(rockfile) | 49 | local basename = dir.base_name(rockfile) |
diff --git a/src/luarocks/admin/index.lua b/src/luarocks/admin/index.lua index 76795104..64c8c1eb 100644 --- a/src/luarocks/admin/index.lua +++ b/src/luarocks/admin/index.lua | |||
@@ -87,7 +87,7 @@ local index_footer_begin = [[ | |||
87 | <a href="manifest">manifest file</a> | 87 | <a href="manifest">manifest file</a> |
88 | ]] | 88 | ]] |
89 | local index_manifest_ver = [[ | 89 | local index_manifest_ver = [[ |
90 | • <a href="manifest-$VER">Lua $VER manifest file</a> (<a href="manifest-$VER.zip">zip</a>) | 90 | • <a href="manifest-$VER">Lua $VER manifest file</a> (<a href="manifest-$VER.zip">zip</a>) |
91 | ]] | 91 | ]] |
92 | local index_footer_end = [[ | 92 | local index_footer_end = [[ |
93 | </p> | 93 | </p> |
@@ -129,7 +129,7 @@ function index.make_index(repo) | |||
129 | end | 129 | end |
130 | local manifest = manif.load_manifest(repo) | 130 | local manifest = manif.load_manifest(repo) |
131 | local out = io.open(dir.path(repo, "index.html"), "w") | 131 | local out = io.open(dir.path(repo, "index.html"), "w") |
132 | 132 | ||
133 | out:write(index_header) | 133 | out:write(index_header) |
134 | for package, version_list in util.sortedpairs(manifest.repository) do | 134 | for package, version_list in util.sortedpairs(manifest.repository) do |
135 | local latest_rockspec = nil | 135 | local latest_rockspec = nil |
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index ae529856..0aecca3e 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua | |||
@@ -328,7 +328,7 @@ local function write_rock_dir_files(rockspec, opts) | |||
328 | local name, version = rockspec.name, rockspec.version | 328 | local name, version = rockspec.name, rockspec.version |
329 | 329 | ||
330 | fs.copy(rockspec.local_abs_filename, path.rockspec_file(name, version), "read") | 330 | fs.copy(rockspec.local_abs_filename, path.rockspec_file(name, version), "read") |
331 | 331 | ||
332 | local deplock_file = deplocks.get_abs_filename(rockspec.name) | 332 | local deplock_file = deplocks.get_abs_filename(rockspec.name) |
333 | if deplock_file then | 333 | if deplock_file then |
334 | fs.copy(deplock_file, dir.path(path.install_dir(name, version), "luarocks.lock"), "read") | 334 | fs.copy(deplock_file, dir.path(path.install_dir(name, version), "luarocks.lock"), "read") |
@@ -375,7 +375,7 @@ function build.build_rockspec(rockspec, opts) | |||
375 | if opts.pin then | 375 | if opts.pin then |
376 | deplocks.init(rockspec.name, ".") | 376 | deplocks.init(rockspec.name, ".") |
377 | end | 377 | end |
378 | 378 | ||
379 | ok, err = process_dependencies(rockspec, opts) | 379 | ok, err = process_dependencies(rockspec, opts) |
380 | if not ok then return nil, err end | 380 | if not ok then return nil, err end |
381 | 381 | ||
@@ -385,7 +385,7 @@ function build.build_rockspec(rockspec, opts) | |||
385 | deplocks.write_file() | 385 | deplocks.write_file() |
386 | end | 386 | end |
387 | return name, version | 387 | return name, version |
388 | end | 388 | end |
389 | 389 | ||
390 | local dirs, err | 390 | local dirs, err |
391 | local rollback | 391 | local rollback |
@@ -405,13 +405,13 @@ function build.build_rockspec(rockspec, opts) | |||
405 | 405 | ||
406 | ok, err = build.apply_patches(rockspec) | 406 | ok, err = build.apply_patches(rockspec) |
407 | if not ok then return nil, err end | 407 | if not ok then return nil, err end |
408 | 408 | ||
409 | ok, err = check_macosx_deployment_target(rockspec) | 409 | ok, err = check_macosx_deployment_target(rockspec) |
410 | if not ok then return nil, err end | 410 | if not ok then return nil, err end |
411 | 411 | ||
412 | ok, err = run_build_driver(rockspec, opts.no_install) | 412 | ok, err = run_build_driver(rockspec, opts.no_install) |
413 | if not ok then return nil, err end | 413 | if not ok then return nil, err end |
414 | 414 | ||
415 | if opts.no_install then | 415 | if opts.no_install then |
416 | fs.pop_dir() | 416 | fs.pop_dir() |
417 | if opts.need_to_fetch then | 417 | if opts.need_to_fetch then |
@@ -422,7 +422,7 @@ function build.build_rockspec(rockspec, opts) | |||
422 | 422 | ||
423 | ok, err = install_files(rockspec, dirs) | 423 | ok, err = install_files(rockspec, dirs) |
424 | if not ok then return nil, err end | 424 | if not ok then return nil, err end |
425 | 425 | ||
426 | for _, d in pairs(dirs) do | 426 | for _, d in pairs(dirs) do |
427 | fs.remove_dir_if_empty(d.name) | 427 | fs.remove_dir_if_empty(d.name) |
428 | end | 428 | end |
@@ -441,7 +441,7 @@ function build.build_rockspec(rockspec, opts) | |||
441 | 441 | ||
442 | ok, err = repos.deploy_files(name, version, repos.should_wrap_bin_scripts(rockspec), opts.deps_mode) | 442 | ok, err = repos.deploy_files(name, version, repos.should_wrap_bin_scripts(rockspec), opts.deps_mode) |
443 | if not ok then return nil, err end | 443 | if not ok then return nil, err end |
444 | 444 | ||
445 | util.remove_scheduled_function(rollback) | 445 | util.remove_scheduled_function(rollback) |
446 | rollback = util.schedule_function(function() | 446 | rollback = util.schedule_function(function() |
447 | repos.delete_version(name, version, opts.deps_mode) | 447 | repos.delete_version(name, version, opts.deps_mode) |
diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index 6241c718..98db29da 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua | |||
@@ -266,7 +266,7 @@ function builtin.run(rockspec, no_install) | |||
266 | local lib_modules = {} | 266 | local lib_modules = {} |
267 | local luadir = path.lua_dir(rockspec.name, rockspec.version) | 267 | local luadir = path.lua_dir(rockspec.name, rockspec.version) |
268 | local libdir = path.lib_dir(rockspec.name, rockspec.version) | 268 | local libdir = path.lib_dir(rockspec.name, rockspec.version) |
269 | 269 | ||
270 | if not build.modules then | 270 | if not build.modules then |
271 | if rockspec:format_is_at_least("3.0") then | 271 | if rockspec:format_is_at_least("3.0") then |
272 | local libs, incdirs, libdirs = autoextract_libs(rockspec.external_dependencies, rockspec.variables) | 272 | local libs, incdirs, libdirs = autoextract_libs(rockspec.external_dependencies, rockspec.variables) |
diff --git a/src/luarocks/build/cmake.lua b/src/luarocks/build/cmake.lua index d7ecc83c..b7a4786e 100644 --- a/src/luarocks/build/cmake.lua +++ b/src/luarocks/build/cmake.lua | |||
@@ -36,7 +36,7 @@ function cmake.run(rockspec, no_install) | |||
36 | 36 | ||
37 | -- Execute cmake with variables. | 37 | -- Execute cmake with variables. |
38 | local args = "" | 38 | local args = "" |
39 | 39 | ||
40 | -- Try to pick the best generator. With msvc and x64, CMake does not select it by default so we need to be explicit. | 40 | -- Try to pick the best generator. With msvc and x64, CMake does not select it by default so we need to be explicit. |
41 | if cfg.cmake_generator then | 41 | if cfg.cmake_generator then |
42 | args = args .. ' -G"'..cfg.cmake_generator.. '"' | 42 | args = args .. ' -G"'..cfg.cmake_generator.. '"' |
@@ -71,7 +71,7 @@ function cmake.run(rockspec, no_install) | |||
71 | return nil, "Failed installing." | 71 | return nil, "Failed installing." |
72 | end | 72 | end |
73 | end | 73 | end |
74 | 74 | ||
75 | return true | 75 | return true |
76 | end | 76 | end |
77 | 77 | ||
diff --git a/src/luarocks/build/command.lua b/src/luarocks/build/command.lua index 309c4a16..b0c4aa79 100644 --- a/src/luarocks/build/command.lua +++ b/src/luarocks/build/command.lua | |||
@@ -14,7 +14,7 @@ function command.run(rockspec, not_install) | |||
14 | assert(rockspec:type() == "rockspec") | 14 | assert(rockspec:type() == "rockspec") |
15 | 15 | ||
16 | local build = rockspec.build | 16 | local build = rockspec.build |
17 | 17 | ||
18 | util.variable_substitutions(build, rockspec.variables) | 18 | util.variable_substitutions(build, rockspec.variables) |
19 | 19 | ||
20 | local env = { | 20 | local env = { |
diff --git a/src/luarocks/build/make.lua b/src/luarocks/build/make.lua index ccab1af0..4345ddff 100644 --- a/src/luarocks/build/make.lua +++ b/src/luarocks/build/make.lua | |||
@@ -13,7 +13,7 @@ local cfg = require("luarocks.core.cfg") | |||
13 | -- configured through variables.MAKE in the config files, or | 13 | -- configured through variables.MAKE in the config files, or |
14 | -- the appropriate platform-specific default). | 14 | -- the appropriate platform-specific default). |
15 | -- @param pass boolean: If true, run make; if false, do nothing. | 15 | -- @param pass boolean: If true, run make; if false, do nothing. |
16 | -- @param target string: The make target; an empty string indicates | 16 | -- @param target string: The make target; an empty string indicates |
17 | -- the default target. | 17 | -- the default target. |
18 | -- @param variables table: A table containing string-string key-value | 18 | -- @param variables table: A table containing string-string key-value |
19 | -- pairs representing variable assignments to be passed to make. | 19 | -- pairs representing variable assignments to be passed to make. |
@@ -42,7 +42,7 @@ function make.run(rockspec, not_install) | |||
42 | assert(rockspec:type() == "rockspec") | 42 | assert(rockspec:type() == "rockspec") |
43 | 43 | ||
44 | local build = rockspec.build | 44 | local build = rockspec.build |
45 | 45 | ||
46 | if build.build_pass == nil then build.build_pass = true end | 46 | if build.build_pass == nil then build.build_pass = true end |
47 | if build.install_pass == nil then build.install_pass = true end | 47 | if build.install_pass == nil then build.install_pass = true end |
48 | build.build_variables = build.build_variables or {} | 48 | build.build_variables = build.build_variables or {} |
@@ -56,9 +56,9 @@ function make.run(rockspec, not_install) | |||
56 | build.install_target = "-f "..makefile.." "..build.install_target | 56 | build.install_target = "-f "..makefile.." "..build.install_target |
57 | end | 57 | end |
58 | 58 | ||
59 | if build.variables then | 59 | if build.variables then |
60 | for var, val in pairs(build.variables) do | 60 | for var, val in pairs(build.variables) do |
61 | build.build_variables[var] = val | 61 | build.build_variables[var] = val |
62 | build.install_variables[var] = val | 62 | build.install_variables[var] = val |
63 | end | 63 | end |
64 | end | 64 | end |
@@ -67,9 +67,9 @@ function make.run(rockspec, not_install) | |||
67 | 67 | ||
68 | util.variable_substitutions(build.build_variables, rockspec.variables) | 68 | util.variable_substitutions(build.build_variables, rockspec.variables) |
69 | util.variable_substitutions(build.install_variables, rockspec.variables) | 69 | util.variable_substitutions(build.install_variables, rockspec.variables) |
70 | 70 | ||
71 | local auto_variables = { "CC" } | 71 | local auto_variables = { "CC" } |
72 | 72 | ||
73 | for _, variable in pairs(auto_variables) do | 73 | for _, variable in pairs(auto_variables) do |
74 | if not build.build_variables[variable] then | 74 | if not build.build_variables[variable] then |
75 | build.build_variables[variable] = rockspec.variables[variable] | 75 | build.build_variables[variable] = rockspec.variables[variable] |
@@ -79,7 +79,7 @@ function make.run(rockspec, not_install) | |||
79 | end | 79 | end |
80 | end | 80 | end |
81 | 81 | ||
82 | -- backwards compatibility | 82 | -- backwards compatibility |
83 | local make_cmd = cfg.make or rockspec.variables.MAKE | 83 | local make_cmd = cfg.make or rockspec.variables.MAKE |
84 | 84 | ||
85 | local ok = make_pass(make_cmd, build.build_pass, build.build_target, build.build_variables) | 85 | local ok = make_pass(make_cmd, build.build_pass, build.build_target, build.build_variables) |
diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index 21f35e20..7037c734 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua | |||
@@ -63,7 +63,7 @@ do | |||
63 | end | 63 | end |
64 | 64 | ||
65 | process_tree_args = function(args, project_dir) | 65 | process_tree_args = function(args, project_dir) |
66 | 66 | ||
67 | if args.global then | 67 | if args.global then |
68 | cfg.local_by_default = false | 68 | cfg.local_by_default = false |
69 | end | 69 | end |
@@ -221,7 +221,7 @@ do | |||
221 | end | 221 | end |
222 | return nil | 222 | return nil |
223 | end | 223 | end |
224 | 224 | ||
225 | local function find_default_lua_version(args, project_dir) | 225 | local function find_default_lua_version(args, project_dir) |
226 | if hardcoded.FORCE_CONFIG then | 226 | if hardcoded.FORCE_CONFIG then |
227 | return nil | 227 | return nil |
@@ -250,7 +250,7 @@ do | |||
250 | end | 250 | end |
251 | return nil | 251 | return nil |
252 | end | 252 | end |
253 | 253 | ||
254 | local function find_version_from_config(dirname) | 254 | local function find_version_from_config(dirname) |
255 | return fun.find(util.lua_versions("descending"), function(v) | 255 | return fun.find(util.lua_versions("descending"), function(v) |
256 | if util.exists(dir.path(dirname, ".luarocks", "config-"..v..".lua")) then | 256 | if util.exists(dir.path(dirname, ".luarocks", "config-"..v..".lua")) then |
@@ -258,12 +258,12 @@ do | |||
258 | end | 258 | end |
259 | end) | 259 | end) |
260 | end | 260 | end |
261 | 261 | ||
262 | local function detect_lua_via_args(args, project_dir) | 262 | local function detect_lua_via_args(args, project_dir) |
263 | local lua_version = args.lua_version | 263 | local lua_version = args.lua_version |
264 | or find_default_lua_version(args, project_dir) | 264 | or find_default_lua_version(args, project_dir) |
265 | or (project_dir and find_version_from_config(project_dir)) | 265 | or (project_dir and find_version_from_config(project_dir)) |
266 | 266 | ||
267 | if args.lua_dir then | 267 | if args.lua_dir then |
268 | local detected, err = util.find_lua(args.lua_dir, lua_version) | 268 | local detected, err = util.find_lua(args.lua_dir, lua_version) |
269 | if not detected then | 269 | if not detected then |
@@ -274,7 +274,7 @@ do | |||
274 | end | 274 | end |
275 | return detected | 275 | return detected |
276 | end | 276 | end |
277 | 277 | ||
278 | if lua_version then | 278 | if lua_version then |
279 | local detected = search_lua_in_path(lua_version) | 279 | local detected = search_lua_in_path(lua_version) |
280 | if detected then | 280 | if detected then |
@@ -284,10 +284,10 @@ do | |||
284 | lua_version = lua_version, | 284 | lua_version = lua_version, |
285 | } | 285 | } |
286 | end | 286 | end |
287 | 287 | ||
288 | return {} | 288 | return {} |
289 | end | 289 | end |
290 | 290 | ||
291 | detect_config_via_args = function(args) | 291 | detect_config_via_args = function(args) |
292 | local project_dir, given = find_project_dir(args.project_tree) | 292 | local project_dir, given = find_project_dir(args.project_tree) |
293 | local detected = detect_lua_via_args(args, project_dir) | 293 | local detected = detect_lua_via_args(args, project_dir) |
@@ -304,15 +304,15 @@ do | |||
304 | return detected | 304 | return detected |
305 | end | 305 | end |
306 | end | 306 | end |
307 | 307 | ||
308 | init_config = function(args) | 308 | init_config = function(args) |
309 | local detected = detect_config_via_args(args) | 309 | local detected = detect_config_via_args(args) |
310 | 310 | ||
311 | local ok, err = cfg.init(detected, util.warning) | 311 | local ok, err = cfg.init(detected, util.warning) |
312 | if not ok then | 312 | if not ok then |
313 | return nil, err | 313 | return nil, err |
314 | end | 314 | end |
315 | 315 | ||
316 | return (detected.lua_dir ~= nil) | 316 | return (detected.lua_dir ~= nil) |
317 | end | 317 | end |
318 | end | 318 | end |
diff --git a/src/luarocks/cmd/build.lua b/src/luarocks/cmd/build.lua index d1fccfdd..4500bcc9 100644 --- a/src/luarocks/cmd/build.lua +++ b/src/luarocks/cmd/build.lua | |||
@@ -145,7 +145,7 @@ function cmd_build.command(args) | |||
145 | return name, version, errcode | 145 | return name, version, errcode |
146 | end) | 146 | end) |
147 | end | 147 | end |
148 | 148 | ||
149 | local ok, err = fs.check_command_permissions(args) | 149 | local ok, err = fs.check_command_permissions(args) |
150 | if not ok then | 150 | if not ok then |
151 | return nil, err, cmd.errorcodes.PERMISSIONDENIED | 151 | return nil, err, cmd.errorcodes.PERMISSIONDENIED |
diff --git a/src/luarocks/cmd/config.lua b/src/luarocks/cmd/config.lua index ab1b9da7..6a73c7ff 100644 --- a/src/luarocks/cmd/config.lua +++ b/src/luarocks/cmd/config.lua | |||
@@ -29,7 +29,7 @@ Query information about the LuaRocks configuration. | |||
29 | * `lua_dir` is a special key as it checks for a valid Lua installation | 29 | * `lua_dir` is a special key as it checks for a valid Lua installation |
30 | (equivalent to --lua-dir) and sets several keys at once. | 30 | (equivalent to --lua-dir) and sets several keys at once. |
31 | * `lua_version` is a special key as it changes the default Lua version | 31 | * `lua_version` is a special key as it changes the default Lua version |
32 | used by LuaRocks commands (equivalent to passing --lua-version). | 32 | used by LuaRocks commands (equivalent to passing --lua-version). |
33 | 33 | ||
34 | Examples: | 34 | Examples: |
35 | luarocks config variables.OPENSSL_DIR /usr/local/openssl | 35 | luarocks config variables.OPENSSL_DIR /usr/local/openssl |
@@ -114,7 +114,7 @@ local function traverse_varstring(var, tbl, fn, missing_parent) | |||
114 | k, r = var:match("^([^[]+)(%[.*)$") | 114 | k, r = var:match("^([^[]+)(%[.*)$") |
115 | end | 115 | end |
116 | end | 116 | end |
117 | 117 | ||
118 | if k then | 118 | if k then |
119 | if not tbl[k] and missing_parent then | 119 | if not tbl[k] and missing_parent then |
120 | missing_parent(tbl, k) | 120 | missing_parent(tbl, k) |
@@ -131,7 +131,7 @@ local function traverse_varstring(var, tbl, fn, missing_parent) | |||
131 | if i then | 131 | if i then |
132 | var = tonumber(i) | 132 | var = tonumber(i) |
133 | end | 133 | end |
134 | 134 | ||
135 | return fn(tbl, var) | 135 | return fn(tbl, var) |
136 | end | 136 | end |
137 | 137 | ||
@@ -179,12 +179,12 @@ local function write_entries(keys, scope, do_unset) | |||
179 | if scope == "project" and not cfg.config_files.project then | 179 | if scope == "project" and not cfg.config_files.project then |
180 | return nil, "Current directory is not part of a project. You may want to run `luarocks init`." | 180 | return nil, "Current directory is not part of a project. You may want to run `luarocks init`." |
181 | end | 181 | end |
182 | 182 | ||
183 | local tbl, err = persist.load_config_file_if_basic(cfg.config_files[scope].file, cfg) | 183 | local tbl, err = persist.load_config_file_if_basic(cfg.config_files[scope].file, cfg) |
184 | if not tbl then | 184 | if not tbl then |
185 | return nil, err | 185 | return nil, err |
186 | end | 186 | end |
187 | 187 | ||
188 | for var, val in util.sortedpairs(keys) do | 188 | for var, val in util.sortedpairs(keys) do |
189 | traverse_varstring(var, tbl, function(t, k) | 189 | traverse_varstring(var, tbl, function(t, k) |
190 | if do_unset then | 190 | if do_unset then |
@@ -242,7 +242,7 @@ end | |||
242 | function config_cmd.command(args) | 242 | function config_cmd.command(args) |
243 | deps.check_lua_incdir(cfg.variables, args.lua_version or cfg.lua_version) | 243 | deps.check_lua_incdir(cfg.variables, args.lua_version or cfg.lua_version) |
244 | deps.check_lua_libdir(cfg.variables, args.lua_version or cfg.lua_version) | 244 | deps.check_lua_libdir(cfg.variables, args.lua_version or cfg.lua_version) |
245 | 245 | ||
246 | -- deprecated flags | 246 | -- deprecated flags |
247 | if args.lua_incdir then | 247 | if args.lua_incdir then |
248 | print(cfg.variables.LUA_INCDIR) | 248 | print(cfg.variables.LUA_INCDIR) |
@@ -287,7 +287,7 @@ function config_cmd.command(args) | |||
287 | end | 287 | end |
288 | print("Lua version will default to " .. args.value .. " in " .. prefix) | 288 | print("Lua version will default to " .. args.value .. " in " .. prefix) |
289 | end | 289 | end |
290 | 290 | ||
291 | if args.key == "lua_dir" and args.value then | 291 | if args.key == "lua_dir" and args.value then |
292 | local scope = get_scope(args) | 292 | local scope = get_scope(args) |
293 | local keys = { | 293 | local keys = { |
diff --git a/src/luarocks/cmd/doc.lua b/src/luarocks/cmd/doc.lua index 2ab7e43c..ae471230 100644 --- a/src/luarocks/cmd/doc.lua +++ b/src/luarocks/cmd/doc.lua | |||
@@ -67,7 +67,7 @@ function doc.command(args) | |||
67 | return try_to_open_homepage(args.rock, args.namespace, args.version) | 67 | return try_to_open_homepage(args.rock, args.namespace, args.version) |
68 | end | 68 | end |
69 | local name, version = iname, iversion | 69 | local name, version = iname, iversion |
70 | 70 | ||
71 | local rockspec, err = fetch.load_local_rockspec(path.rockspec_file(name, version, repo)) | 71 | local rockspec, err = fetch.load_local_rockspec(path.rockspec_file(name, version, repo)) |
72 | if not rockspec then return nil,err end | 72 | if not rockspec then return nil,err end |
73 | local descript = rockspec.description or {} | 73 | local descript = rockspec.description or {} |
@@ -77,7 +77,7 @@ function doc.command(args) | |||
77 | end | 77 | end |
78 | 78 | ||
79 | local directory = path.install_dir(name, version, repo) | 79 | local directory = path.install_dir(name, version, repo) |
80 | 80 | ||
81 | local docdir | 81 | local docdir |
82 | local directories = { "doc", "docs" } | 82 | local directories = { "doc", "docs" } |
83 | for _, d in ipairs(directories) do | 83 | for _, d in ipairs(directories) do |
@@ -101,7 +101,7 @@ function doc.command(args) | |||
101 | local htmlpatt = "%.html?$" | 101 | local htmlpatt = "%.html?$" |
102 | local extensions = { htmlpatt, "%.md$", "%.txt$", "%.textile$", "" } | 102 | local extensions = { htmlpatt, "%.md$", "%.txt$", "%.textile$", "" } |
103 | local basenames = { "index", "readme", "manual" } | 103 | local basenames = { "index", "readme", "manual" } |
104 | 104 | ||
105 | local porcelain = args.porcelain | 105 | local porcelain = args.porcelain |
106 | if #files > 0 then | 106 | if #files > 0 then |
107 | util.title("Documentation files for "..name.." "..version, porcelain) | 107 | util.title("Documentation files for "..name.." "..version, porcelain) |
@@ -116,11 +116,11 @@ function doc.command(args) | |||
116 | end | 116 | end |
117 | end | 117 | end |
118 | end | 118 | end |
119 | 119 | ||
120 | if args.list then | 120 | if args.list then |
121 | return true | 121 | return true |
122 | end | 122 | end |
123 | 123 | ||
124 | for _, extension in ipairs(extensions) do | 124 | for _, extension in ipairs(extensions) do |
125 | for _, basename in ipairs(basenames) do | 125 | for _, basename in ipairs(basenames) do |
126 | local filename = basename..extension | 126 | local filename = basename..extension |
diff --git a/src/luarocks/cmd/download.lua b/src/luarocks/cmd/download.lua index 1f844595..eae82439 100644 --- a/src/luarocks/cmd/download.lua +++ b/src/luarocks/cmd/download.lua | |||
@@ -43,7 +43,7 @@ function cmd_download.command(args) | |||
43 | elseif args.arch then | 43 | elseif args.arch then |
44 | arch = args.arch | 44 | arch = args.arch |
45 | end | 45 | end |
46 | 46 | ||
47 | local dl, err = download.download(arch, args.name, args.namespace, args.version, args.all, args.check_lua_versions) | 47 | local dl, err = download.download(arch, args.name, args.namespace, args.version, args.all, args.check_lua_versions) |
48 | return dl and true, err | 48 | return dl and true, err |
49 | end | 49 | end |
diff --git a/src/luarocks/cmd/init.lua b/src/luarocks/cmd/init.lua index 5f269e22..af88760f 100644 --- a/src/luarocks/cmd/init.lua +++ b/src/luarocks/cmd/init.lua | |||
@@ -30,7 +30,7 @@ local function write_gitignore(entries) | |||
30 | fd:close() | 30 | fd:close() |
31 | gitignore = "\n" .. gitignore .. "\n" | 31 | gitignore = "\n" .. gitignore .. "\n" |
32 | end | 32 | end |
33 | 33 | ||
34 | fd = io.open(".gitignore", gitignore and "a" or "w") | 34 | fd = io.open(".gitignore", gitignore and "a" or "w") |
35 | for _, entry in ipairs(entries) do | 35 | for _, entry in ipairs(entries) do |
36 | entry = "/" .. entry | 36 | entry = "/" .. entry |
@@ -64,7 +64,7 @@ function init.command(args) | |||
64 | if not ok then | 64 | if not ok then |
65 | return nil, err | 65 | return nil, err |
66 | end | 66 | end |
67 | 67 | ||
68 | local has_rockspec = false | 68 | local has_rockspec = false |
69 | for file in fs.dir() do | 69 | for file in fs.dir() do |
70 | if file:match("%.rockspec$") then | 70 | if file:match("%.rockspec$") then |
@@ -97,7 +97,7 @@ function init.command(args) | |||
97 | fs.delete(lua_wrapper) | 97 | fs.delete(lua_wrapper) |
98 | fs.delete(config_file) | 98 | fs.delete(config_file) |
99 | end | 99 | end |
100 | 100 | ||
101 | local config_tbl, err = persist.load_config_file_if_basic(config_file, cfg) | 101 | local config_tbl, err = persist.load_config_file_if_basic(config_file, cfg) |
102 | if config_tbl then | 102 | if config_tbl then |
103 | local globals = { | 103 | local globals = { |
@@ -131,7 +131,7 @@ function init.command(args) | |||
131 | else | 131 | else |
132 | util.printout("Will not attempt to overwrite " .. config_file) | 132 | util.printout("Will not attempt to overwrite " .. config_file) |
133 | end | 133 | end |
134 | 134 | ||
135 | ok, err = persist.save_default_lua_version(".luarocks", cfg.lua_version) | 135 | ok, err = persist.save_default_lua_version(".luarocks", cfg.lua_version) |
136 | if not ok then | 136 | if not ok then |
137 | util.printout("Failed setting default Lua version: " .. err) | 137 | util.printout("Failed setting default Lua version: " .. err) |
@@ -158,7 +158,7 @@ function init.command(args) | |||
158 | write_lua_wrapper = false | 158 | write_lua_wrapper = false |
159 | end | 159 | end |
160 | end | 160 | end |
161 | 161 | ||
162 | if write_lua_wrapper then | 162 | if write_lua_wrapper then |
163 | local interp = dir.path(cfg.variables["LUA_BINDIR"], cfg.lua_interpreter) | 163 | local interp = dir.path(cfg.variables["LUA_BINDIR"], cfg.lua_interpreter) |
164 | if util.check_lua_version(interp, cfg.lua_version) then | 164 | if util.check_lua_version(interp, cfg.lua_version) then |
diff --git a/src/luarocks/cmd/install.lua b/src/luarocks/cmd/install.lua index 760649b0..da9e1ce3 100644 --- a/src/luarocks/cmd/install.lua +++ b/src/luarocks/cmd/install.lua | |||
@@ -75,16 +75,16 @@ function install.install_binary_rock(rock_file, opts) | |||
75 | if not name then | 75 | if not name then |
76 | return nil, "Filename "..rock_file.." does not match format 'name-version-revision.arch.rock'." | 76 | return nil, "Filename "..rock_file.." does not match format 'name-version-revision.arch.rock'." |
77 | end | 77 | end |
78 | 78 | ||
79 | if arch ~= "all" and arch ~= cfg.arch then | 79 | if arch ~= "all" and arch ~= cfg.arch then |
80 | return nil, "Incompatible architecture "..arch, "arch" | 80 | return nil, "Incompatible architecture "..arch, "arch" |
81 | end | 81 | end |
82 | if repos.is_installed(name, version) then | 82 | if repos.is_installed(name, version) then |
83 | repos.delete_version(name, version, opts.deps_mode) | 83 | repos.delete_version(name, version, opts.deps_mode) |
84 | end | 84 | end |
85 | 85 | ||
86 | local install_dir = path.install_dir(name, version) | 86 | local install_dir = path.install_dir(name, version) |
87 | 87 | ||
88 | local rollback = util.schedule_function(function() | 88 | local rollback = util.schedule_function(function() |
89 | fs.delete(install_dir) | 89 | fs.delete(install_dir) |
90 | fs.remove_dir_if_empty(path.versions_dir(name)) | 90 | fs.remove_dir_if_empty(path.versions_dir(name)) |
@@ -139,7 +139,7 @@ end | |||
139 | -- @param rock_file string: local or remote filename of a rock. | 139 | -- @param rock_file string: local or remote filename of a rock. |
140 | -- @param opts table: installation options | 140 | -- @param opts table: installation options |
141 | -- @return (string, string) or (nil, string, [string]): Name and version of | 141 | -- @return (string, string) or (nil, string, [string]): Name and version of |
142 | -- the rock whose dependencies were installed if succeeded or nil and an error message | 142 | -- the rock whose dependencies were installed if succeeded or nil and an error message |
143 | -- followed by an error code. | 143 | -- followed by an error code. |
144 | function install.install_binary_rock_deps(rock_file, opts) | 144 | function install.install_binary_rock_deps(rock_file, opts) |
145 | assert(type(rock_file) == "string") | 145 | assert(type(rock_file) == "string") |
@@ -149,7 +149,7 @@ function install.install_binary_rock_deps(rock_file, opts) | |||
149 | if not name then | 149 | if not name then |
150 | return nil, "Filename "..rock_file.." does not match format 'name-version-revision.arch.rock'." | 150 | return nil, "Filename "..rock_file.." does not match format 'name-version-revision.arch.rock'." |
151 | end | 151 | end |
152 | 152 | ||
153 | if arch ~= "all" and arch ~= cfg.arch then | 153 | if arch ~= "all" and arch ~= cfg.arch then |
154 | return nil, "Incompatible architecture "..arch, "arch" | 154 | return nil, "Incompatible architecture "..arch, "arch" |
155 | end | 155 | end |
@@ -158,7 +158,7 @@ function install.install_binary_rock_deps(rock_file, opts) | |||
158 | 158 | ||
159 | local ok, err, errcode = fetch.fetch_and_unpack_rock(rock_file, install_dir, opts.verify) | 159 | local ok, err, errcode = fetch.fetch_and_unpack_rock(rock_file, install_dir, opts.verify) |
160 | if not ok then return nil, err, errcode end | 160 | if not ok then return nil, err, errcode end |
161 | 161 | ||
162 | local rockspec, err = fetch.load_rockspec(path.rockspec_file(name, version)) | 162 | local rockspec, err = fetch.load_rockspec(path.rockspec_file(name, version)) |
163 | if err then | 163 | if err then |
164 | return nil, "Failed loading rockspec for installed package: "..err, errcode | 164 | return nil, "Failed loading rockspec for installed package: "..err, errcode |
diff --git a/src/luarocks/cmd/lint.lua b/src/luarocks/cmd/lint.lua index 20c842ff..47a3da90 100644 --- a/src/luarocks/cmd/lint.lua +++ b/src/luarocks/cmd/lint.lua | |||
@@ -33,8 +33,8 @@ function lint.command(args) | |||
33 | end | 33 | end |
34 | 34 | ||
35 | local ok = true | 35 | local ok = true |
36 | 36 | ||
37 | -- This should have been done in the type checker, | 37 | -- This should have been done in the type checker, |
38 | -- but it would break compatibility of other commands. | 38 | -- but it would break compatibility of other commands. |
39 | -- Making 'lint' alone be stricter shouldn't be a problem, | 39 | -- Making 'lint' alone be stricter shouldn't be a problem, |
40 | -- because extra-strict checks is what lint-type commands | 40 | -- because extra-strict checks is what lint-type commands |
diff --git a/src/luarocks/cmd/list.lua b/src/luarocks/cmd/list.lua index aa815ea3..7b2682f6 100644 --- a/src/luarocks/cmd/list.lua +++ b/src/luarocks/cmd/list.lua | |||
@@ -36,13 +36,13 @@ local function check_outdated(trees, query) | |||
36 | 36 | ||
37 | local query_available = queries.new(name:lower()) | 37 | local query_available = queries.new(name:lower()) |
38 | local results_available, err = search.search_repos(query_available) | 38 | local results_available, err = search.search_repos(query_available) |
39 | 39 | ||
40 | if results_available[name] then | 40 | if results_available[name] then |
41 | local available_versions = util.keys(results_available[name]) | 41 | local available_versions = util.keys(results_available[name]) |
42 | table.sort(available_versions, vers.compare_versions) | 42 | table.sort(available_versions, vers.compare_versions) |
43 | local latest_available = available_versions[1] | 43 | local latest_available = available_versions[1] |
44 | local latest_available_repo = results_available[name][latest_available][1].repo | 44 | local latest_available_repo = results_available[name][latest_available][1].repo |
45 | 45 | ||
46 | if vers.compare_versions(latest_available, latest_installed) then | 46 | if vers.compare_versions(latest_available, latest_installed) then |
47 | table.insert(outdated, { name = name, installed = latest_installed, available = latest_available, repo = latest_available_repo }) | 47 | table.insert(outdated, { name = name, installed = latest_installed, available = latest_available, repo = latest_available_repo }) |
48 | end | 48 | end |
@@ -76,11 +76,11 @@ function list.command(args) | |||
76 | trees = { args.tree } | 76 | trees = { args.tree } |
77 | title = title .. " in " .. args.tree | 77 | title = title .. " in " .. args.tree |
78 | end | 78 | end |
79 | 79 | ||
80 | if args.outdated then | 80 | if args.outdated then |
81 | return list_outdated(trees, query, args.porcelain) | 81 | return list_outdated(trees, query, args.porcelain) |
82 | end | 82 | end |
83 | 83 | ||
84 | local results = {} | 84 | local results = {} |
85 | for _, tree in ipairs(trees) do | 85 | for _, tree in ipairs(trees) do |
86 | local ok, err, errcode = search.local_manifest_search(results, path.rocks_dir(tree), query) | 86 | local ok, err, errcode = search.local_manifest_search(results, path.rocks_dir(tree), query) |
diff --git a/src/luarocks/cmd/new_version.lua b/src/luarocks/cmd/new_version.lua index fc15ef46..49479910 100644 --- a/src/luarocks/cmd/new_version.lua +++ b/src/luarocks/cmd/new_version.lua | |||
@@ -60,7 +60,7 @@ local function try_replace(tbl, field, old, new) | |||
60 | if new_field ~= old_field then | 60 | if new_field ~= old_field then |
61 | util.printout("Guessing new '"..field.."' field as "..new_field) | 61 | util.printout("Guessing new '"..field.."' field as "..new_field) |
62 | tbl[field] = new_field | 62 | tbl[field] = new_field |
63 | return true | 63 | return true |
64 | end | 64 | end |
65 | return false | 65 | return false |
66 | end | 66 | end |
@@ -104,7 +104,7 @@ local function check_url_and_update_md5(out_rs, invalid_is_error) | |||
104 | end | 104 | end |
105 | end | 105 | end |
106 | end | 106 | end |
107 | 107 | ||
108 | local function update_source_section(out_rs, url, tag, old_ver, new_ver) | 108 | local function update_source_section(out_rs, url, tag, old_ver, new_ver) |
109 | if tag then | 109 | if tag then |
110 | out_rs.source.tag = tag | 110 | out_rs.source.tag = tag |
@@ -144,7 +144,7 @@ local function update_source_section(out_rs, url, tag, old_ver, new_ver) | |||
144 | end | 144 | end |
145 | return true | 145 | return true |
146 | end | 146 | end |
147 | 147 | ||
148 | function new_version.command(args) | 148 | function new_version.command(args) |
149 | if not args.rock then | 149 | if not args.rock then |
150 | local err | 150 | local err |
@@ -153,7 +153,7 @@ function new_version.command(args) | |||
153 | return nil, err | 153 | return nil, err |
154 | end | 154 | end |
155 | end | 155 | end |
156 | 156 | ||
157 | local filename, err | 157 | local filename, err |
158 | if args.rock:match("rockspec$") then | 158 | if args.rock:match("rockspec$") then |
159 | filename, err = fetch.fetch_url(args.rock) | 159 | filename, err = fetch.fetch_url(args.rock) |
@@ -178,7 +178,7 @@ function new_version.command(args) | |||
178 | if args.tag and not args.new_version then | 178 | if args.tag and not args.new_version then |
179 | args.new_version = args.tag:gsub("^v", "") | 179 | args.new_version = args.tag:gsub("^v", "") |
180 | end | 180 | end |
181 | 181 | ||
182 | local out_dir | 182 | local out_dir |
183 | if args.dir then | 183 | if args.dir then |
184 | out_dir = dir.normalize(args.dir) | 184 | out_dir = dir.normalize(args.dir) |
@@ -196,7 +196,7 @@ function new_version.command(args) | |||
196 | new_rev = tonumber(old_rev) + 1 | 196 | new_rev = tonumber(old_rev) + 1 |
197 | end | 197 | end |
198 | local new_rockver = new_ver:gsub("-", "") | 198 | local new_rockver = new_ver:gsub("-", "") |
199 | 199 | ||
200 | local out_rs, err = persist.load_into_table(filename) | 200 | local out_rs, err = persist.load_into_table(filename) |
201 | local out_name = out_rs.package:lower() | 201 | local out_name = out_rs.package:lower() |
202 | out_rs.version = new_rockver.."-"..new_rev | 202 | out_rs.version = new_rockver.."-"..new_rev |
@@ -207,21 +207,21 @@ function new_version.command(args) | |||
207 | if out_rs.build and out_rs.build.type == "module" then | 207 | if out_rs.build and out_rs.build.type == "module" then |
208 | out_rs.build.type = "builtin" | 208 | out_rs.build.type = "builtin" |
209 | end | 209 | end |
210 | 210 | ||
211 | local out_filename = out_name.."-"..new_rockver.."-"..new_rev..".rockspec" | 211 | local out_filename = out_name.."-"..new_rockver.."-"..new_rev..".rockspec" |
212 | if out_dir then | 212 | if out_dir then |
213 | out_filename = dir.path(out_dir, out_filename) | 213 | out_filename = dir.path(out_dir, out_filename) |
214 | fs.make_dir(out_dir) | 214 | fs.make_dir(out_dir) |
215 | end | 215 | end |
216 | persist.save_from_table(out_filename, out_rs, type_rockspec.order) | 216 | persist.save_from_table(out_filename, out_rs, type_rockspec.order) |
217 | 217 | ||
218 | util.printout("Wrote "..out_filename) | 218 | util.printout("Wrote "..out_filename) |
219 | 219 | ||
220 | local valid_out_rs, err = fetch.load_local_rockspec(out_filename) | 220 | local valid_out_rs, err = fetch.load_local_rockspec(out_filename) |
221 | if not valid_out_rs then | 221 | if not valid_out_rs then |
222 | return nil, "Failed loading generated rockspec: "..err | 222 | return nil, "Failed loading generated rockspec: "..err |
223 | end | 223 | end |
224 | 224 | ||
225 | return true | 225 | return true |
226 | end | 226 | end |
227 | 227 | ||
diff --git a/src/luarocks/cmd/path.lua b/src/luarocks/cmd/path.lua index 9d6a8217..9b6fee71 100644 --- a/src/luarocks/cmd/path.lua +++ b/src/luarocks/cmd/path.lua | |||
@@ -10,11 +10,11 @@ local fs = require("luarocks.fs") | |||
10 | function path_cmd.add_to_parser(parser) | 10 | function path_cmd.add_to_parser(parser) |
11 | local cmd = parser:command("path", [[ | 11 | local cmd = parser:command("path", [[ |
12 | Returns the package path currently configured for this installation | 12 | Returns the package path currently configured for this installation |
13 | of LuaRocks, formatted as shell commands to update LUA_PATH and LUA_CPATH. | 13 | of LuaRocks, formatted as shell commands to update LUA_PATH and LUA_CPATH. |
14 | 14 | ||
15 | On Unix systems, you may run: | 15 | On Unix systems, you may run: |
16 | eval `luarocks path` | 16 | eval `luarocks path` |
17 | And on Windows: | 17 | And on Windows: |
18 | luarocks path > "%temp%\_lrp.bat" && call "%temp%\_lrp.bat" && del "%temp%\_lrp.bat"]], | 18 | luarocks path > "%temp%\_lrp.bat" && call "%temp%\_lrp.bat" && del "%temp%\_lrp.bat"]], |
19 | util.see_also()) | 19 | util.see_also()) |
20 | :summary("Return the currently configured package path.") | 20 | :summary("Return the currently configured package path.") |
@@ -56,7 +56,7 @@ function path_cmd.command(args) | |||
56 | lr_cpath = lr_cpath .. ";" .. package.cpath | 56 | lr_cpath = lr_cpath .. ";" .. package.cpath |
57 | lr_bin = lr_bin .. path_sep .. clean_path | 57 | lr_bin = lr_bin .. path_sep .. clean_path |
58 | end | 58 | end |
59 | 59 | ||
60 | local lpath_var, lcpath_var = util.lua_path_variables() | 60 | local lpath_var, lcpath_var = util.lua_path_variables() |
61 | 61 | ||
62 | util.printout(fs.export_cmd(lpath_var, util.cleanup_path(lr_path, ';', cfg.lua_version, args.append))) | 62 | util.printout(fs.export_cmd(lpath_var, util.cleanup_path(lr_path, ';', cfg.lua_version, args.append))) |
diff --git a/src/luarocks/cmd/purge.lua b/src/luarocks/cmd/purge.lua index fa4be4d7..2b5873d7 100644 --- a/src/luarocks/cmd/purge.lua +++ b/src/luarocks/cmd/purge.lua | |||
@@ -42,7 +42,7 @@ function purge.command(args) | |||
42 | if type(tree) ~= "string" then | 42 | if type(tree) ~= "string" then |
43 | return nil, "The --tree argument is mandatory. "..util.see_help("purge") | 43 | return nil, "The --tree argument is mandatory. "..util.see_help("purge") |
44 | end | 44 | end |
45 | 45 | ||
46 | local results = {} | 46 | local results = {} |
47 | if not fs.is_dir(tree) then | 47 | if not fs.is_dir(tree) then |
48 | return nil, "Directory not found: "..tree | 48 | return nil, "Directory not found: "..tree |
diff --git a/src/luarocks/cmd/remove.lua b/src/luarocks/cmd/remove.lua index 46f3e4a6..17723ec9 100644 --- a/src/luarocks/cmd/remove.lua +++ b/src/luarocks/cmd/remove.lua | |||
@@ -42,10 +42,10 @@ end | |||
42 | function cmd_remove.command(args) | 42 | function cmd_remove.command(args) |
43 | local name = args.rock | 43 | local name = args.rock |
44 | local deps_mode = deps.get_deps_mode(args) | 44 | local deps_mode = deps.get_deps_mode(args) |
45 | 45 | ||
46 | local ok, err = fs.check_command_permissions(args) | 46 | local ok, err = fs.check_command_permissions(args) |
47 | if not ok then return nil, err, cmd.errorcodes.PERMISSIONDENIED end | 47 | if not ok then return nil, err, cmd.errorcodes.PERMISSIONDENIED end |
48 | 48 | ||
49 | local rock_type = name:match("%.(rock)$") or name:match("%.(rockspec)$") | 49 | local rock_type = name:match("%.(rock)$") or name:match("%.(rockspec)$") |
50 | local version = args.version | 50 | local version = args.version |
51 | local filename = name | 51 | local filename = name |
diff --git a/src/luarocks/cmd/search.lua b/src/luarocks/cmd/search.lua index 181fdacc..6cab6d80 100644 --- a/src/luarocks/cmd/search.lua +++ b/src/luarocks/cmd/search.lua | |||
@@ -63,7 +63,7 @@ function cmd_search.command(args) | |||
63 | if not args.name and not args.all then | 63 | if not args.name and not args.all then |
64 | return nil, "Enter name and version or use --all. "..util.see_help("search") | 64 | return nil, "Enter name and version or use --all. "..util.see_help("search") |
65 | end | 65 | end |
66 | 66 | ||
67 | local query = queries.new(name, args.namespace, args.version, true) | 67 | local query = queries.new(name, args.namespace, args.version, true) |
68 | local result_tree, err = search.search_repos(query) | 68 | local result_tree, err = search.search_repos(query) |
69 | local porcelain = args.porcelain | 69 | local porcelain = args.porcelain |
diff --git a/src/luarocks/cmd/show.lua b/src/luarocks/cmd/show.lua index c1c155e2..d93459fd 100644 --- a/src/luarocks/cmd/show.lua +++ b/src/luarocks/cmd/show.lua | |||
@@ -100,7 +100,7 @@ local function keys_as_string(t, sep) | |||
100 | return table.concat(keys, sep or " ") | 100 | return table.concat(keys, sep or " ") |
101 | end | 101 | end |
102 | 102 | ||
103 | local function word_wrap(line) | 103 | local function word_wrap(line) |
104 | local width = tonumber(os.getenv("COLUMNS")) or 80 | 104 | local width = tonumber(os.getenv("COLUMNS")) or 80 |
105 | if width > 80 then width = 80 end | 105 | if width > 80 then width = 80 end |
106 | if #line > width then | 106 | if #line > width then |
@@ -265,7 +265,7 @@ end | |||
265 | -- @return boolean: True if succeeded, nil on errors. | 265 | -- @return boolean: True if succeeded, nil on errors. |
266 | function show.command(args) | 266 | function show.command(args) |
267 | local query = queries.new(args.rock, args.namespace, args.version, true) | 267 | local query = queries.new(args.rock, args.namespace, args.version, true) |
268 | 268 | ||
269 | local name, version, repo, repo_url = search.pick_installed_rock(query, args.tree) | 269 | local name, version, repo, repo_url = search.pick_installed_rock(query, args.tree) |
270 | if not name then | 270 | if not name then |
271 | return nil, version | 271 | return nil, version |
diff --git a/src/luarocks/cmd/test.lua b/src/luarocks/cmd/test.lua index 7a1ffda2..21838c90 100644 --- a/src/luarocks/cmd/test.lua +++ b/src/luarocks/cmd/test.lua | |||
@@ -33,9 +33,9 @@ function cmd_test.command(args) | |||
33 | if args.rockspec and args.rockspec:match("rockspec$") then | 33 | if args.rockspec and args.rockspec:match("rockspec$") then |
34 | return test.run_test_suite(args.rockspec, args.test_type, args.args) | 34 | return test.run_test_suite(args.rockspec, args.test_type, args.args) |
35 | end | 35 | end |
36 | 36 | ||
37 | table.insert(args.args, 1, args.rockspec) | 37 | table.insert(args.args, 1, args.rockspec) |
38 | 38 | ||
39 | local rockspec, err = util.get_default_rockspec() | 39 | local rockspec, err = util.get_default_rockspec() |
40 | if not rockspec then | 40 | if not rockspec then |
41 | return nil, err | 41 | return nil, err |
diff --git a/src/luarocks/cmd/unpack.lua b/src/luarocks/cmd/unpack.lua index b9bec4a6..94da2c9f 100644 --- a/src/luarocks/cmd/unpack.lua +++ b/src/luarocks/cmd/unpack.lua | |||
@@ -32,7 +32,7 @@ end | |||
32 | -- files specified in the rockspec, and unpack them inside the directory. | 32 | -- files specified in the rockspec, and unpack them inside the directory. |
33 | -- @param rockspec_file string: The URL for a rockspec file. | 33 | -- @param rockspec_file string: The URL for a rockspec file. |
34 | -- @param dir_name string: The directory where to store and unpack files. | 34 | -- @param dir_name string: The directory where to store and unpack files. |
35 | -- @return table or (nil, string): the loaded rockspec table or | 35 | -- @return table or (nil, string): the loaded rockspec table or |
36 | -- nil and an error message. | 36 | -- nil and an error message. |
37 | local function unpack_rockspec(rockspec_file, dir_name) | 37 | local function unpack_rockspec(rockspec_file, dir_name) |
38 | assert(type(rockspec_file) == "string") | 38 | assert(type(rockspec_file) == "string") |
@@ -61,7 +61,7 @@ end | |||
61 | -- @param dir_name string: The directory where to unpack. | 61 | -- @param dir_name string: The directory where to unpack. |
62 | -- @param kind string: the kind of rock file, as in the second-level | 62 | -- @param kind string: the kind of rock file, as in the second-level |
63 | -- extension in the rock filename (eg. "src", "all", "linux-x86") | 63 | -- extension in the rock filename (eg. "src", "all", "linux-x86") |
64 | -- @return table or (nil, string): the loaded rockspec table or | 64 | -- @return table or (nil, string): the loaded rockspec table or |
65 | -- nil and an error message. | 65 | -- nil and an error message. |
66 | local function unpack_rock(rock_file, dir_name, kind) | 66 | local function unpack_rock(rock_file, dir_name, kind) |
67 | assert(type(rock_file) == "string") | 67 | assert(type(rock_file) == "string") |
@@ -102,7 +102,7 @@ end | |||
102 | -- by an error message. | 102 | -- by an error message. |
103 | local function run_unpacker(file, force) | 103 | local function run_unpacker(file, force) |
104 | assert(type(file) == "string") | 104 | assert(type(file) == "string") |
105 | 105 | ||
106 | local base_name = dir.base_name(file) | 106 | local base_name = dir.base_name(file) |
107 | local dir_name, kind, extension = base_name:match("(.*)%.([^.]+)%.(rock)$") | 107 | local dir_name, kind, extension = base_name:match("(.*)%.([^.]+)%.(rock)$") |
108 | if not extension then | 108 | if not extension then |
@@ -139,7 +139,7 @@ local function run_unpacker(file, force) | |||
139 | return nil, "Failed copying unpacked rockspec into unpacked source directory." | 139 | return nil, "Failed copying unpacked rockspec into unpacked source directory." |
140 | end | 140 | end |
141 | end | 141 | end |
142 | util.printout() | 142 | util.printout() |
143 | util.printout("Done. You may now enter directory ") | 143 | util.printout("Done. You may now enter directory ") |
144 | util.printout(dir.path(dir_name, rockspec.source.dir)) | 144 | util.printout(dir.path(dir_name, rockspec.source.dir)) |
145 | util.printout("and type 'luarocks make' to build.") | 145 | util.printout("and type 'luarocks make' to build.") |
diff --git a/src/luarocks/cmd/upload.lua b/src/luarocks/cmd/upload.lua index 6e3877ba..da51b401 100644 --- a/src/luarocks/cmd/upload.lua +++ b/src/luarocks/cmd/upload.lua | |||
@@ -53,7 +53,7 @@ function upload.command(args) | |||
53 | version = rockspec.version | 53 | version = rockspec.version |
54 | }) | 54 | }) |
55 | if not res then return nil, err end | 55 | if not res then return nil, err end |
56 | 56 | ||
57 | if not res.module then | 57 | if not res.module then |
58 | util.printout("Will create new module (" .. tostring(rockspec.package) .. ")") | 58 | util.printout("Will create new module (" .. tostring(rockspec.package) .. ")") |
59 | end | 59 | end |
@@ -87,7 +87,7 @@ function upload.command(args) | |||
87 | util.printout("Signed packed rock: "..rock_sigfname) | 87 | util.printout("Signed packed rock: "..rock_sigfname) |
88 | end | 88 | end |
89 | end | 89 | end |
90 | 90 | ||
91 | local multipart = require("luarocks.upload.multipart") | 91 | local multipart = require("luarocks.upload.multipart") |
92 | 92 | ||
93 | res, err = api:method("upload", nil, { | 93 | res, err = api:method("upload", nil, { |
@@ -95,13 +95,13 @@ function upload.command(args) | |||
95 | rockspec_sig = sigfname and multipart.new_file(sigfname), | 95 | rockspec_sig = sigfname and multipart.new_file(sigfname), |
96 | }) | 96 | }) |
97 | if not res then return nil, err end | 97 | if not res then return nil, err end |
98 | 98 | ||
99 | if res.is_new and #res.manifests == 0 then | 99 | if res.is_new and #res.manifests == 0 then |
100 | util.printerr("Warning: module not added to root manifest due to name taken.") | 100 | util.printerr("Warning: module not added to root manifest due to name taken.") |
101 | end | 101 | end |
102 | 102 | ||
103 | local module_url = res.module_url | 103 | local module_url = res.module_url |
104 | 104 | ||
105 | if rock_fname then | 105 | if rock_fname then |
106 | if (not res.version) or (not res.version.id) then | 106 | if (not res.version) or (not res.version.id) then |
107 | return nil, "Invalid response from server." | 107 | return nil, "Invalid response from server." |
@@ -113,7 +113,7 @@ function upload.command(args) | |||
113 | }) | 113 | }) |
114 | if not res then return nil, err end | 114 | if not res then return nil, err end |
115 | end | 115 | end |
116 | 116 | ||
117 | util.printout() | 117 | util.printout() |
118 | util.printout("Done: " .. tostring(module_url)) | 118 | util.printout("Done: " .. tostring(module_url)) |
119 | util.printout() | 119 | util.printout() |
diff --git a/src/luarocks/cmd/write_rockspec.lua b/src/luarocks/cmd/write_rockspec.lua index 5d5404e5..871cdd44 100644 --- a/src/luarocks/cmd/write_rockspec.lua +++ b/src/luarocks/cmd/write_rockspec.lua | |||
@@ -137,7 +137,7 @@ do | |||
137 | return url | 137 | return url |
138 | end | 138 | end |
139 | end | 139 | end |
140 | 140 | ||
141 | local function detect_scm_url(directory) | 141 | local function detect_scm_url(directory) |
142 | return detect_url_from_command("git", "config --get remote.origin.url", directory) or | 142 | return detect_url_from_command("git", "config --get remote.origin.url", directory) or |
143 | detect_url_from_command("hg", "paths default", directory) | 143 | detect_url_from_command("hg", "paths default", directory) |
@@ -230,7 +230,7 @@ local function fill_as_builtin(rockspec, libs) | |||
230 | libdirs[#libdirs+1] = "$("..upper.."_LIBDIR)" | 230 | libdirs[#libdirs+1] = "$("..upper.."_LIBDIR)" |
231 | end | 231 | end |
232 | end | 232 | end |
233 | 233 | ||
234 | rockspec.build.modules, rockspec.build.install, rockspec.build.copy_directories = builtin.autodetect_modules(libs, incdirs, libdirs) | 234 | rockspec.build.modules, rockspec.build.install, rockspec.build.copy_directories = builtin.autodetect_modules(libs, incdirs, libdirs) |
235 | end | 235 | end |
236 | 236 | ||
@@ -302,10 +302,10 @@ function write_rockspec.command(args) | |||
302 | version = version or "dev" | 302 | version = version or "dev" |
303 | 303 | ||
304 | local filename = args.output or dir.path(fs.current_dir(), name:lower().."-"..version.."-1.rockspec") | 304 | local filename = args.output or dir.path(fs.current_dir(), name:lower().."-"..version.."-1.rockspec") |
305 | 305 | ||
306 | local url = detect_url(location) | 306 | local url = detect_url(location) |
307 | local homepage = detect_homepage(url, args.homepage) | 307 | local homepage = detect_homepage(url, args.homepage) |
308 | 308 | ||
309 | local rockspec, err = rockspecs.from_persisted_table(filename, { | 309 | local rockspec, err = rockspecs.from_persisted_table(filename, { |
310 | rockspec_format = args.rockspec_format, | 310 | rockspec_format = args.rockspec_format, |
311 | package = name, | 311 | package = name, |
@@ -327,11 +327,11 @@ function write_rockspec.command(args) | |||
327 | }) | 327 | }) |
328 | assert(not err, err) | 328 | assert(not err, err) |
329 | rockspec.source.protocol = protocol | 329 | rockspec.source.protocol = protocol |
330 | 330 | ||
331 | if not next(rockspec.dependencies) then | 331 | if not next(rockspec.dependencies) then |
332 | util.warning("Please specify supported Lua versions with --lua-versions=<ver>. "..util.see_help("write_rockspec")) | 332 | util.warning("Please specify supported Lua versions with --lua-versions=<ver>. "..util.see_help("write_rockspec")) |
333 | end | 333 | end |
334 | 334 | ||
335 | local local_dir = location | 335 | local local_dir = location |
336 | 336 | ||
337 | if location:match("://") then | 337 | if location:match("://") then |
@@ -354,11 +354,11 @@ function write_rockspec.command(args) | |||
354 | local_dir = nil | 354 | local_dir = nil |
355 | end | 355 | end |
356 | end | 356 | end |
357 | 357 | ||
358 | if not local_dir then | 358 | if not local_dir then |
359 | local_dir = "." | 359 | local_dir = "." |
360 | end | 360 | end |
361 | 361 | ||
362 | local libs = nil | 362 | local libs = nil |
363 | if args.lib then | 363 | if args.lib then |
364 | libs = {} | 364 | libs = {} |
@@ -391,16 +391,16 @@ function write_rockspec.command(args) | |||
391 | util.title("Please fill in the source.license field manually or use --license.") | 391 | util.title("Please fill in the source.license field manually or use --license.") |
392 | end | 392 | end |
393 | end | 393 | end |
394 | 394 | ||
395 | fill_as_builtin(rockspec, libs) | 395 | fill_as_builtin(rockspec, libs) |
396 | 396 | ||
397 | rockspec_cleanup(rockspec) | 397 | rockspec_cleanup(rockspec) |
398 | 398 | ||
399 | persist.save_from_table(filename, rockspec, type_rockspec.order) | 399 | persist.save_from_table(filename, rockspec, type_rockspec.order) |
400 | 400 | ||
401 | util.printout() | 401 | util.printout() |
402 | util.printout("Wrote template at "..filename.." -- you should now edit and finish it.") | 402 | util.printout("Wrote template at "..filename.." -- you should now edit and finish it.") |
403 | util.printout() | 403 | util.printout() |
404 | 404 | ||
405 | return true | 405 | return true |
406 | end | 406 | end |
diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua index d65681c1..c19f7d3b 100644 --- a/src/luarocks/core/cfg.lua +++ b/src/luarocks/core/cfg.lua | |||
@@ -558,7 +558,7 @@ local cfg = {} | |||
558 | 558 | ||
559 | --- Initializes the LuaRocks configuration for variables, paths | 559 | --- Initializes the LuaRocks configuration for variables, paths |
560 | -- and OS detection. | 560 | -- and OS detection. |
561 | -- @param detected table containing information detected about the | 561 | -- @param detected table containing information detected about the |
562 | -- environment. All fields below are optional: | 562 | -- environment. All fields below are optional: |
563 | -- * lua_version (in x.y format, e.g. "5.3") | 563 | -- * lua_version (in x.y format, e.g. "5.3") |
564 | -- * lua_bindir (e.g. "/usr/local/bin") | 564 | -- * lua_bindir (e.g. "/usr/local/bin") |
@@ -575,7 +575,7 @@ function cfg.init(detected, warning) | |||
575 | if not hc_ok then | 575 | if not hc_ok then |
576 | hardcoded = {} | 576 | hardcoded = {} |
577 | end | 577 | end |
578 | 578 | ||
579 | local init = cfg.init | 579 | local init = cfg.init |
580 | 580 | ||
581 | ---------------------------------------- | 581 | ---------------------------------------- |
@@ -595,7 +595,7 @@ function cfg.init(detected, warning) | |||
595 | end | 595 | end |
596 | 596 | ||
597 | -- Use detected values as defaults, overridable via config files or CLI args | 597 | -- Use detected values as defaults, overridable via config files or CLI args |
598 | 598 | ||
599 | local first_arg = get_first_arg() | 599 | local first_arg = get_first_arg() |
600 | 600 | ||
601 | cfg.lua_version = detected.lua_version or hardcoded.LUA_VERSION or _VERSION:sub(5) | 601 | cfg.lua_version = detected.lua_version or hardcoded.LUA_VERSION or _VERSION:sub(5) |
@@ -778,7 +778,7 @@ function cfg.init(detected, warning) | |||
778 | and home_config_file | 778 | and home_config_file |
779 | or sys_config_file), | 779 | or sys_config_file), |
780 | } | 780 | } |
781 | 781 | ||
782 | cfg.cache = {} | 782 | cfg.cache = {} |
783 | 783 | ||
784 | ---------------------------------------- | 784 | ---------------------------------------- |
diff --git a/src/luarocks/core/dir.lua b/src/luarocks/core/dir.lua index d346ec4f..765a0e58 100644 --- a/src/luarocks/core/dir.lua +++ b/src/luarocks/core/dir.lua | |||
@@ -6,7 +6,7 @@ local require = nil | |||
6 | 6 | ||
7 | local function unquote(c) | 7 | local function unquote(c) |
8 | local first, last = c:sub(1,1), c:sub(-1) | 8 | local first, last = c:sub(1,1), c:sub(-1) |
9 | if (first == '"' and last == '"') or | 9 | if (first == '"' and last == '"') or |
10 | (first == "'" and last == "'") then | 10 | (first == "'" and last == "'") then |
11 | return c:sub(2,-2) | 11 | return c:sub(2,-2) |
12 | end | 12 | end |
@@ -40,7 +40,7 @@ end | |||
40 | -- @return string, string: the protocol, and the pathname without the protocol. | 40 | -- @return string, string: the protocol, and the pathname without the protocol. |
41 | function dir.split_url(url) | 41 | function dir.split_url(url) |
42 | assert(type(url) == "string") | 42 | assert(type(url) == "string") |
43 | 43 | ||
44 | url = unquote(url) | 44 | url = unquote(url) |
45 | local protocol, pathname = url:match("^([^:]*)://(.*)") | 45 | local protocol, pathname = url:match("^([^:]*)://(.*)") |
46 | if not protocol then | 46 | if not protocol then |
diff --git a/src/luarocks/core/manif.lua b/src/luarocks/core/manif.lua index fe0a95fa..3925f636 100644 --- a/src/luarocks/core/manif.lua +++ b/src/luarocks/core/manif.lua | |||
@@ -94,7 +94,7 @@ function manif.scan_dependencies(name, version, tree_manifests, dest) | |||
94 | if pkgdeps then | 94 | if pkgdeps then |
95 | for _, dep in ipairs(pkgdeps) do | 95 | for _, dep in ipairs(pkgdeps) do |
96 | local pkg, constraints = dep.name, dep.constraints | 96 | local pkg, constraints = dep.name, dep.constraints |
97 | 97 | ||
98 | for _, t in ipairs(tree_manifests) do | 98 | for _, t in ipairs(tree_manifests) do |
99 | local entries = t.manifest.repository[pkg] | 99 | local entries = t.manifest.repository[pkg] |
100 | if entries then | 100 | if entries then |
diff --git a/src/luarocks/core/persist.lua b/src/luarocks/core/persist.lua index 59089818..57e7b5d4 100644 --- a/src/luarocks/core/persist.lua +++ b/src/luarocks/core/persist.lua | |||
@@ -66,9 +66,9 @@ function persist.load_into_table(filename, tbl) | |||
66 | } | 66 | } |
67 | local save_mt = getmetatable(result) | 67 | local save_mt = getmetatable(result) |
68 | setmetatable(result, globals_mt) | 68 | setmetatable(result, globals_mt) |
69 | 69 | ||
70 | local ok, err, errcode = persist.run_file(filename, result) | 70 | local ok, err, errcode = persist.run_file(filename, result) |
71 | 71 | ||
72 | setmetatable(result, save_mt) | 72 | setmetatable(result, save_mt) |
73 | 73 | ||
74 | if not ok then | 74 | if not ok then |
diff --git a/src/luarocks/core/sysdetect.lua b/src/luarocks/core/sysdetect.lua index 534ab89f..7358c29f 100644 --- a/src/luarocks/core/sysdetect.lua +++ b/src/luarocks/core/sysdetect.lua | |||
@@ -15,7 +15,7 @@ end | |||
15 | local function read_int8(fd) | 15 | local function read_int8(fd) |
16 | if io.type(fd) == "closed file" then | 16 | if io.type(fd) == "closed file" then |
17 | return nil | 17 | return nil |
18 | end | 18 | end |
19 | local s = fd:read(1) | 19 | local s = fd:read(1) |
20 | if not s then | 20 | if not s then |
21 | fd:close() | 21 | fd:close() |
@@ -44,7 +44,7 @@ end | |||
44 | local function read(fd, bytes, endian) | 44 | local function read(fd, bytes, endian) |
45 | if io.type(fd) == "closed file" then | 45 | if io.type(fd) == "closed file" then |
46 | return nil | 46 | return nil |
47 | end | 47 | end |
48 | local s = fd:read(bytes) | 48 | local s = fd:read(bytes) |
49 | if not s | 49 | if not s |
50 | then fd:close() | 50 | then fd:close() |
@@ -138,7 +138,7 @@ end | |||
138 | local function detect_elf_system(fd, hdr, sections) | 138 | local function detect_elf_system(fd, hdr, sections) |
139 | local system = e_osabi[hdr.osabi] | 139 | local system = e_osabi[hdr.osabi] |
140 | local endian = hdr.endian | 140 | local endian = hdr.endian |
141 | 141 | ||
142 | if system == "sysv" then | 142 | if system == "sysv" then |
143 | local abitag = sections[".note.ABI-tag"] | 143 | local abitag = sections[".note.ABI-tag"] |
144 | if abitag then | 144 | if abitag then |
@@ -154,7 +154,7 @@ local function detect_elf_system(fd, hdr, sections) | |||
154 | elseif sections[".note.openbsd.ident"] then | 154 | elseif sections[".note.openbsd.ident"] then |
155 | return "openbsd" | 155 | return "openbsd" |
156 | end | 156 | end |
157 | 157 | ||
158 | local gnu_version_r = sections[".gnu.version_r"] | 158 | local gnu_version_r = sections[".gnu.version_r"] |
159 | if gnu_version_r then | 159 | if gnu_version_r then |
160 | 160 | ||
@@ -170,7 +170,7 @@ local function detect_elf_system(fd, hdr, sections) | |||
170 | 170 | ||
171 | fd:seek("set", dynstr + vn_file) | 171 | fd:seek("set", dynstr + vn_file) |
172 | local libname = fd:read(64):gsub("%z.*", "") | 172 | local libname = fd:read(64):gsub("%z.*", "") |
173 | 173 | ||
174 | if hdr.e_type == 0x03 and libname == "libroot.so" then | 174 | if hdr.e_type == 0x03 and libname == "libroot.so" then |
175 | return "haiku" | 175 | return "haiku" |
176 | elseif libname:match("linux") then | 176 | elseif libname:match("linux") then |
@@ -190,7 +190,7 @@ local function detect_elf_system(fd, hdr, sections) | |||
190 | end | 190 | end |
191 | end | 191 | end |
192 | end | 192 | end |
193 | 193 | ||
194 | return system | 194 | return system |
195 | end | 195 | end |
196 | 196 | ||
@@ -207,7 +207,7 @@ local function read_elf_header(fd) | |||
207 | if not hdr.osabi then | 207 | if not hdr.osabi then |
208 | return nil | 208 | return nil |
209 | end | 209 | end |
210 | 210 | ||
211 | local endian = hdr.endian | 211 | local endian = hdr.endian |
212 | fd:seek("set", 0x10) | 212 | fd:seek("set", 0x10) |
213 | hdr.e_type = read(fd, 2, endian) | 213 | hdr.e_type = read(fd, 2, endian) |
@@ -221,10 +221,10 @@ local function read_elf_header(fd) | |||
221 | if elfversion ~= 1 then | 221 | if elfversion ~= 1 then |
222 | return nil | 222 | return nil |
223 | end | 223 | end |
224 | 224 | ||
225 | local word = (hdr.bits == 1) and 4 or 8 | 225 | local word = (hdr.bits == 1) and 4 or 8 |
226 | hdr.word = word | 226 | hdr.word = word |
227 | 227 | ||
228 | hdr.e_entry = read(fd, word, endian) | 228 | hdr.e_entry = read(fd, word, endian) |
229 | hdr.e_phoff = read(fd, word, endian) | 229 | hdr.e_phoff = read(fd, word, endian) |
230 | hdr.e_shoff = read(fd, word, endian) | 230 | hdr.e_shoff = read(fd, word, endian) |
@@ -235,7 +235,7 @@ local function read_elf_header(fd) | |||
235 | hdr.e_shentsize = read(fd, 2, endian) | 235 | hdr.e_shentsize = read(fd, 2, endian) |
236 | hdr.e_shnum = read(fd, 2, endian) | 236 | hdr.e_shnum = read(fd, 2, endian) |
237 | hdr.e_shstrndx = read(fd, 2, endian) | 237 | hdr.e_shstrndx = read(fd, 2, endian) |
238 | 238 | ||
239 | return hdr, processor | 239 | return hdr, processor |
240 | end | 240 | end |
241 | 241 | ||
@@ -323,7 +323,7 @@ local function detect_pe(fd) | |||
323 | fd:seek("set", peoffset + 4) -- move to position of Machine section | 323 | fd:seek("set", peoffset + 4) -- move to position of Machine section |
324 | local machine = read(fd, 2, LITTLE) | 324 | local machine = read(fd, 2, LITTLE) |
325 | local processor = pe_machine[machine] | 325 | local processor = pe_machine[machine] |
326 | 326 | ||
327 | local rdata_pos = fd:read(736):match(".rdata%z%z............(....)") | 327 | local rdata_pos = fd:read(736):match(".rdata%z%z............(....)") |
328 | if rdata_pos then | 328 | if rdata_pos then |
329 | rdata_pos = bytes2number(rdata_pos, LITTLE) | 329 | rdata_pos = bytes2number(rdata_pos, LITTLE) |
@@ -333,7 +333,7 @@ local function detect_pe(fd) | |||
333 | system = "cygwin" | 333 | system = "cygwin" |
334 | end | 334 | end |
335 | end | 335 | end |
336 | 336 | ||
337 | return system, processor or "unknown" | 337 | return system, processor or "unknown" |
338 | end | 338 | end |
339 | 339 | ||
@@ -363,7 +363,7 @@ local cache_processor | |||
363 | function sysdetect.detect(input_file) | 363 | function sysdetect.detect(input_file) |
364 | local dirsep = package.config:sub(1,1) | 364 | local dirsep = package.config:sub(1,1) |
365 | local files | 365 | local files |
366 | 366 | ||
367 | if input_file then | 367 | if input_file then |
368 | files = { input_file } | 368 | files = { input_file } |
369 | else | 369 | else |
diff --git a/src/luarocks/core/util.lua b/src/luarocks/core/util.lua index dae8cfab..384a6eba 100644 --- a/src/luarocks/core/util.lua +++ b/src/luarocks/core/util.lua | |||
@@ -5,7 +5,7 @@ local require = nil | |||
5 | -------------------------------------------------------------------------------- | 5 | -------------------------------------------------------------------------------- |
6 | 6 | ||
7 | --- Run a process and read a its output. | 7 | --- Run a process and read a its output. |
8 | -- Equivalent to io.popen(cmd):read("*l"), except that it | 8 | -- Equivalent to io.popen(cmd):read("*l"), except that it |
9 | -- closes the fd right away. | 9 | -- closes the fd right away. |
10 | -- @param cmd string: The command to execute | 10 | -- @param cmd string: The command to execute |
11 | -- @param spec string: "*l" by default, to read a single line. | 11 | -- @param spec string: "*l" by default, to read a single line. |
@@ -63,7 +63,7 @@ function util.show_table(t, tname, top_indent) | |||
63 | local autoref -- for self references | 63 | local autoref -- for self references |
64 | 64 | ||
65 | local function is_empty_table(tbl) return next(tbl) == nil end | 65 | local function is_empty_table(tbl) return next(tbl) == nil end |
66 | 66 | ||
67 | local function basic_serialize(o) | 67 | local function basic_serialize(o) |
68 | local so = tostring(o) | 68 | local so = tostring(o) |
69 | if type(o) == "function" then | 69 | if type(o) == "function" then |
@@ -71,7 +71,7 @@ function util.show_table(t, tname, top_indent) | |||
71 | -- info.name is nil because o is not a calling level | 71 | -- info.name is nil because o is not a calling level |
72 | if info.what == "C" then | 72 | if info.what == "C" then |
73 | return ("%q"):format(so .. ", C function") | 73 | return ("%q"):format(so .. ", C function") |
74 | else | 74 | else |
75 | -- the information is defined through lines | 75 | -- the information is defined through lines |
76 | return ("%q"):format(so .. ", defined in (" .. info.linedefined .. "-" .. info.lastlinedefined .. ")" .. info.source) | 76 | return ("%q"):format(so .. ", defined in (" .. info.linedefined .. "-" .. info.lastlinedefined .. ")" .. info.source) |
77 | end | 77 | end |
@@ -81,14 +81,14 @@ function util.show_table(t, tname, top_indent) | |||
81 | return ("%q"):format(so) | 81 | return ("%q"):format(so) |
82 | end | 82 | end |
83 | end | 83 | end |
84 | 84 | ||
85 | local function add_to_cart(value, name, indent, saved, field) | 85 | local function add_to_cart(value, name, indent, saved, field) |
86 | indent = indent or "" | 86 | indent = indent or "" |
87 | saved = saved or {} | 87 | saved = saved or {} |
88 | field = field or name | 88 | field = field or name |
89 | 89 | ||
90 | cart = cart .. indent .. field | 90 | cart = cart .. indent .. field |
91 | 91 | ||
92 | if type(value) ~= "table" then | 92 | if type(value) ~= "table" then |
93 | cart = cart .. " = " .. basic_serialize(value) .. ";\n" | 93 | cart = cart .. " = " .. basic_serialize(value) .. ";\n" |
94 | else | 94 | else |
@@ -113,7 +113,7 @@ function util.show_table(t, tname, top_indent) | |||
113 | end | 113 | end |
114 | end | 114 | end |
115 | end | 115 | end |
116 | 116 | ||
117 | tname = tname or "__unnamed__" | 117 | tname = tname or "__unnamed__" |
118 | if type(t) ~= "table" then | 118 | if type(t) ~= "table" then |
119 | return tname .. " = " .. basic_serialize(t) | 119 | return tname .. " = " .. basic_serialize(t) |
@@ -189,7 +189,7 @@ function util.cleanup_path(list, sep, lua_version, keep_first) | |||
189 | local part = parts[i]:gsub("//", "/") | 189 | local part = parts[i]:gsub("//", "/") |
190 | if lua_version then | 190 | if lua_version then |
191 | part = part:gsub("/lua/([%d.]+)/", function(part_version) | 191 | part = part:gsub("/lua/([%d.]+)/", function(part_version) |
192 | if part_version:sub(1, #lua_version) ~= lua_version then | 192 | if part_version:sub(1, #lua_version) ~= lua_version then |
193 | return "/lua/"..lua_version.."/" | 193 | return "/lua/"..lua_version.."/" |
194 | end | 194 | end |
195 | end) | 195 | end) |
diff --git a/src/luarocks/core/vers.lua b/src/luarocks/core/vers.lua index e680f70b..e7251bb5 100644 --- a/src/luarocks/core/vers.lua +++ b/src/luarocks/core/vers.lua | |||
@@ -63,11 +63,11 @@ local version_mt = { | |||
63 | return not (v2 < v1) | 63 | return not (v2 < v1) |
64 | end, | 64 | end, |
65 | --- Return version as a string. | 65 | --- Return version as a string. |
66 | -- @param v The version table. | 66 | -- @param v The version table. |
67 | -- @return The string representation. | 67 | -- @return The string representation. |
68 | __tostring = function(v) | 68 | __tostring = function(v) |
69 | return v.string | 69 | return v.string |
70 | end, | 70 | end, |
71 | } | 71 | } |
72 | 72 | ||
73 | local version_cache = {} | 73 | local version_cache = {} |
@@ -102,7 +102,7 @@ function vers.parse_version(vstring) | |||
102 | version[i] = version[i] and version[i] + number/100000 or number | 102 | version[i] = version[i] and version[i] + number/100000 or number |
103 | i = i + 1 | 103 | i = i + 1 |
104 | end | 104 | end |
105 | 105 | ||
106 | -- trim leading and trailing spaces | 106 | -- trim leading and trailing spaces |
107 | local v = vstring:match("^%s*(.*)%s*$") | 107 | local v = vstring:match("^%s*(.*)%s*$") |
108 | version.string = v | 108 | version.string = v |
@@ -164,7 +164,7 @@ local function partial_match(version, requested) | |||
164 | if type(version) ~= "table" then version = vers.parse_version(version) end | 164 | if type(version) ~= "table" then version = vers.parse_version(version) end |
165 | if type(requested) ~= "table" then requested = vers.parse_version(requested) end | 165 | if type(requested) ~= "table" then requested = vers.parse_version(requested) end |
166 | if not version or not requested then return false end | 166 | if not version or not requested then return false end |
167 | 167 | ||
168 | for i, ri in ipairs(requested) do | 168 | for i, ri in ipairs(requested) do |
169 | local vi = version[i] or 0 | 169 | local vi = version[i] or 0 |
170 | if ri ~= vi then return false end | 170 | if ri ~= vi then return false end |
diff --git a/src/luarocks/deplocks.lua b/src/luarocks/deplocks.lua index f6449986..d62908f4 100644 --- a/src/luarocks/deplocks.lua +++ b/src/luarocks/deplocks.lua | |||
@@ -46,10 +46,10 @@ function deplocks.load(root_rock_name, dirname) | |||
46 | -- could not open, maybe file does not exist | 46 | -- could not open, maybe file does not exist |
47 | return true, nil | 47 | return true, nil |
48 | end | 48 | end |
49 | 49 | ||
50 | deplock_abs_filename = fs.absolute_name(filename) | 50 | deplock_abs_filename = fs.absolute_name(filename) |
51 | deplock_root_rock_name = root_rock_name | 51 | deplock_root_rock_name = root_rock_name |
52 | 52 | ||
53 | deptable = result | 53 | deptable = result |
54 | return true, filename | 54 | return true, filename |
55 | end | 55 | end |
@@ -58,7 +58,7 @@ function deplocks.add(depskey, name, version) | |||
58 | if deptable_mode == "locked" then | 58 | if deptable_mode == "locked" then |
59 | return | 59 | return |
60 | end | 60 | end |
61 | 61 | ||
62 | local dk = deptable[depskey] | 62 | local dk = deptable[depskey] |
63 | if not dk then | 63 | if not dk then |
64 | dk = {} | 64 | dk = {} |
@@ -89,7 +89,7 @@ end | |||
89 | 89 | ||
90 | -- a table-like interface to deplocks | 90 | -- a table-like interface to deplocks |
91 | function deplocks.proxy(depskey) | 91 | function deplocks.proxy(depskey) |
92 | return setmetatable({}, { | 92 | return setmetatable({}, { |
93 | __index = function(_, k) | 93 | __index = function(_, k) |
94 | return deplocks.get(depskey, k) | 94 | return deplocks.get(depskey, k) |
95 | end, | 95 | end, |
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index f6de0db8..7e7b69e6 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua | |||
@@ -47,7 +47,7 @@ local function prepare_get_versions(deps_mode, rocks_provided, depskey, blacklis | |||
47 | end | 47 | end |
48 | versions, locations = manif.get_versions(dep, deps_mode) | 48 | versions, locations = manif.get_versions(dep, deps_mode) |
49 | end | 49 | end |
50 | 50 | ||
51 | if blacklist and blacklist[dep.name] then | 51 | if blacklist and blacklist[dep.name] then |
52 | local orig_versions = versions | 52 | local orig_versions = versions |
53 | versions = {} | 53 | versions = {} |
@@ -57,9 +57,9 @@ local function prepare_get_versions(deps_mode, rocks_provided, depskey, blacklis | |||
57 | end | 57 | end |
58 | end | 58 | end |
59 | end | 59 | end |
60 | 60 | ||
61 | local lockversion = deplocks.get(depskey, dep.name) | 61 | local lockversion = deplocks.get(depskey, dep.name) |
62 | 62 | ||
63 | return versions, locations, lockversion, provided ~= nil | 63 | return versions, locations, lockversion, provided ~= nil |
64 | end | 64 | end |
65 | end | 65 | end |
@@ -81,9 +81,9 @@ end | |||
81 | local function match_dep(dep, get_versions) | 81 | local function match_dep(dep, get_versions) |
82 | assert(type(dep) == "table") | 82 | assert(type(dep) == "table") |
83 | assert(type(get_versions) == "function") | 83 | assert(type(get_versions) == "function") |
84 | 84 | ||
85 | local versions, locations, lockversion, provided = get_versions(dep) | 85 | local versions, locations, lockversion, provided = get_versions(dep) |
86 | 86 | ||
87 | local latest_version | 87 | local latest_version |
88 | local latest_vstring | 88 | local latest_vstring |
89 | for _, vstring in ipairs(versions) do | 89 | for _, vstring in ipairs(versions) do |
@@ -95,7 +95,7 @@ local function match_dep(dep, get_versions) | |||
95 | end | 95 | end |
96 | end | 96 | end |
97 | end | 97 | end |
98 | 98 | ||
99 | if lockversion and not locations[lockversion] then | 99 | if lockversion and not locations[lockversion] then |
100 | local latest_matching_msg = "" | 100 | local latest_matching_msg = "" |
101 | if latest_vstring and latest_vstring ~= lockversion then | 101 | if latest_vstring and latest_vstring ~= lockversion then |
@@ -104,7 +104,7 @@ local function match_dep(dep, get_versions) | |||
104 | util.printout("Forcing " .. dep.name .. " to pinned version " .. lockversion .. latest_matching_msg) | 104 | util.printout("Forcing " .. dep.name .. " to pinned version " .. lockversion .. latest_matching_msg) |
105 | return nil, nil, queries.new(dep.name, dep.namespace, lockversion) | 105 | return nil, nil, queries.new(dep.name, dep.namespace, lockversion) |
106 | end | 106 | end |
107 | 107 | ||
108 | return latest_vstring, locations[latest_vstring], dep, provided | 108 | return latest_vstring, locations[latest_vstring], dep, provided |
109 | end | 109 | end |
110 | 110 | ||
@@ -113,7 +113,7 @@ local function match_all_deps(dependencies, get_versions) | |||
113 | assert(type(get_versions) == "function") | 113 | assert(type(get_versions) == "function") |
114 | 114 | ||
115 | local matched, missing, no_upgrade = {}, {}, {} | 115 | local matched, missing, no_upgrade = {}, {}, {} |
116 | 116 | ||
117 | for _, dep in ipairs(dependencies) do | 117 | for _, dep in ipairs(dependencies) do |
118 | local found, _, provided | 118 | local found, _, provided |
119 | found, _, dep, provided = match_dep(dep, get_versions) | 119 | found, _, dep, provided = match_dep(dep, get_versions) |
@@ -169,7 +169,7 @@ end | |||
169 | -- @param version string: package version. | 169 | -- @param version string: package version. |
170 | -- @param dependencies table: array of dependencies. | 170 | -- @param dependencies table: array of dependencies. |
171 | -- @param deps_mode string: Which trees to check dependencies for | 171 | -- @param deps_mode string: Which trees to check dependencies for |
172 | -- @param rocks_provided table: A table of auto-dependencies provided | 172 | -- @param rocks_provided table: A table of auto-dependencies provided |
173 | -- by this Lua implementation for the given dependency. | 173 | -- by this Lua implementation for the given dependency. |
174 | -- "one" for the current default tree, "all" for all trees, | 174 | -- "one" for the current default tree, "all" for all trees, |
175 | -- "order" for all trees with priority >= the current default, "none" for no trees. | 175 | -- "order" for all trees with priority >= the current default, "none" for no trees. |
@@ -179,7 +179,7 @@ function deps.report_missing_dependencies(name, version, dependencies, deps_mode | |||
179 | assert(type(dependencies) == "table") | 179 | assert(type(dependencies) == "table") |
180 | assert(type(deps_mode) == "string") | 180 | assert(type(deps_mode) == "string") |
181 | assert(type(rocks_provided) == "table") | 181 | assert(type(rocks_provided) == "table") |
182 | 182 | ||
183 | if deps_mode == "none" then | 183 | if deps_mode == "none" then |
184 | return | 184 | return |
185 | end | 185 | end |
@@ -270,7 +270,7 @@ local function check_supported_platforms(rockspec) | |||
270 | return nil, "This rockspec for "..rockspec.package.." does not support "..plats.." platforms." | 270 | return nil, "This rockspec for "..rockspec.package.." does not support "..plats.." platforms." |
271 | end | 271 | end |
272 | end | 272 | end |
273 | 273 | ||
274 | return true | 274 | return true |
275 | end | 275 | end |
276 | 276 | ||
@@ -295,7 +295,7 @@ function deps.fulfill_dependencies(rockspec, depskey, deps_mode, verify, deplock | |||
295 | local name = rockspec.name | 295 | local name = rockspec.name |
296 | local version = rockspec.version | 296 | local version = rockspec.version |
297 | local rocks_provided = rockspec.rocks_provided | 297 | local rocks_provided = rockspec.rocks_provided |
298 | 298 | ||
299 | local ok, filename, err = deplocks.load(name, deplock_dir or ".") | 299 | local ok, filename, err = deplocks.load(name, deplock_dir or ".") |
300 | if filename then | 300 | if filename then |
301 | util.printout("Using dependencies pinned in lockfile: " .. filename) | 301 | util.printout("Using dependencies pinned in lockfile: " .. filename) |
@@ -530,7 +530,7 @@ local function check_external_dependency(name, ext_files, vars, mode, cache) | |||
530 | local err_files = {program = {}, header = {}, library = {}} | 530 | local err_files = {program = {}, header = {}, library = {}} |
531 | 531 | ||
532 | local dirs = get_external_deps_dirs(mode) | 532 | local dirs = get_external_deps_dirs(mode) |
533 | 533 | ||
534 | local prefixes | 534 | local prefixes |
535 | if vars[name .. "_DIR"] then | 535 | if vars[name .. "_DIR"] then |
536 | prefixes = { vars[name .. "_DIR"] } | 536 | prefixes = { vars[name .. "_DIR"] } |
@@ -539,7 +539,7 @@ local function check_external_dependency(name, ext_files, vars, mode, cache) | |||
539 | else | 539 | else |
540 | prefixes = cfg.external_deps_dirs | 540 | prefixes = cfg.external_deps_dirs |
541 | end | 541 | end |
542 | 542 | ||
543 | for _, prefix in ipairs(prefixes) do | 543 | for _, prefix in ipairs(prefixes) do |
544 | prefix = resolve_prefix(prefix, dirs) | 544 | prefix = resolve_prefix(prefix, dirs) |
545 | if cfg.is_platform("mingw32") and name == "LUA" then | 545 | if cfg.is_platform("mingw32") and name == "LUA" then |
@@ -556,7 +556,7 @@ local function check_external_dependency(name, ext_files, vars, mode, cache) | |||
556 | return true | 556 | return true |
557 | end | 557 | end |
558 | end | 558 | end |
559 | 559 | ||
560 | return nil, err_dirname, err_testfile, err_files | 560 | return nil, err_dirname, err_testfile, err_files |
561 | end | 561 | end |
562 | 562 | ||
@@ -575,7 +575,7 @@ end | |||
575 | -- nil and an error message if any test failed. | 575 | -- nil and an error message if any test failed. |
576 | function deps.check_external_deps(rockspec, mode) | 576 | function deps.check_external_deps(rockspec, mode) |
577 | assert(rockspec:type() == "rockspec") | 577 | assert(rockspec:type() == "rockspec") |
578 | 578 | ||
579 | if not rockspec.external_dependencies then | 579 | if not rockspec.external_dependencies then |
580 | rockspec.external_dependencies = builtin.autodetect_external_dependencies(rockspec.build) | 580 | rockspec.external_dependencies = builtin.autodetect_external_dependencies(rockspec.build) |
581 | end | 581 | end |
@@ -587,7 +587,7 @@ function deps.check_external_deps(rockspec, mode) | |||
587 | local ok, err_dirname, err_testfile, err_files = check_external_dependency(name, ext_files, rockspec.variables, mode) | 587 | local ok, err_dirname, err_testfile, err_files = check_external_dependency(name, ext_files, rockspec.variables, mode) |
588 | if not ok then | 588 | if not ok then |
589 | local lines = {"Could not find "..err_testfile.." file for "..name} | 589 | local lines = {"Could not find "..err_testfile.." file for "..name} |
590 | 590 | ||
591 | local err_paths = {} | 591 | local err_paths = {} |
592 | for _, err_file in ipairs(err_files[err_testfile]) do | 592 | for _, err_file in ipairs(err_files[err_testfile]) do |
593 | if not err_paths[err_file] then | 593 | if not err_paths[err_file] then |
@@ -595,10 +595,10 @@ function deps.check_external_deps(rockspec, mode) | |||
595 | table.insert(lines, " No file "..err_file) | 595 | table.insert(lines, " No file "..err_file) |
596 | end | 596 | end |
597 | end | 597 | end |
598 | 598 | ||
599 | table.insert(lines, "You may have to install "..name.." in your system and/or pass "..name.."_DIR or "..name.."_"..err_dirname.." to the luarocks command.") | 599 | table.insert(lines, "You may have to install "..name.." in your system and/or pass "..name.."_DIR or "..name.."_"..err_dirname.." to the luarocks command.") |
600 | table.insert(lines, "Example: luarocks install "..rockspec.name.." "..name.."_DIR=/usr/local") | 600 | table.insert(lines, "Example: luarocks install "..rockspec.name.." "..name.."_DIR=/usr/local") |
601 | 601 | ||
602 | return nil, table.concat(lines, "\n"), "dependency" | 602 | return nil, table.concat(lines, "\n"), "dependency" |
603 | end | 603 | end |
604 | end | 604 | end |
@@ -700,7 +700,7 @@ function deps.check_lua_incdir(vars) | |||
700 | if vars.LUA_INCDIR then | 700 | if vars.LUA_INCDIR then |
701 | return lua_h_exists(vars.LUA_INCDIR, cfg.lua_version) | 701 | return lua_h_exists(vars.LUA_INCDIR, cfg.lua_version) |
702 | end | 702 | end |
703 | 703 | ||
704 | if vars.LUA_DIR then | 704 | if vars.LUA_DIR then |
705 | vars.LUA_INCDIR = find_lua_incdir(vars.LUA_DIR, cfg.lua_version, ljv) | 705 | vars.LUA_INCDIR = find_lua_incdir(vars.LUA_DIR, cfg.lua_version, ljv) |
706 | if vars.LUA_INCDIR then | 706 | if vars.LUA_INCDIR then |
diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua index da912d3e..c8b15d61 100644 --- a/src/luarocks/fetch.lua +++ b/src/luarocks/fetch.lua | |||
@@ -175,7 +175,7 @@ local function fetch_and_verify_signature_for(url, filename, tmpdir) | |||
175 | if not sig_file then | 175 | if not sig_file then |
176 | return nil, "Could not fetch signature file for verification: " .. err, errcode | 176 | return nil, "Could not fetch signature file for verification: " .. err, errcode |
177 | end | 177 | end |
178 | 178 | ||
179 | local ok, err = signing.verify_signature(filename, sig_file) | 179 | local ok, err = signing.verify_signature(filename, sig_file) |
180 | if not ok then | 180 | if not ok then |
181 | return nil, "Failed signature verification: " .. err | 181 | return nil, "Failed signature verification: " .. err |
@@ -269,7 +269,7 @@ function fetch.load_local_rockspec(rel_filename, quick) | |||
269 | if not tbl then | 269 | if not tbl then |
270 | return nil, "Could not load rockspec file "..abs_filename.." ("..err..")" | 270 | return nil, "Could not load rockspec file "..abs_filename.." ("..err..")" |
271 | end | 271 | end |
272 | 272 | ||
273 | local rockspec, err = rockspecs.from_persisted_table(abs_filename, tbl, err, quick) | 273 | local rockspec, err = rockspecs.from_persisted_table(abs_filename, tbl, err, quick) |
274 | if not rockspec then | 274 | if not rockspec then |
275 | return nil, abs_filename .. ": " .. err | 275 | return nil, abs_filename .. ": " .. err |
@@ -279,12 +279,12 @@ function fetch.load_local_rockspec(rel_filename, quick) | |||
279 | if basename ~= "rockspec" and basename ~= name_version .. ".rockspec" then | 279 | if basename ~= "rockspec" and basename ~= name_version .. ".rockspec" then |
280 | return nil, "Inconsistency between rockspec filename ("..basename..") and its contents ("..name_version..".rockspec)." | 280 | return nil, "Inconsistency between rockspec filename ("..basename..") and its contents ("..name_version..".rockspec)." |
281 | end | 281 | end |
282 | 282 | ||
283 | return rockspec | 283 | return rockspec |
284 | end | 284 | end |
285 | 285 | ||
286 | --- Load a local or remote rockspec into a table. | 286 | --- Load a local or remote rockspec into a table. |
287 | -- This is the entry point for the LuaRocks tools. | 287 | -- This is the entry point for the LuaRocks tools. |
288 | -- Only the LuaRocks runtime loader should use | 288 | -- Only the LuaRocks runtime loader should use |
289 | -- load_local_rockspec directly. | 289 | -- load_local_rockspec directly. |
290 | -- @param filename string: Local or remote filename of a rockspec. | 290 | -- @param filename string: Local or remote filename of a rockspec. |
@@ -425,7 +425,7 @@ function fetch.fetch_sources(rockspec, extract, dest_dir) | |||
425 | return nil, "Unknown protocol "..protocol | 425 | return nil, "Unknown protocol "..protocol |
426 | end | 426 | end |
427 | end | 427 | end |
428 | 428 | ||
429 | if cfg.only_sources_from | 429 | if cfg.only_sources_from |
430 | and rockspec.source.pathname | 430 | and rockspec.source.pathname |
431 | and #rockspec.source.pathname > 0 then | 431 | and #rockspec.source.pathname > 0 then |
diff --git a/src/luarocks/fetch/git.lua b/src/luarocks/fetch/git.lua index 88ba4848..29892e92 100644 --- a/src/luarocks/fetch/git.lua +++ b/src/luarocks/fetch/git.lua | |||
@@ -150,7 +150,7 @@ function git.get_sources(rockspec, extract, dest_dir, depth) | |||
150 | return nil, 'Failed to fetch submodules.' | 150 | return nil, 'Failed to fetch submodules.' |
151 | end | 151 | end |
152 | end | 152 | end |
153 | 153 | ||
154 | if not rockspec.source.tag then | 154 | if not rockspec.source.tag then |
155 | rockspec.source.identifier = git_identifier(git_cmd, rockspec.version) | 155 | rockspec.source.identifier = git_identifier(git_cmd, rockspec.version) |
156 | end | 156 | end |
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 83ffbd47..0e98449a 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
@@ -132,7 +132,7 @@ function fs_lua.is_tool_available(tool_cmd, tool_name, arg) | |||
132 | 132 | ||
133 | if ok then | 133 | if ok then |
134 | return true | 134 | return true |
135 | else | 135 | else |
136 | local msg = "'%s' program not found. Make sure %s is installed and is available in your PATH " .. | 136 | local msg = "'%s' program not found. Make sure %s is installed and is available in your PATH " .. |
137 | "(or you may want to edit the 'variables.%s' value in file '%s')" | 137 | "(or you may want to edit the 'variables.%s' value in file '%s')" |
138 | return nil, msg:format(tool_cmd, tool_name, tool_name:upper(), cfg.config_files.nearest) | 138 | return nil, msg:format(tool_cmd, tool_name, tool_name:upper(), cfg.config_files.nearest) |
@@ -535,7 +535,7 @@ end | |||
535 | --- Internal implementation function for fs.dir. | 535 | --- Internal implementation function for fs.dir. |
536 | -- Yields a filename on each iteration. | 536 | -- Yields a filename on each iteration. |
537 | -- @param at string: directory to list | 537 | -- @param at string: directory to list |
538 | -- @return nil or (nil and string): an error message on failure | 538 | -- @return nil or (nil and string): an error message on failure |
539 | function fs_lua.dir_iterator(at) | 539 | function fs_lua.dir_iterator(at) |
540 | local pok, iter, arg = pcall(lfs.dir, at) | 540 | local pok, iter, arg = pcall(lfs.dir, at) |
541 | if not pok then | 541 | if not pok then |
@@ -707,7 +707,7 @@ local redirect_protocols = { | |||
707 | 707 | ||
708 | local function request(url, method, http, loop_control) -- luacheck: ignore 431 | 708 | local function request(url, method, http, loop_control) -- luacheck: ignore 431 |
709 | local result = {} | 709 | local result = {} |
710 | 710 | ||
711 | if cfg.verbose then | 711 | if cfg.verbose then |
712 | print(method, url) | 712 | print(method, url) |
713 | end | 713 | end |
diff --git a/src/luarocks/fs/tools.lua b/src/luarocks/fs/tools.lua index fdb93dba..4fe8e104 100644 --- a/src/luarocks/fs/tools.lua +++ b/src/luarocks/fs/tools.lua | |||
@@ -12,7 +12,7 @@ local dir_stack = {} | |||
12 | 12 | ||
13 | do | 13 | do |
14 | local tool_cache = {} | 14 | local tool_cache = {} |
15 | 15 | ||
16 | local tool_options = { | 16 | local tool_options = { |
17 | downloader = { | 17 | downloader = { |
18 | desc = "downloader", | 18 | desc = "downloader", |
@@ -147,7 +147,7 @@ function tools.use_downloader(url, filename, cache) | |||
147 | assert(type(filename) == "string" or not filename) | 147 | assert(type(filename) == "string" or not filename) |
148 | 148 | ||
149 | filename = fs.absolute_name(filename or dir.base_name(url)) | 149 | filename = fs.absolute_name(filename or dir.base_name(url)) |
150 | 150 | ||
151 | local downloader, err = fs.which_tool("downloader") | 151 | local downloader, err = fs.which_tool("downloader") |
152 | if not downloader then | 152 | if not downloader then |
153 | return nil, err | 153 | return nil, err |
diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua index 53903f0c..d5b36127 100644 --- a/src/luarocks/fs/unix.lua +++ b/src/luarocks/fs/unix.lua | |||
@@ -76,7 +76,7 @@ function unix.wrap_script(script, target, deps_mode, name, version, ...) | |||
76 | assert(type(deps_mode) == "string") | 76 | assert(type(deps_mode) == "string") |
77 | assert(type(name) == "string" or not name) | 77 | assert(type(name) == "string" or not name) |
78 | assert(type(version) == "string" or not version) | 78 | assert(type(version) == "string" or not version) |
79 | 79 | ||
80 | local wrapper = io.open(target, "w") | 80 | local wrapper = io.open(target, "w") |
81 | if not wrapper then | 81 | if not wrapper then |
82 | return nil, "Could not open "..target.." for writing." | 82 | return nil, "Could not open "..target.." for writing." |
@@ -153,7 +153,7 @@ function unix.is_actual_binary(filename) | |||
153 | return first ~= "#!" | 153 | return first ~= "#!" |
154 | end | 154 | end |
155 | 155 | ||
156 | function unix.copy_binary(filename, dest) | 156 | function unix.copy_binary(filename, dest) |
157 | return fs.copy(filename, dest, "exec") | 157 | return fs.copy(filename, dest, "exec") |
158 | end | 158 | end |
159 | 159 | ||
diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua index 959ee86e..d36d407d 100644 --- a/src/luarocks/fs/unix/tools.lua +++ b/src/luarocks/fs/unix/tools.lua | |||
@@ -51,7 +51,7 @@ end | |||
51 | --- Copy a file. | 51 | --- Copy a file. |
52 | -- @param src string: Pathname of source | 52 | -- @param src string: Pathname of source |
53 | -- @param dest string: Pathname of destination | 53 | -- @param dest string: Pathname of destination |
54 | -- @param perm string ("read" or "exec") or nil: Permissions for destination | 54 | -- @param perm string ("read" or "exec") or nil: Permissions for destination |
55 | -- file or nil to use the source permissions | 55 | -- file or nil to use the source permissions |
56 | -- @return boolean or (boolean, string): true on success, false on failure, | 56 | -- @return boolean or (boolean, string): true on success, false on failure, |
57 | -- plus an error message. | 57 | -- plus an error message. |
diff --git a/src/luarocks/fs/win32.lua b/src/luarocks/fs/win32.lua index 00dd0163..49de8e97 100644 --- a/src/luarocks/fs/win32.lua +++ b/src/luarocks/fs/win32.lua | |||
@@ -217,7 +217,7 @@ function win32.is_actual_binary(name) | |||
217 | return false | 217 | return false |
218 | end | 218 | end |
219 | 219 | ||
220 | function win32.copy_binary(filename, dest) | 220 | function win32.copy_binary(filename, dest) |
221 | local ok, err = fs.copy(filename, dest) | 221 | local ok, err = fs.copy(filename, dest) |
222 | if not ok then | 222 | if not ok then |
223 | return nil, err | 223 | return nil, err |
diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua index b9eadc5b..f643bc80 100644 --- a/src/luarocks/manif.lua +++ b/src/luarocks/manif.lua | |||
@@ -110,7 +110,7 @@ function manif.load_manifest(repo_url, lua_version, versioned_only) | |||
110 | break | 110 | break |
111 | end | 111 | end |
112 | end | 112 | end |
113 | if not pathname then | 113 | if not pathname then |
114 | return nil, err, errcode | 114 | return nil, err, errcode |
115 | end | 115 | end |
116 | end | 116 | end |
@@ -236,7 +236,7 @@ end | |||
236 | function manif.get_versions(dep, deps_mode) | 236 | function manif.get_versions(dep, deps_mode) |
237 | assert(type(dep) == "table") | 237 | assert(type(dep) == "table") |
238 | assert(type(deps_mode) == "string") | 238 | assert(type(deps_mode) == "string") |
239 | 239 | ||
240 | local name = dep.name | 240 | local name = dep.name |
241 | local namespace = dep.namespace | 241 | local namespace = dep.namespace |
242 | 242 | ||
diff --git a/src/luarocks/manif/writer.lua b/src/luarocks/manif/writer.lua index fd891844..a435d29e 100644 --- a/src/luarocks/manif/writer.lua +++ b/src/luarocks/manif/writer.lua | |||
@@ -90,7 +90,7 @@ end | |||
90 | local function update_dependencies(manifest, deps_mode) | 90 | local function update_dependencies(manifest, deps_mode) |
91 | assert(type(manifest) == "table") | 91 | assert(type(manifest) == "table") |
92 | assert(type(deps_mode) == "string") | 92 | assert(type(deps_mode) == "string") |
93 | 93 | ||
94 | for pkg, versions in pairs(manifest.repository) do | 94 | for pkg, versions in pairs(manifest.repository) do |
95 | for version, repositories in pairs(versions) do | 95 | for version, repositories in pairs(versions) do |
96 | for _, repo in ipairs(repositories) do | 96 | for _, repo in ipairs(repositories) do |
@@ -160,7 +160,7 @@ local function filter_by_lua_version(manifest, lua_version, repodir, cache) | |||
160 | assert(type(manifest) == "table") | 160 | assert(type(manifest) == "table") |
161 | assert(type(repodir) == "string") | 161 | assert(type(repodir) == "string") |
162 | assert((not cache) or type(cache) == "table") | 162 | assert((not cache) or type(cache) == "table") |
163 | 163 | ||
164 | cache = cache or {} | 164 | cache = cache or {} |
165 | lua_version = vers.parse_version(lua_version) | 165 | lua_version = vers.parse_version(lua_version) |
166 | for pkg, versions in pairs(manifest.repository) do | 166 | for pkg, versions in pairs(manifest.repository) do |
@@ -176,7 +176,7 @@ local function filter_by_lua_version(manifest, lua_version, repodir, cache) | |||
176 | if rockspec then | 176 | if rockspec then |
177 | cache[pathname] = rockspec | 177 | cache[pathname] = rockspec |
178 | for _, dep in ipairs(rockspec.dependencies) do | 178 | for _, dep in ipairs(rockspec.dependencies) do |
179 | if dep.name == "lua" then | 179 | if dep.name == "lua" then |
180 | if not vers.match_constraints(lua_version, dep.constraints) then | 180 | if not vers.match_constraints(lua_version, dep.constraints) then |
181 | table.insert(to_remove, version) | 181 | table.insert(to_remove, version) |
182 | end | 182 | end |
diff --git a/src/luarocks/pack.lua b/src/luarocks/pack.lua index 983aef74..34268475 100644 --- a/src/luarocks/pack.lua +++ b/src/luarocks/pack.lua | |||
@@ -91,13 +91,13 @@ function pack.pack_installed_rock(query, tree) | |||
91 | if not fs.exists(prefix) then | 91 | if not fs.exists(prefix) then |
92 | return nil, "'"..name.." "..version.."' does not seem to be an installed rock." | 92 | return nil, "'"..name.." "..version.."' does not seem to be an installed rock." |
93 | end | 93 | end |
94 | 94 | ||
95 | local rock_manifest, err = manif.load_rock_manifest(name, version, root) | 95 | local rock_manifest, err = manif.load_rock_manifest(name, version, root) |
96 | if not rock_manifest then return nil, err end | 96 | if not rock_manifest then return nil, err end |
97 | 97 | ||
98 | local name_version = name .. "-" .. version | 98 | local name_version = name .. "-" .. version |
99 | local rock_file = fs.absolute_name(name_version .. "."..cfg.arch..".rock") | 99 | local rock_file = fs.absolute_name(name_version .. "."..cfg.arch..".rock") |
100 | 100 | ||
101 | local temp_dir = fs.make_temp_dir("pack") | 101 | local temp_dir = fs.make_temp_dir("pack") |
102 | fs.copy_contents(prefix, temp_dir) | 102 | fs.copy_contents(prefix, temp_dir) |
103 | 103 | ||
@@ -111,7 +111,7 @@ function pack.pack_installed_rock(query, tree) | |||
111 | local ok, err = copy_back_files(name, version, rock_manifest.lua, path.deploy_lua_dir(repo), dir.path(temp_dir, "lua"), "read") | 111 | local ok, err = copy_back_files(name, version, rock_manifest.lua, path.deploy_lua_dir(repo), dir.path(temp_dir, "lua"), "read") |
112 | if not ok then return nil, "Failed copying back files: " .. err end | 112 | if not ok then return nil, "Failed copying back files: " .. err end |
113 | end | 113 | end |
114 | 114 | ||
115 | local ok, err = fs.change_dir(temp_dir) | 115 | local ok, err = fs.change_dir(temp_dir) |
116 | if not ok then return nil, err end | 116 | if not ok then return nil, err end |
117 | if not is_binary and not repos.has_binaries(name, version) then | 117 | if not is_binary and not repos.has_binaries(name, version) then |
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua index b3b01704..a9f04ef0 100644 --- a/src/luarocks/path.lua +++ b/src/luarocks/path.lua | |||
@@ -49,7 +49,7 @@ function path.manifest_file(tree) | |||
49 | end | 49 | end |
50 | 50 | ||
51 | --- Get the directory for all versions of a package in a tree. | 51 | --- Get the directory for all versions of a package in a tree. |
52 | -- @param name string: The package name. | 52 | -- @param name string: The package name. |
53 | -- @return string: The resulting path -- does not guarantee that | 53 | -- @return string: The resulting path -- does not guarantee that |
54 | -- @param tree string or nil: If given, specifies the local tree to use. | 54 | -- @param tree string or nil: If given, specifies the local tree to use. |
55 | -- the package (and by extension, the path) exists. | 55 | -- the package (and by extension, the path) exists. |
@@ -59,7 +59,7 @@ function path.versions_dir(name, tree) | |||
59 | end | 59 | end |
60 | 60 | ||
61 | --- Get the local installation directory (prefix) for a package. | 61 | --- Get the local installation directory (prefix) for a package. |
62 | -- @param name string: The package name. | 62 | -- @param name string: The package name. |
63 | -- @param version string: The package version. | 63 | -- @param version string: The package version. |
64 | -- @param tree string or nil: If given, specifies the local tree to use. | 64 | -- @param tree string or nil: If given, specifies the local tree to use. |
65 | -- @return string: The resulting path -- does not guarantee that | 65 | -- @return string: The resulting path -- does not guarantee that |
@@ -71,7 +71,7 @@ function path.install_dir(name, version, tree) | |||
71 | end | 71 | end |
72 | 72 | ||
73 | --- Get the local filename of the rockspec of an installed rock. | 73 | --- Get the local filename of the rockspec of an installed rock. |
74 | -- @param name string: The package name. | 74 | -- @param name string: The package name. |
75 | -- @param version string: The package version. | 75 | -- @param version string: The package version. |
76 | -- @param tree string or nil: If given, specifies the local tree to use. | 76 | -- @param tree string or nil: If given, specifies the local tree to use. |
77 | -- @return string: The resulting path -- does not guarantee that | 77 | -- @return string: The resulting path -- does not guarantee that |
@@ -83,7 +83,7 @@ function path.rockspec_file(name, version, tree) | |||
83 | end | 83 | end |
84 | 84 | ||
85 | --- Get the local filename of the rock_manifest file of an installed rock. | 85 | --- Get the local filename of the rock_manifest file of an installed rock. |
86 | -- @param name string: The package name. | 86 | -- @param name string: The package name. |
87 | -- @param version string: The package version. | 87 | -- @param version string: The package version. |
88 | -- @param tree string or nil: If given, specifies the local tree to use. | 88 | -- @param tree string or nil: If given, specifies the local tree to use. |
89 | -- @return string: The resulting path -- does not guarantee that | 89 | -- @return string: The resulting path -- does not guarantee that |
@@ -107,7 +107,7 @@ function path.rock_namespace_file(name, version, tree) | |||
107 | end | 107 | end |
108 | 108 | ||
109 | --- Get the local installation directory for C libraries of a package. | 109 | --- Get the local installation directory for C libraries of a package. |
110 | -- @param name string: The package name. | 110 | -- @param name string: The package name. |
111 | -- @param version string: The package version. | 111 | -- @param version string: The package version. |
112 | -- @param tree string or nil: If given, specifies the local tree to use. | 112 | -- @param tree string or nil: If given, specifies the local tree to use. |
113 | -- @return string: The resulting path -- does not guarantee that | 113 | -- @return string: The resulting path -- does not guarantee that |
@@ -119,7 +119,7 @@ function path.lib_dir(name, version, tree) | |||
119 | end | 119 | end |
120 | 120 | ||
121 | --- Get the local installation directory for Lua modules of a package. | 121 | --- Get the local installation directory for Lua modules of a package. |
122 | -- @param name string: The package name. | 122 | -- @param name string: The package name. |
123 | -- @param version string: The package version. | 123 | -- @param version string: The package version. |
124 | -- @param tree string or nil: If given, specifies the local tree to use. | 124 | -- @param tree string or nil: If given, specifies the local tree to use. |
125 | -- @return string: The resulting path -- does not guarantee that | 125 | -- @return string: The resulting path -- does not guarantee that |
@@ -131,7 +131,7 @@ function path.lua_dir(name, version, tree) | |||
131 | end | 131 | end |
132 | 132 | ||
133 | --- Get the local installation directory for documentation of a package. | 133 | --- Get the local installation directory for documentation of a package. |
134 | -- @param name string: The package name. | 134 | -- @param name string: The package name. |
135 | -- @param version string: The package version. | 135 | -- @param version string: The package version. |
136 | -- @param tree string or nil: If given, specifies the local tree to use. | 136 | -- @param tree string or nil: If given, specifies the local tree to use. |
137 | -- @return string: The resulting path -- does not guarantee that | 137 | -- @return string: The resulting path -- does not guarantee that |
@@ -143,7 +143,7 @@ function path.doc_dir(name, version, tree) | |||
143 | end | 143 | end |
144 | 144 | ||
145 | --- Get the local installation directory for configuration files of a package. | 145 | --- Get the local installation directory for configuration files of a package. |
146 | -- @param name string: The package name. | 146 | -- @param name string: The package name. |
147 | -- @param version string: The package version. | 147 | -- @param version string: The package version. |
148 | -- @param tree string or nil: If given, specifies the local tree to use. | 148 | -- @param tree string or nil: If given, specifies the local tree to use. |
149 | -- @return string: The resulting path -- does not guarantee that | 149 | -- @return string: The resulting path -- does not guarantee that |
@@ -156,7 +156,7 @@ end | |||
156 | 156 | ||
157 | --- Get the local installation directory for command-line scripts | 157 | --- Get the local installation directory for command-line scripts |
158 | -- of a package. | 158 | -- of a package. |
159 | -- @param name string: The package name. | 159 | -- @param name string: The package name. |
160 | -- @param version string: The package version. | 160 | -- @param version string: The package version. |
161 | -- @param tree string or nil: If given, specifies the local tree to use. | 161 | -- @param tree string or nil: If given, specifies the local tree to use. |
162 | -- @return string: The resulting path -- does not guarantee that | 162 | -- @return string: The resulting path -- does not guarantee that |
diff --git a/src/luarocks/persist.lua b/src/luarocks/persist.lua index b21323ce..02c5016c 100644 --- a/src/luarocks/persist.lua +++ b/src/luarocks/persist.lua | |||
@@ -85,7 +85,7 @@ local function write_table_key_assignment(out, k, level) | |||
85 | persist.write_value(out, k, level) | 85 | persist.write_value(out, k, level) |
86 | out:write("]") | 86 | out:write("]") |
87 | end | 87 | end |
88 | 88 | ||
89 | out:write(" = ") | 89 | out:write(" = ") |
90 | end | 90 | end |
91 | 91 | ||
diff --git a/src/luarocks/queries.lua b/src/luarocks/queries.lua index de5c9652..6df61296 100644 --- a/src/luarocks/queries.lua +++ b/src/luarocks/queries.lua | |||
@@ -55,7 +55,7 @@ function queries.new(name, namespace, version, substring, arch, operator) | |||
55 | assert(type(substring) == "boolean" or not substring) | 55 | assert(type(substring) == "boolean" or not substring) |
56 | assert(type(arch) == "string" or not arch) | 56 | assert(type(arch) == "string" or not arch) |
57 | assert(type(operator) == "string" or not operator) | 57 | assert(type(operator) == "string" or not operator) |
58 | 58 | ||
59 | operator = operator or "==" | 59 | operator = operator or "==" |
60 | 60 | ||
61 | local self = { | 61 | local self = { |
@@ -99,7 +99,7 @@ do | |||
99 | ["="] = "==", | 99 | ["="] = "==", |
100 | ["!="] = "~=" | 100 | ["!="] = "~=" |
101 | } | 101 | } |
102 | 102 | ||
103 | --- Consumes a constraint from a string, converting it to table format. | 103 | --- Consumes a constraint from a string, converting it to table format. |
104 | -- For example, a string ">= 1.0, > 2.0" is converted to a table in the | 104 | -- For example, a string ">= 1.0, > 2.0" is converted to a table in the |
105 | -- format {op = ">=", version={1,0}} and the rest, "> 2.0", is returned | 105 | -- format {op = ">=", version={1,0}} and the rest, "> 2.0", is returned |
@@ -110,20 +110,20 @@ do | |||
110 | -- input string is invalid. | 110 | -- input string is invalid. |
111 | parse_constraint = function(input) | 111 | parse_constraint = function(input) |
112 | assert(type(input) == "string") | 112 | assert(type(input) == "string") |
113 | 113 | ||
114 | local no_upgrade, op, version, rest = input:match("^(@?)([<>=~!]*)%s*([%w%.%_%-]+)[%s,]*(.*)") | 114 | local no_upgrade, op, version, rest = input:match("^(@?)([<>=~!]*)%s*([%w%.%_%-]+)[%s,]*(.*)") |
115 | local _op = operators[op] | 115 | local _op = operators[op] |
116 | version = vers.parse_version(version) | 116 | version = vers.parse_version(version) |
117 | if not _op then | 117 | if not _op then |
118 | return nil, "Encountered bad constraint operator: '"..tostring(op).."' in '"..input.."'" | 118 | return nil, "Encountered bad constraint operator: '"..tostring(op).."' in '"..input.."'" |
119 | end | 119 | end |
120 | if not version then | 120 | if not version then |
121 | return nil, "Could not parse version from constraint: '"..input.."'" | 121 | return nil, "Could not parse version from constraint: '"..input.."'" |
122 | end | 122 | end |
123 | return { op = _op, version = version, no_upgrade = no_upgrade=="@" and true or nil }, rest | 123 | return { op = _op, version = version, no_upgrade = no_upgrade=="@" and true or nil }, rest |
124 | end | 124 | end |
125 | end | 125 | end |
126 | 126 | ||
127 | --- Convert a list of constraints from string to table format. | 127 | --- Convert a list of constraints from string to table format. |
128 | -- For example, a string ">= 1.0, < 2.0" is converted to a table in the format | 128 | -- For example, a string ">= 1.0, < 2.0" is converted to a table in the format |
129 | -- {{op = ">=", version={1,0}}, {op = "<", version={2,0}}}. | 129 | -- {{op = ">=", version={1,0}}, {op = "<", version={2,0}}}. |
@@ -134,7 +134,7 @@ do | |||
134 | -- or nil if the input string is invalid. | 134 | -- or nil if the input string is invalid. |
135 | parse_constraints = function(input) | 135 | parse_constraints = function(input) |
136 | assert(type(input) == "string") | 136 | assert(type(input) == "string") |
137 | 137 | ||
138 | local constraints, oinput, constraint = {}, input | 138 | local constraints, oinput, constraint = {}, input |
139 | while #input > 0 do | 139 | while #input > 0 do |
140 | constraint, input = parse_constraint(input) | 140 | constraint, input = parse_constraint(input) |
@@ -147,26 +147,26 @@ do | |||
147 | return constraints | 147 | return constraints |
148 | end | 148 | end |
149 | end | 149 | end |
150 | 150 | ||
151 | --- Prepare a query in dependency table format. | 151 | --- Prepare a query in dependency table format. |
152 | -- @param depstr string: A dependency in string format | 152 | -- @param depstr string: A dependency in string format |
153 | -- as entered in rockspec files. | 153 | -- as entered in rockspec files. |
154 | -- @return table: A query in table format, or nil and an error message in case of errors. | 154 | -- @return table: A query in table format, or nil and an error message in case of errors. |
155 | function queries.from_dep_string(depstr) | 155 | function queries.from_dep_string(depstr) |
156 | assert(type(depstr) == "string") | 156 | assert(type(depstr) == "string") |
157 | 157 | ||
158 | local ns_name, rest = depstr:match("^%s*([a-zA-Z0-9%.%-%_]*/?[a-zA-Z0-9][a-zA-Z0-9%.%-%_]*)%s*([^/]*)") | 158 | local ns_name, rest = depstr:match("^%s*([a-zA-Z0-9%.%-%_]*/?[a-zA-Z0-9][a-zA-Z0-9%.%-%_]*)%s*([^/]*)") |
159 | if not ns_name then | 159 | if not ns_name then |
160 | return nil, "failed to extract dependency name from '"..depstr.."'" | 160 | return nil, "failed to extract dependency name from '"..depstr.."'" |
161 | end | 161 | end |
162 | 162 | ||
163 | local constraints, err = parse_constraints(rest) | 163 | local constraints, err = parse_constraints(rest) |
164 | if not constraints then | 164 | if not constraints then |
165 | return nil, err | 165 | return nil, err |
166 | end | 166 | end |
167 | 167 | ||
168 | local name, namespace = util.split_namespace(ns_name) | 168 | local name, namespace = util.split_namespace(ns_name) |
169 | 169 | ||
170 | local self = { | 170 | local self = { |
171 | name = name, | 171 | name = name, |
172 | namespace = namespace, | 172 | namespace = namespace, |
diff --git a/src/luarocks/remove.lua b/src/luarocks/remove.lua index aabd716f..9f816c7e 100644 --- a/src/luarocks/remove.lua +++ b/src/luarocks/remove.lua | |||
@@ -47,14 +47,14 @@ end | |||
47 | -- "one" for the current default tree, "all" for all trees, | 47 | -- "one" for the current default tree, "all" for all trees, |
48 | -- "order" for all trees with priority >= the current default, "none" for no trees. | 48 | -- "order" for all trees with priority >= the current default, "none" for no trees. |
49 | -- @return boolean or (nil, string): true on success or nil and an error message. | 49 | -- @return boolean or (nil, string): true on success or nil and an error message. |
50 | local function delete_versions(name, versions, deps_mode) | 50 | local function delete_versions(name, versions, deps_mode) |
51 | 51 | ||
52 | for version, _ in pairs(versions) do | 52 | for version, _ in pairs(versions) do |
53 | util.printout("Removing "..name.." "..version.."...") | 53 | util.printout("Removing "..name.." "..version.."...") |
54 | local ok, err = repos.delete_version(name, version, deps_mode) | 54 | local ok, err = repos.delete_version(name, version, deps_mode) |
55 | if not ok then return nil, err end | 55 | if not ok then return nil, err end |
56 | end | 56 | end |
57 | 57 | ||
58 | return true | 58 | return true |
59 | end | 59 | end |
60 | 60 | ||
@@ -63,7 +63,7 @@ function remove.remove_search_results(results, name, deps_mode, force, fast) | |||
63 | 63 | ||
64 | local version = next(versions) | 64 | local version = next(versions) |
65 | local second = next(versions, version) | 65 | local second = next(versions, version) |
66 | 66 | ||
67 | local dependents = {} | 67 | local dependents = {} |
68 | if not fast then | 68 | if not fast then |
69 | util.printout("Checking stability of dependencies in the absence of") | 69 | util.printout("Checking stability of dependencies in the absence of") |
@@ -71,7 +71,7 @@ function remove.remove_search_results(results, name, deps_mode, force, fast) | |||
71 | util.printout() | 71 | util.printout() |
72 | dependents = check_dependents(name, versions, deps_mode) | 72 | dependents = check_dependents(name, versions, deps_mode) |
73 | end | 73 | end |
74 | 74 | ||
75 | if #dependents > 0 then | 75 | if #dependents > 0 then |
76 | if force or fast then | 76 | if force or fast then |
77 | util.printerr("The following packages may be broken by this forced removal:") | 77 | util.printerr("The following packages may be broken by this forced removal:") |
@@ -95,7 +95,7 @@ function remove.remove_search_results(results, name, deps_mode, force, fast) | |||
95 | return nil, "Failed removing." | 95 | return nil, "Failed removing." |
96 | end | 96 | end |
97 | end | 97 | end |
98 | 98 | ||
99 | local ok, err = delete_versions(name, versions, deps_mode) | 99 | local ok, err = delete_versions(name, versions, deps_mode) |
100 | if not ok then return nil, err end | 100 | if not ok then return nil, err end |
101 | 101 | ||
diff --git a/src/luarocks/repos.lua b/src/luarocks/repos.lua index 4a78dfb2..4610c734 100644 --- a/src/luarocks/repos.lua +++ b/src/luarocks/repos.lua | |||
@@ -47,7 +47,7 @@ end | |||
47 | -- versions of a package, or nil if none is available. | 47 | -- versions of a package, or nil if none is available. |
48 | local function get_installed_versions(name) | 48 | local function get_installed_versions(name) |
49 | assert(type(name) == "string" and not name:match("/")) | 49 | assert(type(name) == "string" and not name:match("/")) |
50 | 50 | ||
51 | local dirs = fs.list_dir(path.versions_dir(name)) | 51 | local dirs = fs.list_dir(path.versions_dir(name)) |
52 | return (dirs and #dirs > 0) and dirs or nil | 52 | return (dirs and #dirs > 0) and dirs or nil |
53 | end | 53 | end |
@@ -61,7 +61,7 @@ end | |||
61 | function repos.is_installed(name, version) | 61 | function repos.is_installed(name, version) |
62 | assert(type(name) == "string" and not name:match("/")) | 62 | assert(type(name) == "string" and not name:match("/")) |
63 | assert(type(version) == "string") | 63 | assert(type(version) == "string") |
64 | 64 | ||
65 | return fs.is_dir(path.install_dir(name, version)) | 65 | return fs.is_dir(path.install_dir(name, version)) |
66 | end | 66 | end |
67 | 67 | ||
@@ -172,11 +172,11 @@ function repos.run_hook(rockspec, hook_name) | |||
172 | if not hooks then | 172 | if not hooks then |
173 | return true | 173 | return true |
174 | end | 174 | end |
175 | 175 | ||
176 | if cfg.hooks_enabled == false then | 176 | if cfg.hooks_enabled == false then |
177 | return nil, "This rockspec contains hooks, which are blocked by the 'hooks_enabled' setting in your LuaRocks configuration." | 177 | return nil, "This rockspec contains hooks, which are blocked by the 'hooks_enabled' setting in your LuaRocks configuration." |
178 | end | 178 | end |
179 | 179 | ||
180 | if not hooks.substituted_variables then | 180 | if not hooks.substituted_variables then |
181 | util.variable_substitutions(hooks, rockspec.variables) | 181 | util.variable_substitutions(hooks, rockspec.variables) |
182 | hooks.substituted_variables = true | 182 | hooks.substituted_variables = true |
@@ -269,7 +269,7 @@ local function backup_existing(should_backup, target) | |||
269 | repeat | 269 | repeat |
270 | backup = backup.."~" | 270 | backup = backup.."~" |
271 | until not fs.exists(backup) -- Slight race condition here, but shouldn't be a problem. | 271 | until not fs.exists(backup) -- Slight race condition here, but shouldn't be a problem. |
272 | 272 | ||
273 | util.warning(target.." is not tracked by this installation of LuaRocks. Moving it to "..backup) | 273 | util.warning(target.." is not tracked by this installation of LuaRocks. Moving it to "..backup) |
274 | local move_ok, move_err = os.rename(target, backup) | 274 | local move_ok, move_err = os.rename(target, backup) |
275 | if not move_ok then | 275 | if not move_ok then |
@@ -300,7 +300,7 @@ local function prepare_op_install() | |||
300 | if not ok then | 300 | if not ok then |
301 | return nil, err | 301 | return nil, err |
302 | end | 302 | end |
303 | 303 | ||
304 | local backup, err = backup_existing(op.backup, op.realdst or op.dst) | 304 | local backup, err = backup_existing(op.backup, op.realdst or op.dst) |
305 | if err then | 305 | if err then |
306 | return nil, err | 306 | return nil, err |
@@ -308,22 +308,22 @@ local function prepare_op_install() | |||
308 | if backup then | 308 | if backup then |
309 | op.backup_file = backup | 309 | op.backup_file = backup |
310 | end | 310 | end |
311 | 311 | ||
312 | ok, err = op.fn(op.src, op.dst, op.backup) | 312 | ok, err = op.fn(op.src, op.dst, op.backup) |
313 | if not ok then | 313 | if not ok then |
314 | return nil, err | 314 | return nil, err |
315 | end | 315 | end |
316 | 316 | ||
317 | rmdirs[dir.dir_name(op.src)] = true | 317 | rmdirs[dir.dir_name(op.src)] = true |
318 | return true | 318 | return true |
319 | end | 319 | end |
320 | 320 | ||
321 | local function done_op_install() | 321 | local function done_op_install() |
322 | for d, _ in pairs(rmdirs) do | 322 | for d, _ in pairs(rmdirs) do |
323 | fs.remove_dir_tree_if_empty(d) | 323 | fs.remove_dir_tree_if_empty(d) |
324 | end | 324 | end |
325 | end | 325 | end |
326 | 326 | ||
327 | return op_install, done_op_install | 327 | return op_install, done_op_install |
328 | end | 328 | end |
329 | 329 | ||
@@ -361,7 +361,7 @@ end | |||
361 | local function prepare_op_delete() | 361 | local function prepare_op_delete() |
362 | local deletes = {} | 362 | local deletes = {} |
363 | local rmdirs = {} | 363 | local rmdirs = {} |
364 | 364 | ||
365 | local function done_op_delete() | 365 | local function done_op_delete() |
366 | for _, f in ipairs(deletes) do | 366 | for _, f in ipairs(deletes) do |
367 | os.remove(f) | 367 | os.remove(f) |
@@ -377,12 +377,12 @@ local function prepare_op_delete() | |||
377 | local suffix = check_suffix(op.name, op.suffix) | 377 | local suffix = check_suffix(op.name, op.suffix) |
378 | op.name = op.name .. suffix | 378 | op.name = op.name .. suffix |
379 | end | 379 | end |
380 | 380 | ||
381 | table.insert(deletes, op.name) | 381 | table.insert(deletes, op.name) |
382 | 382 | ||
383 | rmdirs[dir.dir_name(op.name)] = true | 383 | rmdirs[dir.dir_name(op.name)] = true |
384 | end | 384 | end |
385 | 385 | ||
386 | return op_delete, done_op_delete | 386 | return op_delete, done_op_delete |
387 | end | 387 | end |
388 | 388 | ||
@@ -406,7 +406,7 @@ function repos.deploy_files(name, version, wrap_bin_scripts, deps_mode) | |||
406 | 406 | ||
407 | local rock_manifest, load_err = manif.load_rock_manifest(name, version) | 407 | local rock_manifest, load_err = manif.load_rock_manifest(name, version) |
408 | if not rock_manifest then return nil, load_err end | 408 | if not rock_manifest then return nil, load_err end |
409 | 409 | ||
410 | local repo = cfg.root_dir | 410 | local repo = cfg.root_dir |
411 | local renames = {} | 411 | local renames = {} |
412 | local installs = {} | 412 | local installs = {} |
@@ -592,7 +592,7 @@ function repos.delete_version(name, version, deps_mode, quick) | |||
592 | op_delete(op) | 592 | op_delete(op) |
593 | end | 593 | end |
594 | done_op_delete() | 594 | done_op_delete() |
595 | 595 | ||
596 | if not quick then | 596 | if not quick then |
597 | for _, op in ipairs(renames) do | 597 | for _, op in ipairs(renames) do |
598 | op_rename(op) | 598 | op_rename(op) |
diff --git a/src/luarocks/results.lua b/src/luarocks/results.lua index a6ebfbf3..c14862de 100644 --- a/src/luarocks/results.lua +++ b/src/luarocks/results.lua | |||
@@ -17,11 +17,11 @@ function results.new(name, version, repo, arch, namespace) | |||
17 | assert(type(repo) == "string") | 17 | assert(type(repo) == "string") |
18 | assert(type(arch) == "string" or not arch) | 18 | assert(type(arch) == "string" or not arch) |
19 | assert(type(namespace) == "string" or not namespace) | 19 | assert(type(namespace) == "string" or not namespace) |
20 | 20 | ||
21 | if not namespace then | 21 | if not namespace then |
22 | name, namespace = util.split_namespace(name) | 22 | name, namespace = util.split_namespace(name) |
23 | end | 23 | end |
24 | 24 | ||
25 | local self = { | 25 | local self = { |
26 | name = name, | 26 | name = name, |
27 | version = version, | 27 | version = version, |
diff --git a/src/luarocks/rockspecs.lua b/src/luarocks/rockspecs.lua index f1bb6d6a..94462951 100644 --- a/src/luarocks/rockspecs.lua +++ b/src/luarocks/rockspecs.lua | |||
@@ -1,5 +1,5 @@ | |||
1 | local rockspecs = {} | 1 | local rockspecs = {} |
2 | 2 | ||
3 | local cfg = require("luarocks.core.cfg") | 3 | local cfg = require("luarocks.core.cfg") |
4 | local dir = require("luarocks.dir") | 4 | local dir = require("luarocks.dir") |
5 | local path = require("luarocks.path") | 5 | local path = require("luarocks.path") |
@@ -31,9 +31,9 @@ end | |||
31 | -- if it doesn't (or if nil is passed), this function does nothing. | 31 | -- if it doesn't (or if nil is passed), this function does nothing. |
32 | local function platform_overrides(tbl) | 32 | local function platform_overrides(tbl) |
33 | assert(type(tbl) == "table" or not tbl) | 33 | assert(type(tbl) == "table" or not tbl) |
34 | 34 | ||
35 | if not tbl then return end | 35 | if not tbl then return end |
36 | 36 | ||
37 | if tbl.platforms then | 37 | if tbl.platforms then |
38 | for platform in cfg.each_platform() do | 38 | for platform in cfg.each_platform() do |
39 | local platform_tbl = tbl.platforms[platform] | 39 | local platform_tbl = tbl.platforms[platform] |
@@ -158,4 +158,4 @@ function rockspecs.from_persisted_table(filename, rockspec, globals, quick) | |||
158 | return setmetatable(rockspec, rockspec_mt) | 158 | return setmetatable(rockspec, rockspec_mt) |
159 | end | 159 | end |
160 | 160 | ||
161 | return rockspecs \ No newline at end of file | 161 | return rockspecs |
diff --git a/src/luarocks/search.lua b/src/luarocks/search.lua index d2bad630..8a79d990 100644 --- a/src/luarocks/search.lua +++ b/src/luarocks/search.lua | |||
@@ -61,13 +61,13 @@ function search.disk_search(repo, query, result_tree) | |||
61 | assert(type(repo) == "string") | 61 | assert(type(repo) == "string") |
62 | assert(query:type() == "query") | 62 | assert(query:type() == "query") |
63 | assert(type(result_tree) == "table" or not result_tree) | 63 | assert(type(result_tree) == "table" or not result_tree) |
64 | 64 | ||
65 | local fs = require("luarocks.fs") | 65 | local fs = require("luarocks.fs") |
66 | 66 | ||
67 | if not result_tree then | 67 | if not result_tree then |
68 | result_tree = {} | 68 | result_tree = {} |
69 | end | 69 | end |
70 | 70 | ||
71 | for name in fs.dir(repo) do | 71 | for name in fs.dir(repo) do |
72 | local pathname = dir.path(repo, name) | 72 | local pathname = dir.path(repo, name) |
73 | local rname, rversion, rarch = path.parse_name(name) | 73 | local rname, rversion, rarch = path.parse_name(name) |
@@ -231,13 +231,13 @@ function search.find_suitable_rock(query) | |||
231 | assert(query:type() == "query") | 231 | assert(query:type() == "query") |
232 | 232 | ||
233 | local rocks_provided = util.get_rocks_provided() | 233 | local rocks_provided = util.get_rocks_provided() |
234 | 234 | ||
235 | if rocks_provided[query.name] ~= nil then | 235 | if rocks_provided[query.name] ~= nil then |
236 | -- Do not install versions listed in rocks_provided. | 236 | -- Do not install versions listed in rocks_provided. |
237 | return nil, "Rock "..query.name.." "..rocks_provided[query.name].. | 237 | return nil, "Rock "..query.name.." "..rocks_provided[query.name].. |
238 | " is already provided by VM or via 'rocks_provided' in the config file.", "provided" | 238 | " is already provided by VM or via 'rocks_provided' in the config file.", "provided" |
239 | end | 239 | end |
240 | 240 | ||
241 | local result_tree = search.search_repos(query) | 241 | local result_tree = search.search_repos(query) |
242 | local first_rock = next(result_tree) | 242 | local first_rock = next(result_tree) |
243 | if not first_rock then | 243 | if not first_rock then |
@@ -270,19 +270,19 @@ function search.find_rock_checking_lua_versions(query, check_lua_versions) | |||
270 | if check_lua_versions then | 270 | if check_lua_versions then |
271 | util.printout(query.name .. " not found for Lua " .. cfg.lua_version .. ".") | 271 | util.printout(query.name .. " not found for Lua " .. cfg.lua_version .. ".") |
272 | util.printout("Checking if available for other Lua versions...") | 272 | util.printout("Checking if available for other Lua versions...") |
273 | 273 | ||
274 | -- Check if constraints are satisfiable with other Lua versions. | 274 | -- Check if constraints are satisfiable with other Lua versions. |
275 | local lua_versions = supported_lua_versions(query) | 275 | local lua_versions = supported_lua_versions(query) |
276 | 276 | ||
277 | if #lua_versions ~= 0 then | 277 | if #lua_versions ~= 0 then |
278 | -- Build a nice message in "only Lua 5.x and 5.y but not 5.z." format | 278 | -- Build a nice message in "only Lua 5.x and 5.y but not 5.z." format |
279 | for i, lua_version in ipairs(lua_versions) do | 279 | for i, lua_version in ipairs(lua_versions) do |
280 | lua_versions[i] = "Lua "..lua_version | 280 | lua_versions[i] = "Lua "..lua_version |
281 | end | 281 | end |
282 | 282 | ||
283 | local versions_message = "only "..table.concat(lua_versions, " and ").. | 283 | local versions_message = "only "..table.concat(lua_versions, " and ").. |
284 | " but not Lua "..cfg.lua_version.."." | 284 | " but not Lua "..cfg.lua_version.."." |
285 | 285 | ||
286 | if #query.constraints == 0 then | 286 | if #query.constraints == 0 then |
287 | add = query.name.." supports "..versions_message | 287 | add = query.name.." supports "..versions_message |
288 | elseif #query.constraints == 1 and query.constraints[1].op == "==" then | 288 | elseif #query.constraints == 1 and query.constraints[1].op == "==" then |
@@ -308,7 +308,7 @@ end | |||
308 | function search.print_result_tree(result_tree, porcelain) | 308 | function search.print_result_tree(result_tree, porcelain) |
309 | assert(type(result_tree) == "table") | 309 | assert(type(result_tree) == "table") |
310 | assert(type(porcelain) == "boolean" or not porcelain) | 310 | assert(type(porcelain) == "boolean" or not porcelain) |
311 | 311 | ||
312 | if porcelain then | 312 | if porcelain then |
313 | for package, versions in util.sortedpairs(result_tree) do | 313 | for package, versions in util.sortedpairs(result_tree) do |
314 | for version, repos in util.sortedpairs(versions, vers.compare_versions) do | 314 | for version, repos in util.sortedpairs(versions, vers.compare_versions) do |
@@ -320,7 +320,7 @@ function search.print_result_tree(result_tree, porcelain) | |||
320 | end | 320 | end |
321 | return | 321 | return |
322 | end | 322 | end |
323 | 323 | ||
324 | for package, versions in util.sortedpairs(result_tree) do | 324 | for package, versions in util.sortedpairs(result_tree) do |
325 | local namespaces = {} | 325 | local namespaces = {} |
326 | for version, repos in util.sortedpairs(versions, vers.compare_versions) do | 326 | for version, repos in util.sortedpairs(versions, vers.compare_versions) do |
diff --git a/src/luarocks/signing.lua b/src/luarocks/signing.lua index 2e61041e..cb91643a 100644 --- a/src/luarocks/signing.lua +++ b/src/luarocks/signing.lua | |||
@@ -22,7 +22,7 @@ function signing.sign_file(file) | |||
22 | if not gpg then | 22 | if not gpg then |
23 | return nil, err | 23 | return nil, err |
24 | end | 24 | end |
25 | 25 | ||
26 | local sigfile = file .. ".asc" | 26 | local sigfile = file .. ".asc" |
27 | if fs.execute(gpg, "--armor", "--output", sigfile, "--detach-sign", file) then | 27 | if fs.execute(gpg, "--armor", "--output", sigfile, "--detach-sign", file) then |
28 | return sigfile | 28 | return sigfile |
diff --git a/src/luarocks/test.lua b/src/luarocks/test.lua index c550c5b8..15eca234 100644 --- a/src/luarocks/test.lua +++ b/src/luarocks/test.lua | |||
@@ -22,13 +22,13 @@ local function get_test_type(rockspec) | |||
22 | if rockspec.test and rockspec.test.type then | 22 | if rockspec.test and rockspec.test.type then |
23 | return rockspec.test.type | 23 | return rockspec.test.type |
24 | end | 24 | end |
25 | 25 | ||
26 | for _, test_module in ipairs(test_modules) do | 26 | for _, test_module in ipairs(test_modules) do |
27 | if test_module.detect_type() then | 27 | if test_module.detect_type() then |
28 | return test_modules[test_module] | 28 | return test_modules[test_module] |
29 | end | 29 | end |
30 | end | 30 | end |
31 | 31 | ||
32 | return nil, "could not detect test type -- no test suite for " .. rockspec.package .. "?" | 32 | return nil, "could not detect test type -- no test suite for " .. rockspec.package .. "?" |
33 | end | 33 | end |
34 | 34 | ||
@@ -45,7 +45,7 @@ function test.run_test_suite(rockspec_arg, test_type, args) | |||
45 | assert(type(rockspec_arg) == "table") | 45 | assert(type(rockspec_arg) == "table") |
46 | rockspec = rockspec_arg | 46 | rockspec = rockspec_arg |
47 | end | 47 | end |
48 | 48 | ||
49 | if not test_type then | 49 | if not test_type then |
50 | local err | 50 | local err |
51 | test_type, err = get_test_type(rockspec, test_type) | 51 | test_type, err = get_test_type(rockspec, test_type) |
@@ -67,7 +67,7 @@ function test.run_test_suite(rockspec_arg, test_type, args) | |||
67 | if not pok then | 67 | if not pok then |
68 | return nil, "failed loading test execution module " .. mod_name | 68 | return nil, "failed loading test execution module " .. mod_name |
69 | end | 69 | end |
70 | 70 | ||
71 | return test_mod.run_tests(rockspec.test, args) | 71 | return test_mod.run_tests(rockspec.test, args) |
72 | end | 72 | end |
73 | 73 | ||
diff --git a/src/luarocks/test/command.lua b/src/luarocks/test/command.lua index 999cc325..1795c4e9 100644 --- a/src/luarocks/test/command.lua +++ b/src/luarocks/test/command.lua | |||
@@ -20,7 +20,7 @@ function command.run_tests(test, args) | |||
20 | script = "test.lua" | 20 | script = "test.lua" |
21 | } | 21 | } |
22 | end | 22 | end |
23 | 23 | ||
24 | if not test.script and not test.command then | 24 | if not test.script and not test.command then |
25 | test.script = "test.lua" | 25 | test.script = "test.lua" |
26 | end | 26 | end |
@@ -31,7 +31,7 @@ function command.run_tests(test, args) | |||
31 | table.insert(args, i, test.flags[i]) | 31 | table.insert(args, i, test.flags[i]) |
32 | end | 32 | end |
33 | end | 33 | end |
34 | 34 | ||
35 | local ok | 35 | local ok |
36 | 36 | ||
37 | if test.script then | 37 | if test.script then |
diff --git a/src/luarocks/tools/patch.lua b/src/luarocks/tools/patch.lua index 829df931..b12f38fc 100644 --- a/src/luarocks/tools/patch.lua +++ b/src/luarocks/tools/patch.lua | |||
@@ -114,7 +114,7 @@ local function file_lines(f) | |||
114 | pos_beg = pos + 1 | 114 | pos_beg = pos + 1 |
115 | if #line > 0 then | 115 | if #line > 0 then |
116 | return line | 116 | return line |
117 | end | 117 | end |
118 | end | 118 | end |
119 | end | 119 | end |
120 | 120 | ||
@@ -526,7 +526,7 @@ local function patch_hunks(srcname, tgtname, hunks) | |||
526 | tgt:close() | 526 | tgt:close() |
527 | src:close() | 527 | src:close() |
528 | return true | 528 | return true |
529 | end | 529 | end |
530 | 530 | ||
531 | local function strip_dirs(filename, strip) | 531 | local function strip_dirs(filename, strip) |
532 | if strip == nil then return filename end | 532 | if strip == nil then return filename end |
@@ -616,7 +616,7 @@ local function patch_file(source, target, epoch, hunks, strip, create_delete) | |||
616 | end | 616 | end |
617 | end | 617 | end |
618 | hunklineno = 1 | 618 | hunklineno = 1 |
619 | 619 | ||
620 | -- todo \ No newline at end of file | 620 | -- todo \ No newline at end of file |
621 | end | 621 | end |
622 | -- check hunks in source file | 622 | -- check hunks in source file |
diff --git a/src/luarocks/tools/tar.lua b/src/luarocks/tools/tar.lua index a6a95252..aea2809c 100644 --- a/src/luarocks/tools/tar.lua +++ b/src/luarocks/tools/tar.lua | |||
@@ -30,7 +30,7 @@ local function octal_to_number(octal) | |||
30 | local number = 0 | 30 | local number = 0 |
31 | octal = octal:gsub("%s", "") | 31 | octal = octal:gsub("%s", "") |
32 | for i = #octal,1,-1 do | 32 | for i = #octal,1,-1 do |
33 | local digit = tonumber(octal:sub(i,i)) | 33 | local digit = tonumber(octal:sub(i,i)) |
34 | if not digit then | 34 | if not digit then |
35 | break | 35 | break |
36 | end | 36 | end |
@@ -93,7 +93,7 @@ function tar.untar(filename, destdir) | |||
93 | 93 | ||
94 | local tar_handle = io.open(filename, "rb") | 94 | local tar_handle = io.open(filename, "rb") |
95 | if not tar_handle then return nil, "Error opening file "..filename end | 95 | if not tar_handle then return nil, "Error opening file "..filename end |
96 | 96 | ||
97 | local long_name, long_link_name | 97 | local long_name, long_link_name |
98 | local ok, err | 98 | local ok, err |
99 | local make_dir = fun.memoize(fs.make_dir) | 99 | local make_dir = fun.memoize(fs.make_dir) |
diff --git a/src/luarocks/tools/zip.lua b/src/luarocks/tools/zip.lua index 37091185..7803b509 100644 --- a/src/luarocks/tools/zip.lua +++ b/src/luarocks/tools/zip.lua | |||
@@ -129,7 +129,7 @@ end | |||
129 | -- @return true if succeeded, nil in case of failure. | 129 | -- @return true if succeeded, nil in case of failure. |
130 | local function zipwriter_close_file_in_zip(self) | 130 | local function zipwriter_close_file_in_zip(self) |
131 | local zh = self.ziphandle | 131 | local zh = self.ziphandle |
132 | 132 | ||
133 | if not self.in_open_file then | 133 | if not self.in_open_file then |
134 | return nil | 134 | return nil |
135 | end | 135 | end |
@@ -152,16 +152,16 @@ local function zipwriter_close_file_in_zip(self) | |||
152 | 152 | ||
153 | -- File data | 153 | -- File data |
154 | zh:write(self.data) | 154 | zh:write(self.data) |
155 | 155 | ||
156 | -- Data descriptor | 156 | -- Data descriptor |
157 | zh:write(DATA_DESCRIPTOR_SIGNATURE) | 157 | zh:write(DATA_DESCRIPTOR_SIGNATURE) |
158 | zh:write(number_to_lestring(lfh.crc32, 4)) | 158 | zh:write(number_to_lestring(lfh.crc32, 4)) |
159 | zh:write(number_to_lestring(lfh.compressed_size, 4)) | 159 | zh:write(number_to_lestring(lfh.compressed_size, 4)) |
160 | zh:write(number_to_lestring(lfh.uncompressed_size, 4)) | 160 | zh:write(number_to_lestring(lfh.uncompressed_size, 4)) |
161 | 161 | ||
162 | table.insert(self.files, lfh) | 162 | table.insert(self.files, lfh) |
163 | self.in_open_file = false | 163 | self.in_open_file = false |
164 | 164 | ||
165 | return true | 165 | return true |
166 | end | 166 | end |
167 | 167 | ||
@@ -208,9 +208,9 @@ end | |||
208 | -- @return true if succeeded, nil in case of failure. | 208 | -- @return true if succeeded, nil in case of failure. |
209 | local function zipwriter_close(self) | 209 | local function zipwriter_close(self) |
210 | local zh = self.ziphandle | 210 | local zh = self.ziphandle |
211 | 211 | ||
212 | local central_directory_offset = zh:seek() | 212 | local central_directory_offset = zh:seek() |
213 | 213 | ||
214 | local size_of_central_directory = 0 | 214 | local size_of_central_directory = 0 |
215 | -- Central directory structure | 215 | -- Central directory structure |
216 | for _, lfh in ipairs(self.files) do | 216 | for _, lfh in ipairs(self.files) do |
@@ -234,7 +234,7 @@ local function zipwriter_close(self) | |||
234 | zh:write(lfh.file_name) | 234 | zh:write(lfh.file_name) |
235 | size_of_central_directory = size_of_central_directory + 46 + lfh.file_name_length | 235 | size_of_central_directory = size_of_central_directory + 46 + lfh.file_name_length |
236 | end | 236 | end |
237 | 237 | ||
238 | -- End of central directory record | 238 | -- End of central directory record |
239 | zh:write(END_OF_CENTRAL_DIR_SIGNATURE) -- signature | 239 | zh:write(END_OF_CENTRAL_DIR_SIGNATURE) -- signature |
240 | zh:write(number_to_lestring(0, 2)) -- number of this disk | 240 | zh:write(number_to_lestring(0, 2)) -- number of this disk |
@@ -253,16 +253,16 @@ end | |||
253 | -- @param name filename of the zipfile to be created. | 253 | -- @param name filename of the zipfile to be created. |
254 | -- @return a zip handle, or nil in case of error. | 254 | -- @return a zip handle, or nil in case of error. |
255 | function zip.new_zipwriter(name) | 255 | function zip.new_zipwriter(name) |
256 | 256 | ||
257 | local zw = {} | 257 | local zw = {} |
258 | 258 | ||
259 | zw.ziphandle = io.open(fs.absolute_name(name), "wb") | 259 | zw.ziphandle = io.open(fs.absolute_name(name), "wb") |
260 | if not zw.ziphandle then | 260 | if not zw.ziphandle then |
261 | return nil | 261 | return nil |
262 | end | 262 | end |
263 | zw.files = {} | 263 | zw.files = {} |
264 | zw.in_open_file = false | 264 | zw.in_open_file = false |
265 | 265 | ||
266 | zw.add = zipwriter_add | 266 | zw.add = zipwriter_add |
267 | zw.close = zipwriter_close | 267 | zw.close = zipwriter_close |
268 | zw.open_new_file_in_zip = zipwriter_open_new_file_in_zip | 268 | zw.open_new_file_in_zip = zipwriter_open_new_file_in_zip |
@@ -381,7 +381,7 @@ local function process_end_of_central_dir(zh) | |||
381 | return nil, "Could not find End of Central Directory signature" | 381 | return nil, "Could not find End of Central Directory signature" |
382 | end | 382 | end |
383 | end | 383 | end |
384 | 384 | ||
385 | -- number of this disk (2 bytes) | 385 | -- number of this disk (2 bytes) |
386 | -- number of the disk with the start of the central directory (2 bytes) | 386 | -- number of the disk with the start of the central directory (2 bytes) |
387 | -- total number of entries in the central directory on this disk (2 bytes) | 387 | -- total number of entries in the central directory on this disk (2 bytes) |
@@ -450,7 +450,7 @@ function zip.unzip(zipfile) | |||
450 | if not cd_entries then | 450 | if not cd_entries then |
451 | return nil, cd_offset | 451 | return nil, cd_offset |
452 | end | 452 | end |
453 | 453 | ||
454 | local ok, err = zh:seek("set", cd_offset) | 454 | local ok, err = zh:seek("set", cd_offset) |
455 | if not ok then | 455 | if not ok then |
456 | return nil, err | 456 | return nil, err |
@@ -513,7 +513,7 @@ end | |||
513 | function zip.gzip(input_filename, output_filename) | 513 | function zip.gzip(input_filename, output_filename) |
514 | assert(type(input_filename) == "string") | 514 | assert(type(input_filename) == "string") |
515 | assert(output_filename == nil or type(output_filename) == "string") | 515 | assert(output_filename == nil or type(output_filename) == "string") |
516 | 516 | ||
517 | if not output_filename then | 517 | if not output_filename then |
518 | output_filename = input_filename .. ".gz" | 518 | output_filename = input_filename .. ".gz" |
519 | end | 519 | end |
@@ -525,7 +525,7 @@ end | |||
525 | function zip.gunzip(input_filename, output_filename) | 525 | function zip.gunzip(input_filename, output_filename) |
526 | assert(type(input_filename) == "string") | 526 | assert(type(input_filename) == "string") |
527 | assert(output_filename == nil or type(output_filename) == "string") | 527 | assert(output_filename == nil or type(output_filename) == "string") |
528 | 528 | ||
529 | if not output_filename then | 529 | if not output_filename then |
530 | output_filename = input_filename:gsub("%.gz$", "") | 530 | output_filename = input_filename:gsub("%.gz$", "") |
531 | end | 531 | end |
diff --git a/src/luarocks/type/manifest.lua b/src/luarocks/type/manifest.lua index bf985ad3..043366ea 100644 --- a/src/luarocks/type/manifest.lua +++ b/src/luarocks/type/manifest.lua | |||
@@ -64,7 +64,7 @@ local manifest_formats = type_check.declare_schemas({ | |||
64 | }) | 64 | }) |
65 | 65 | ||
66 | --- Type check a manifest table. | 66 | --- Type check a manifest table. |
67 | -- Verify the correctness of elements from a | 67 | -- Verify the correctness of elements from a |
68 | -- manifest table, reporting on unknown fields and type | 68 | -- manifest table, reporting on unknown fields and type |
69 | -- mismatches. | 69 | -- mismatches. |
70 | -- @return boolean or (nil, string): true if type checking | 70 | -- @return boolean or (nil, string): true if type checking |
diff --git a/src/luarocks/type/rockspec.lua b/src/luarocks/type/rockspec.lua index 8214516e..0b4b5dcf 100644 --- a/src/luarocks/type/rockspec.lua +++ b/src/luarocks/type/rockspec.lua | |||
@@ -89,13 +89,13 @@ local rockspec_formats, versions = type_check.declare_schemas({ | |||
89 | post_install = { _type = "string" }, | 89 | post_install = { _type = "string" }, |
90 | }, | 90 | }, |
91 | }, | 91 | }, |
92 | 92 | ||
93 | ["1.1"] = { | 93 | ["1.1"] = { |
94 | deploy = { | 94 | deploy = { |
95 | wrap_bin_scripts = { _type = "boolean" }, | 95 | wrap_bin_scripts = { _type = "boolean" }, |
96 | } | 96 | } |
97 | }, | 97 | }, |
98 | 98 | ||
99 | ["3.0"] = { | 99 | ["3.0"] = { |
100 | description = { | 100 | description = { |
101 | labels = { | 101 | labels = { |
@@ -135,7 +135,7 @@ local rockspec_formats, versions = type_check.declare_schemas({ | |||
135 | } | 135 | } |
136 | }) | 136 | }) |
137 | 137 | ||
138 | type_rockspec.order = {"rockspec_format", "package", "version", | 138 | type_rockspec.order = {"rockspec_format", "package", "version", |
139 | { "source", { "url", "tag", "branch", "md5" } }, | 139 | { "source", { "url", "tag", "branch", "md5" } }, |
140 | { "description", {"summary", "detailed", "homepage", "license" } }, | 140 | { "description", {"summary", "detailed", "homepage", "license" } }, |
141 | "supported_platforms", "dependencies", "build_dependencies", "external_dependencies", | 141 | "supported_platforms", "dependencies", "build_dependencies", "external_dependencies", |
@@ -160,7 +160,7 @@ local function check_rockspec_using_version(rockspec, globals, version) | |||
160 | end | 160 | end |
161 | 161 | ||
162 | --- Type check a rockspec table. | 162 | --- Type check a rockspec table. |
163 | -- Verify the correctness of elements from a | 163 | -- Verify the correctness of elements from a |
164 | -- rockspec table, reporting on unknown fields and type | 164 | -- rockspec table, reporting on unknown fields and type |
165 | -- mismatches. | 165 | -- mismatches. |
166 | -- @return boolean or (nil, string): true if type checking | 166 | -- @return boolean or (nil, string): true if type checking |
diff --git a/src/luarocks/type_check.lua b/src/luarocks/type_check.lua index bdf8ecc8..21085ef9 100644 --- a/src/luarocks/type_check.lua +++ b/src/luarocks/type_check.lua | |||
@@ -22,7 +22,7 @@ do | |||
22 | end | 22 | end |
23 | end | 23 | end |
24 | end | 24 | end |
25 | 25 | ||
26 | local function expand_magic_platforms(tbl) | 26 | local function expand_magic_platforms(tbl) |
27 | for k,v in pairs(tbl) do | 27 | for k,v in pairs(tbl) do |
28 | if v == type_check.MAGIC_PLATFORMS then | 28 | if v == type_check.MAGIC_PLATFORMS then |
@@ -35,7 +35,7 @@ do | |||
35 | end | 35 | end |
36 | end | 36 | end |
37 | end | 37 | end |
38 | 38 | ||
39 | -- Build a table of schemas. | 39 | -- Build a table of schemas. |
40 | -- @param versions a table where each key is a version number as a string, | 40 | -- @param versions a table where each key is a version number as a string, |
41 | -- and the value is a schema specification. Schema versions are considered | 41 | -- and the value is a schema specification. Schema versions are considered |
@@ -44,7 +44,7 @@ do | |||
44 | function type_check.declare_schemas(inputs) | 44 | function type_check.declare_schemas(inputs) |
45 | local schemas = {} | 45 | local schemas = {} |
46 | local parent_version | 46 | local parent_version |
47 | 47 | ||
48 | local versions = fun.reverse_in(fun.sort_in(util.keys(inputs), vers.compare_versions)) | 48 | local versions = fun.reverse_in(fun.sort_in(util.keys(inputs), vers.compare_versions)) |
49 | 49 | ||
50 | for _, version in ipairs(versions) do | 50 | for _, version in ipairs(versions) do |
@@ -99,10 +99,10 @@ local function type_check_item(version, item, typetbl, context) | |||
99 | return nil, err | 99 | return nil, err |
100 | end | 100 | end |
101 | end | 101 | end |
102 | 102 | ||
103 | local item_type = type(item) or "nil" | 103 | local item_type = type(item) or "nil" |
104 | local expected_type = typetbl._type or "table" | 104 | local expected_type = typetbl._type or "table" |
105 | 105 | ||
106 | if expected_type == "number" then | 106 | if expected_type == "number" then |
107 | if not tonumber(item) then | 107 | if not tonumber(item) then |
108 | return nil, "Type mismatch on field "..context..": expected a number" | 108 | return nil, "Type mismatch on field "..context..": expected a number" |
@@ -148,7 +148,7 @@ end | |||
148 | -- in tbl that is correctly typed, type(tbl.x) == type(types.x)). | 148 | -- in tbl that is correctly typed, type(tbl.x) == type(types.x)). |
149 | -- If the reference table contains a field called MORE, then | 149 | -- If the reference table contains a field called MORE, then |
150 | -- unknown fields in the checked table are accepted. | 150 | -- unknown fields in the checked table are accepted. |
151 | -- If it contains a field called ANY, then its type will be | 151 | -- If it contains a field called ANY, then its type will be |
152 | -- used to check any unknown fields. If a field is prefixed | 152 | -- used to check any unknown fields. If a field is prefixed |
153 | -- with MUST_, it is mandatory; its absence from the table is | 153 | -- with MUST_, it is mandatory; its absence from the table is |
154 | -- a type error. | 154 | -- a type error. |
@@ -174,7 +174,7 @@ function type_check.type_check_table(version, tbl, typetbl, context) | |||
174 | 174 | ||
175 | for k, v in pairs(tbl) do | 175 | for k, v in pairs(tbl) do |
176 | local t = typetbl[k] or typetbl._any | 176 | local t = typetbl[k] or typetbl._any |
177 | if t then | 177 | if t then |
178 | local ok, err = type_check_item(version, v, t, mkfield(context, k)) | 178 | local ok, err = type_check_item(version, v, t, mkfield(context, k)) |
179 | if not ok then return nil, err end | 179 | if not ok then return nil, err end |
180 | elseif typetbl._more then | 180 | elseif typetbl._more then |
diff --git a/src/luarocks/upload/api.lua b/src/luarocks/upload/api.lua index a28b517a..df57fc80 100644 --- a/src/luarocks/upload/api.lua +++ b/src/luarocks/upload/api.lua | |||
@@ -120,7 +120,7 @@ function Api:request(url, params, post_params) | |||
120 | local vars = cfg.variables | 120 | local vars = cfg.variables |
121 | local json_ok, json = util.require_json() | 121 | local json_ok, json = util.require_json() |
122 | if not json_ok then return nil, "A JSON library is required for this command. "..json end | 122 | if not json_ok then return nil, "A JSON library is required for this command. "..json end |
123 | 123 | ||
124 | if fs.which_tool("downloader") == "wget" then | 124 | if fs.which_tool("downloader") == "wget" then |
125 | local curl_ok, err = fs.is_tool_available(vars.CURL, "curl") | 125 | local curl_ok, err = fs.is_tool_available(vars.CURL, "curl") |
126 | if not curl_ok then | 126 | if not curl_ok then |
@@ -135,7 +135,7 @@ function Api:request(url, params, post_params) | |||
135 | url = url .. ("?" .. encode_query_string(params)) | 135 | url = url .. ("?" .. encode_query_string(params)) |
136 | end | 136 | end |
137 | local method = "GET" | 137 | local method = "GET" |
138 | local out | 138 | local out |
139 | local tmpfile = fs.tmpname() | 139 | local tmpfile = fs.tmpname() |
140 | if post_params then | 140 | if post_params then |
141 | method = "POST" | 141 | method = "POST" |
@@ -148,7 +148,7 @@ function Api:request(url, params, post_params) | |||
148 | curl_cmd = curl_cmd .. "--form \""..k.."="..var.."\" " | 148 | curl_cmd = curl_cmd .. "--form \""..k.."="..var.."\" " |
149 | end | 149 | end |
150 | if cfg.connection_timeout and cfg.connection_timeout > 0 then | 150 | if cfg.connection_timeout and cfg.connection_timeout > 0 then |
151 | curl_cmd = curl_cmd .. "--connect-timeout "..tonumber(cfg.connection_timeout).." " | 151 | curl_cmd = curl_cmd .. "--connect-timeout "..tonumber(cfg.connection_timeout).." " |
152 | end | 152 | end |
153 | local ok = fs.execute_string(curl_cmd..fs.Q(url).." -o "..fs.Q(tmpfile)) | 153 | local ok = fs.execute_string(curl_cmd..fs.Q(url).." -o "..fs.Q(tmpfile)) |
154 | if not ok then | 154 | if not ok then |
@@ -206,7 +206,7 @@ function Api:request(url, params, post_params) | |||
206 | if not http_ok then | 206 | if not http_ok then |
207 | return nil, "Failed loading socket library!" | 207 | return nil, "Failed loading socket library!" |
208 | end | 208 | end |
209 | 209 | ||
210 | if not self.config.key then | 210 | if not self.config.key then |
211 | return nil, "Must have API key before performing any actions." | 211 | return nil, "Must have API key before performing any actions." |
212 | end | 212 | end |
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index 6161a061..ae96eb6a 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
@@ -34,7 +34,7 @@ local debug = require("debug") | |||
34 | -- which can be used to remove the item later from the list. | 34 | -- which can be used to remove the item later from the list. |
35 | function util.schedule_function(f, ...) | 35 | function util.schedule_function(f, ...) |
36 | assert(type(f) == "function") | 36 | assert(type(f) == "function") |
37 | 37 | ||
38 | local item = { fn = f, args = pack(...) } | 38 | local item = { fn = f, args = pack(...) } |
39 | table.insert(scheduled_functions, item) | 39 | table.insert(scheduled_functions, item) |
40 | return item | 40 | return item |
@@ -122,12 +122,12 @@ end | |||
122 | -- exists in vars. Only string values are processed; this function | 122 | -- exists in vars. Only string values are processed; this function |
123 | -- does not scan subtables recursively. | 123 | -- does not scan subtables recursively. |
124 | -- @param tbl table: Table to have its string values modified. | 124 | -- @param tbl table: Table to have its string values modified. |
125 | -- @param vars table: Table containing string-string key-value pairs | 125 | -- @param vars table: Table containing string-string key-value pairs |
126 | -- representing variables to replace in the strings values of tbl. | 126 | -- representing variables to replace in the strings values of tbl. |
127 | function util.variable_substitutions(tbl, vars) | 127 | function util.variable_substitutions(tbl, vars) |
128 | assert(type(tbl) == "table") | 128 | assert(type(tbl) == "table") |
129 | assert(type(vars) == "table") | 129 | assert(type(vars) == "table") |
130 | 130 | ||
131 | local updated = {} | 131 | local updated = {} |
132 | for k, v in pairs(tbl) do | 132 | for k, v in pairs(tbl) do |
133 | if type(v) == "string" then | 133 | if type(v) == "string" then |
@@ -450,7 +450,7 @@ do | |||
450 | function util.get_luajit_version() | 450 | function util.get_luajit_version() |
451 | local cfg = require("luarocks.core.cfg") | 451 | local cfg = require("luarocks.core.cfg") |
452 | if cfg.cache.luajit_version_checked then | 452 | if cfg.cache.luajit_version_checked then |
453 | return cfg.cache.luajit_version | 453 | return cfg.cache.luajit_version |
454 | end | 454 | end |
455 | cfg.cache.luajit_version_checked = true | 455 | cfg.cache.luajit_version_checked = true |
456 | 456 | ||
@@ -553,9 +553,9 @@ end | |||
553 | 553 | ||
554 | function util.opts_table(type_name, valid_opts) | 554 | function util.opts_table(type_name, valid_opts) |
555 | local opts_mt = {} | 555 | local opts_mt = {} |
556 | 556 | ||
557 | opts_mt.__index = opts_mt | 557 | opts_mt.__index = opts_mt |
558 | 558 | ||
559 | function opts_mt.type() | 559 | function opts_mt.type() |
560 | return type_name | 560 | return type_name |
561 | end | 561 | end |
@@ -590,7 +590,7 @@ end | |||
590 | -- "lua" for the Lua version and, for format 3.0+, "luajit" if detected). | 590 | -- "lua" for the Lua version and, for format 3.0+, "luajit" if detected). |
591 | function util.get_rocks_provided(rockspec) | 591 | function util.get_rocks_provided(rockspec) |
592 | local cfg = require("luarocks.core.cfg") | 592 | local cfg = require("luarocks.core.cfg") |
593 | 593 | ||
594 | if not rockspec and cfg.cache.rocks_provided then | 594 | if not rockspec and cfg.cache.rocks_provided then |
595 | return cfg.cache.rocks_provided | 595 | return cfg.cache.rocks_provided |
596 | end | 596 | end |