editorconfig: trim trailing whitespace
parent
2b56388e76
commit
8f3ce333e7
|
@ -1,6 +1,8 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
|
||||
|
|
|
@ -23,20 +23,20 @@ describe("LuaRocks add tests #integration", function()
|
|||
it("missing argument", function()
|
||||
assert.is_false(run.luarocks_admin_bool("--server=testing add"))
|
||||
end)
|
||||
|
||||
|
||||
it("invalid server", function()
|
||||
assert.is_false(run.luarocks_admin_bool("--server=invalid add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.src.rock"))
|
||||
end)
|
||||
|
||||
|
||||
it("invalid server #ssh", function()
|
||||
assert.is_true(run.luarocks_admin_bool("--server=testing add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.src.rock"))
|
||||
end)
|
||||
|
||||
|
||||
--TODO This test fails, sftp support not yet implemented
|
||||
it("invalid server", function()
|
||||
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" } ))
|
||||
end)
|
||||
|
||||
|
||||
it("split server url", function()
|
||||
assert.is_false(run.luarocks_admin_bool("--server=\"localhost@/tmp/luarocks_testing\" add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.src.rock"))
|
||||
end)
|
||||
|
|
|
@ -55,7 +55,7 @@ describe("LuaRocks build #integration", function()
|
|||
it("invalid", function()
|
||||
assert.is_false(run.luarocks_bool("build invalid"))
|
||||
end)
|
||||
|
||||
|
||||
it("with no arguments behaves as luarocks make", function()
|
||||
test_env.run_in_tmp(function(tmpdir)
|
||||
write_file("c_module-1.0-1.rockspec", [[
|
||||
|
@ -72,7 +72,7 @@ describe("LuaRocks build #integration", function()
|
|||
}
|
||||
]], finally)
|
||||
write_file("c_module.c", c_module_source, finally)
|
||||
|
||||
|
||||
assert.is_true(run.luarocks_bool("build"))
|
||||
assert.truthy(lfs.attributes(tmpdir .. "/c_module." .. test_env.lib_extension))
|
||||
end, finally)
|
||||
|
@ -84,12 +84,12 @@ describe("LuaRocks build #integration", function()
|
|||
assert.is_false(run.luarocks_bool("build --tree=/usr " .. testing_paths.fixtures_dir .. "/a_rock-1.0.1-rockspec"))
|
||||
assert.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec"))
|
||||
end)
|
||||
|
||||
|
||||
it("fails if it doesn't have the permissions to access the specified tree's parent #unix", function()
|
||||
assert.is_false(run.luarocks_bool("build --tree=/usr/invalid " .. testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec"))
|
||||
assert.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec"))
|
||||
end)
|
||||
|
||||
|
||||
it("verbose", function()
|
||||
test_env.run_in_tmp(function(tmpdir)
|
||||
write_file("test-1.0-1.rockspec", [[
|
||||
|
@ -99,7 +99,7 @@ describe("LuaRocks build #integration", function()
|
|||
url = "file://]] .. tmpdir:gsub("\\", "/") .. [[/test.lua"
|
||||
}
|
||||
build = {
|
||||
type = "builtin",
|
||||
type = "builtin",
|
||||
modules = {
|
||||
test = "test.lua"
|
||||
}
|
||||
|
@ -111,14 +111,14 @@ describe("LuaRocks build #integration", function()
|
|||
assert.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/test/1.0-1/test-1.0-1.rockspec"))
|
||||
end, finally)
|
||||
end)
|
||||
|
||||
|
||||
it("fails if the deps-mode argument is invalid", function()
|
||||
assert.is_false(run.luarocks_bool("build --deps-mode=123 " .. testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec"))
|
||||
assert.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec"))
|
||||
end)
|
||||
|
||||
|
||||
it("with --only-sources", function()
|
||||
assert.is_true(run.luarocks_bool("download --server=" .. testing_paths.fixtures_dir .. "/a_repo --rockspec a_rock 1.0"))
|
||||
assert.is_true(run.luarocks_bool("download --server=" .. testing_paths.fixtures_dir .. "/a_repo --rockspec a_rock 1.0"))
|
||||
assert.is_false(run.luarocks_bool("build --only-sources=\"http://example.com\" a_rock-1.0-1.rockspec"))
|
||||
assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec"))
|
||||
|
||||
|
@ -129,7 +129,7 @@ describe("LuaRocks build #integration", function()
|
|||
assert.is_true(os.remove("a_rock-1.0-1.rockspec"))
|
||||
assert.is_true(os.remove("a_rock-1.0-1.src.rock"))
|
||||
end)
|
||||
|
||||
|
||||
it("fails if an empty tree is given", function()
|
||||
assert.is_false(run.luarocks_bool("build --tree=\"\" " .. testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec"))
|
||||
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()
|
|||
assert.is_true(run.luarocks_bool("build luacov 0.13.0-1"))
|
||||
assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luacov/0.13.0-1/luacov-0.13.0-1.rockspec"))
|
||||
end)
|
||||
|
||||
|
||||
it("command stdlib", function()
|
||||
assert.is_true(run.luarocks_bool("build stdlib"))
|
||||
assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/stdlib/41.0.0-1/stdlib-41.0.0-1.rockspec"))
|
||||
end)
|
||||
|
||||
|
||||
it("fails if the current platform is not supported", function()
|
||||
test_env.run_in_tmp(function(tmpdir)
|
||||
write_file("test-1.0-1.rockspec", [[
|
||||
|
@ -159,7 +159,7 @@ describe("LuaRocks build #integration", function()
|
|||
"unix", "macosx"
|
||||
}
|
||||
build = {
|
||||
type = "builtin",
|
||||
type = "builtin",
|
||||
modules = {
|
||||
test = "test.lua"
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ describe("LuaRocks build #integration", function()
|
|||
end
|
||||
end, finally)
|
||||
end)
|
||||
|
||||
|
||||
it("with skipping dependency checks", function()
|
||||
test_env.run_in_tmp(function(tmpdir)
|
||||
write_file("test-1.0-1.rockspec", [[
|
||||
|
@ -189,7 +189,7 @@ describe("LuaRocks build #integration", function()
|
|||
"a_rock 1.0"
|
||||
}
|
||||
build = {
|
||||
type = "builtin",
|
||||
type = "builtin",
|
||||
modules = {
|
||||
test = "test.lua"
|
||||
}
|
||||
|
@ -342,7 +342,7 @@ describe("LuaRocks build #integration", function()
|
|||
assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/build_only_deps/0.1-1/build_only_deps-0.1-1.rockspec"))
|
||||
assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec"))
|
||||
end)
|
||||
|
||||
|
||||
it("only deps of a given rockspec", function()
|
||||
test_env.run_in_tmp(function(tmpdir)
|
||||
write_file("test-1.0-1.rockspec", [[
|
||||
|
@ -355,7 +355,7 @@ describe("LuaRocks build #integration", function()
|
|||
"a_rock 1.0"
|
||||
}
|
||||
build = {
|
||||
type = "builtin",
|
||||
type = "builtin",
|
||||
modules = {
|
||||
test = "test.lua"
|
||||
}
|
||||
|
@ -381,7 +381,7 @@ describe("LuaRocks build #integration", function()
|
|||
"a_rock 1.0"
|
||||
}
|
||||
build = {
|
||||
type = "builtin",
|
||||
type = "builtin",
|
||||
modules = {
|
||||
test = "test.lua"
|
||||
}
|
||||
|
@ -406,18 +406,18 @@ describe("LuaRocks build #integration", function()
|
|||
describe("rockspec format 3.0 #rs3", function()
|
||||
local tmpdir
|
||||
local olddir
|
||||
|
||||
|
||||
before_each(function()
|
||||
tmpdir = get_tmp_path()
|
||||
olddir = lfs.currentdir()
|
||||
lfs.mkdir(tmpdir)
|
||||
lfs.chdir(tmpdir)
|
||||
|
||||
|
||||
lfs.mkdir("autodetect")
|
||||
write_file("autodetect/bla.lua", "return {}", finally)
|
||||
write_file("c_module.c", c_module_source, finally)
|
||||
end)
|
||||
|
||||
|
||||
after_each(function()
|
||||
if olddir then
|
||||
lfs.chdir(olddir)
|
||||
|
@ -427,7 +427,7 @@ describe("LuaRocks build #integration", function()
|
|||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
it("defaults to build.type == 'builtin'", function()
|
||||
local rockspec = "a_rock-1.0-1.rockspec"
|
||||
test_env.write_file(rockspec, [[
|
||||
|
@ -509,7 +509,7 @@ describe("LuaRocks build #integration", function()
|
|||
lazy_teardown(function()
|
||||
test_env.mock_server_done()
|
||||
end)
|
||||
|
||||
|
||||
it("fails when missing external dependency", function()
|
||||
test_env.run_in_tmp(function(tmpdir)
|
||||
write_file("missing_external-0.1-1.rockspec", [[
|
||||
|
@ -545,7 +545,7 @@ describe("LuaRocks build #integration", function()
|
|||
assert.is.truthy(run.luarocks("show with_external_dep"))
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("#build_dependencies", function()
|
||||
it("builds with a build dependency", function()
|
||||
assert(run.luarocks_bool("build has_build_dep --server=" .. testing_paths.fixtures_dir .. "/a_repo" ))
|
||||
|
@ -969,7 +969,7 @@ describe("LuaRocks build #unit", function()
|
|||
elseif test_env.TEST_TARGET_OS == "osx" then
|
||||
os.execute("cc -dynamiclib -o " .. fdir .. "/libfixturedep.dylib " .. fdir .. "/fixturedep.c")
|
||||
end
|
||||
|
||||
|
||||
local rockspec = {
|
||||
rockspec_format = "3.0",
|
||||
package = "c_module",
|
||||
|
@ -1026,7 +1026,7 @@ describe("LuaRocks build #unit", function()
|
|||
lazy_setup(function()
|
||||
git = git_repo.start()
|
||||
end)
|
||||
|
||||
|
||||
lazy_teardown(function()
|
||||
if git then
|
||||
git:stop()
|
||||
|
|
|
@ -5,7 +5,7 @@ local run = test_env.run
|
|||
test_env.unload_luarocks()
|
||||
|
||||
describe("LuaRocks command line #integration", function()
|
||||
|
||||
|
||||
setup(function()
|
||||
test_env.setup_specs()
|
||||
end)
|
||||
|
|
|
@ -9,7 +9,7 @@ local hardcoded
|
|||
test_env.unload_luarocks()
|
||||
|
||||
describe("LuaRocks config tests #integration", function()
|
||||
|
||||
|
||||
setup(function()
|
||||
test_env.setup_specs()
|
||||
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()
|
|||
local output = run.luarocks("config --lua-incdir")
|
||||
assert.match(hardcoded.LUA_DIR, output, 1, true)
|
||||
end)
|
||||
|
||||
|
||||
it("--lua-libdir returns a subdir of LUA_DIR", function()
|
||||
local output = run.luarocks("config --lua-libdir")
|
||||
assert.match(hardcoded.LUA_DIR, output, 1, true)
|
||||
end)
|
||||
|
||||
|
||||
it("--lua-ver returns the Lua version", function()
|
||||
local output = run.luarocks("config --lua-ver")
|
||||
local lua_version = _VERSION:gsub("Lua ", "")
|
||||
|
@ -69,17 +69,17 @@ describe("LuaRocks config tests #integration", function()
|
|||
end
|
||||
assert.are.same(lua_version, output)
|
||||
end)
|
||||
|
||||
|
||||
it("--rock-trees lists rock trees", function()
|
||||
assert.is_true(run.luarocks_bool("config --rock-trees"))
|
||||
end)
|
||||
|
||||
|
||||
describe("--user-config", function()
|
||||
it("returns user config dir", function()
|
||||
local user_config_path = run.luarocks("config --user-config")
|
||||
assert.is.truthy(lfs.attributes(user_config_path))
|
||||
end)
|
||||
|
||||
|
||||
it("handles a missing user config", function()
|
||||
local output = run.luarocks("config --user-config", {LUAROCKS_CONFIG = "missing_file.lua"})
|
||||
assert.match("Warning", output)
|
||||
|
@ -89,7 +89,7 @@ describe("LuaRocks config tests #integration", function()
|
|||
describe("--system-config", function()
|
||||
local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks"
|
||||
local configfile = scdir .. "/config-" .. env_variables.LUA_VERSION .. ".lua"
|
||||
|
||||
|
||||
it("fails if system config doesn't exist", function()
|
||||
os.rename(configfile, configfile .. ".bak")
|
||||
finally(function()
|
||||
|
@ -97,28 +97,28 @@ describe("LuaRocks config tests #integration", function()
|
|||
end)
|
||||
assert.is_false(run.luarocks_bool("config --system-config"))
|
||||
end)
|
||||
|
||||
|
||||
it("outputs the path of the system config", function()
|
||||
lfs.mkdir(testing_paths.testing_lrprefix)
|
||||
lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/")
|
||||
lfs.mkdir(scdir)
|
||||
|
||||
|
||||
local sysconfig = io.open(configfile, "w+")
|
||||
sysconfig:write(" ")
|
||||
sysconfig:close()
|
||||
finally(function()
|
||||
os.remove(configfile)
|
||||
end)
|
||||
|
||||
|
||||
local output = run.luarocks("config --system-config")
|
||||
assert.are.same(configfile, output)
|
||||
end)
|
||||
|
||||
|
||||
it("fails if system config is invalid", function()
|
||||
lfs.mkdir(testing_paths.testing_lrprefix)
|
||||
lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/")
|
||||
lfs.mkdir(scdir)
|
||||
|
||||
|
||||
local sysconfig = io.open(configfile, "w+")
|
||||
sysconfig:write("if if if")
|
||||
sysconfig:close()
|
||||
|
@ -176,7 +176,7 @@ describe("LuaRocks config tests #integration", function()
|
|||
local myproject = tmpdir .. "/myproject"
|
||||
lfs.mkdir(myproject)
|
||||
lfs.chdir(myproject)
|
||||
|
||||
|
||||
assert(run.luarocks("init"))
|
||||
assert.truthy(run.luarocks_bool("config my_var my_value"))
|
||||
|
||||
|
@ -206,7 +206,7 @@ describe("LuaRocks config tests #integration", function()
|
|||
local myproject = tmpdir .. "/myproject"
|
||||
lfs.mkdir(myproject)
|
||||
lfs.chdir(myproject)
|
||||
|
||||
|
||||
assert(run.luarocks("init"))
|
||||
assert.truthy(run.luarocks_bool("config web_browser foo --scope=project"))
|
||||
|
||||
|
@ -220,7 +220,7 @@ describe("LuaRocks config tests #integration", function()
|
|||
local myproject = tmpdir .. "/myproject"
|
||||
lfs.mkdir(myproject)
|
||||
lfs.chdir(myproject)
|
||||
|
||||
|
||||
assert(run.luarocks("init"))
|
||||
assert.truthy(run.luarocks_bool("config variables.FOO_DIR /foo/bar --scope=project"))
|
||||
|
||||
|
@ -234,7 +234,7 @@ describe("LuaRocks config tests #integration", function()
|
|||
local myproject = tmpdir .. "/myproject"
|
||||
lfs.mkdir(myproject)
|
||||
lfs.chdir(myproject)
|
||||
|
||||
|
||||
assert(run.luarocks("init"))
|
||||
assert.truthy(run.luarocks_bool("config external_deps_patterns.lib[1] testtest --scope=project"))
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ describe("LuaRocks deps-mode #integration", function()
|
|||
it("one", function()
|
||||
assert.is_true(run.luarocks_bool("build --tree=system lpeg"))
|
||||
assert.is_true(run.luarocks_bool("build --deps-mode=one --tree=" .. testing_paths.testing_tree .. " lxsh"))
|
||||
|
||||
|
||||
assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
|
||||
assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec"))
|
||||
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()
|
|||
assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
|
||||
assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
|
||||
end)
|
||||
|
||||
|
||||
it("make order sys", function()
|
||||
assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg"))
|
||||
assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6"))
|
||||
|
|
|
@ -7,17 +7,17 @@ local dir = require("luarocks.dir")
|
|||
|
||||
describe("luarocks.dir #unit", function()
|
||||
local runner
|
||||
|
||||
|
||||
setup(function()
|
||||
runner = require("luacov.runner")
|
||||
runner.init(testing_paths.testrun_dir .. "/luacov.config")
|
||||
runner.tick = true
|
||||
end)
|
||||
|
||||
|
||||
teardown(function()
|
||||
runner.shutdown()
|
||||
end)
|
||||
|
||||
|
||||
describe("dir.is_basic_protocol", function()
|
||||
it("checks whether the arguments represent a valid protocol and returns the result of the check", function()
|
||||
assert.truthy(dir.is_basic_protocol("http"))
|
||||
|
|
|
@ -6,7 +6,7 @@ test_env.unload_luarocks()
|
|||
|
||||
describe("luarocks doc #integration", function()
|
||||
before_each(function()
|
||||
test_env.setup_specs(extra_rocks)
|
||||
test_env.setup_specs()
|
||||
end)
|
||||
|
||||
describe("basic tests", function()
|
||||
|
@ -74,7 +74,7 @@ describe("luarocks doc #integration", function()
|
|||
assert.match("a_rock 2.0", run.luarocks("doc a_user/a_rock"))
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("tests with flags", function()
|
||||
it("of installed package", function()
|
||||
test_env.run_in_tmp(function(tmpdir)
|
||||
|
@ -127,12 +127,12 @@ describe("luarocks doc #integration", function()
|
|||
assert.is.truthy(output:find("doc2%.md"))
|
||||
end, finally)
|
||||
end)
|
||||
|
||||
|
||||
it("with --local", function()
|
||||
assert.is_true(run.luarocks_bool("install --server=" .. testing_paths.fixtures_dir .. "/a_repo a_rock"))
|
||||
assert.is_true(run.luarocks_bool("doc --server=" .. testing_paths.fixtures_dir .. "/a_repo a_rock --local"))
|
||||
end)
|
||||
|
||||
|
||||
it("with --porcelain", function()
|
||||
test_env.run_in_tmp(function(tmpdir)
|
||||
test_env.write_file("test-1.0-1.rockspec", [[
|
||||
|
|
|
@ -28,7 +28,7 @@ describe("luarocks download #integration", function()
|
|||
assert.is.truthy(lfs.attributes("validate-args-1.5.4-1.rockspec"))
|
||||
test_env.remove_files(lfs.currentdir(), "validate--args--")
|
||||
end)
|
||||
|
||||
|
||||
it("rockspec version", function()
|
||||
assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1"))
|
||||
assert.is.truthy(lfs.attributes("validate-args-1.5.4-1.rockspec"))
|
||||
|
|
|
@ -17,9 +17,9 @@ describe("luarocks fetch #unit #mock", function()
|
|||
local are_same_files = function(file1, file2)
|
||||
return file1 == file2 or lfs.attributes(file1).ino == lfs.attributes(file2).ino
|
||||
end
|
||||
|
||||
|
||||
local runner
|
||||
|
||||
|
||||
setup(function()
|
||||
cfg.init()
|
||||
fs.init()
|
||||
|
@ -29,15 +29,15 @@ describe("luarocks fetch #unit #mock", function()
|
|||
runner.init(testing_paths.testrun_dir .. "/luacov.config")
|
||||
runner.tick = true
|
||||
end)
|
||||
|
||||
|
||||
teardown(function()
|
||||
test_env.mock_server_done()
|
||||
|
||||
runner.shutdown()
|
||||
end)
|
||||
|
||||
|
||||
describe("fetch.fetch_url", function()
|
||||
|
||||
|
||||
it("fetches the url argument and returns the absolute path of the fetched file", function()
|
||||
local fetchedfile = fetch.fetch_url("http://localhost:8080/file/a_rock.lua")
|
||||
assert.truthy(are_same_files(fetchedfile, lfs.currentdir() .. "/a_rock.lua"))
|
||||
|
@ -50,25 +50,25 @@ describe("luarocks fetch #unit #mock", function()
|
|||
assert.same(fetchedcontent, filecontent)
|
||||
os.remove(fetchedfile)
|
||||
end)
|
||||
|
||||
|
||||
it("returns the absolute path of the filename argument if the url represents a file", function()
|
||||
local file = fetch.fetch_url("file://a_rock.lua")
|
||||
assert.truthy(are_same_files(file, lfs.currentdir() .. "/a_rock.lua"))
|
||||
end)
|
||||
|
||||
|
||||
it("returns false and does nothing if the url argument contains a nonexistent file", function()
|
||||
assert.falsy(fetch.fetch_url("http://localhost:8080/file/nonexistent"))
|
||||
end)
|
||||
|
||||
|
||||
it("returns false and does nothing if the url argument is invalid", function()
|
||||
assert.falsy(fetch.fetch_url("invalid://url", "file"))
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("fetch.fetch_url_at_temp_dir", function()
|
||||
local tmpfile
|
||||
local tmpdir
|
||||
|
||||
|
||||
after_each(function()
|
||||
if tmpfile then
|
||||
os.remove(tmpfile)
|
||||
|
@ -89,7 +89,7 @@ describe("luarocks fetch #unit #mock", function()
|
|||
assert.truthy(are_same_files(tmpfile, pathname))
|
||||
assert.truthy(are_same_files(tmpdir, dirname))
|
||||
end)
|
||||
|
||||
|
||||
it("returns true and fetches the url into a temporary dir", function()
|
||||
local fetchedfile, tmpdir = fetch.fetch_url_at_temp_dir("http://localhost:8080/file/a_rock.lua", "test")
|
||||
assert.truthy(are_same_files(fetchedfile, tmpdir .. "/a_rock.lua"))
|
||||
|
@ -101,7 +101,7 @@ describe("luarocks fetch #unit #mock", function()
|
|||
fd:close()
|
||||
assert.same(fetchedcontent, filecontent)
|
||||
end)
|
||||
|
||||
|
||||
it("returns true and fetches the url into a temporary dir with custom filename", function()
|
||||
local fetchedfile, tmpdir = fetch.fetch_url_at_temp_dir("http://localhost:8080/file/a_rock.lua", "test", "my_a_rock.lua")
|
||||
assert.truthy(are_same_files(fetchedfile, tmpdir .. "/my_a_rock.lua"))
|
||||
|
@ -114,12 +114,12 @@ describe("luarocks fetch #unit #mock", function()
|
|||
fd:close()
|
||||
assert.same(fetchedcontent, filecontent)
|
||||
end)
|
||||
|
||||
|
||||
it("returns false and does nothing if the file specified in the url is nonexistent", function()
|
||||
assert.falsy(fetch.fetch_url_at_temp_dir("file://nonexistent", "test"))
|
||||
assert.falsy(fetch.fetch_url_at_temp_dir("http://localhost:8080/file/nonexistent", "test"))
|
||||
end)
|
||||
|
||||
|
||||
it("returns false and does nothing if the url is invalid", function()
|
||||
assert.falsy(fetch.fetch_url_at_temp_dir("url://invalid", "test"))
|
||||
end)
|
||||
|
@ -133,7 +133,7 @@ describe("luarocks fetch #unit #mock", function()
|
|||
assert.truthy(are_same_files(inferreddir, founddir))
|
||||
assert.truthy(lfs.attributes(tmpdir .. "/" .. founddir))
|
||||
end)
|
||||
|
||||
|
||||
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()
|
||||
local url = "http://localhost:8080/file/an_upstream_tarball-0.1.tar.gz"
|
||||
local file, tmpdir = assert(fetch.fetch_url_at_temp_dir(url, "test"))
|
||||
|
@ -142,29 +142,29 @@ describe("luarocks fetch #unit #mock", function()
|
|||
assert.truthy(are_same_files(founddir, "an_upstream_tarball-0.1"))
|
||||
assert.truthy(lfs.attributes(tmpdir .. "/" .. founddir))
|
||||
end)
|
||||
|
||||
|
||||
it("returns false and does nothing if the temporary directory doesn't exist", function()
|
||||
assert.falsy(fetch.find_base_dir("file", "nonexistent", "url"))
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("fetch.fetch_and_unpack_rock", function()
|
||||
local tmpdir
|
||||
|
||||
|
||||
after_each(function()
|
||||
if tmpdir then
|
||||
lfs.rmdir(tmpdir)
|
||||
tmpdir = nil
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
it("unpacks the rock file from the url and returns its resulting temporary parent directory", function()
|
||||
tmpdir = fetch.fetch_and_unpack_rock("http://localhost:8080/file/a_rock-1.0-1.src.rock")
|
||||
assert.truthy(string.find(tmpdir, "a_rock%-1%.0%-1"))
|
||||
assert.truthy(lfs.attributes(tmpdir .. "/a_rock-1.0-1.rockspec"))
|
||||
assert.truthy(lfs.attributes(tmpdir .. "/a_rock.lua"))
|
||||
end)
|
||||
|
||||
|
||||
it("unpacks the rock file from the url with custom unpacking directory", function()
|
||||
tmpdir = get_tmp_path()
|
||||
lfs.mkdir(tmpdir)
|
||||
|
@ -173,15 +173,15 @@ describe("luarocks fetch #unit #mock", function()
|
|||
assert.truthy(lfs.attributes(resultingdir .. "/a_rock-1.0-1.rockspec"))
|
||||
assert.truthy(lfs.attributes(resultingdir .. "/a_rock.lua"))
|
||||
end)
|
||||
|
||||
|
||||
it("does nothing if the url doesn't represent a rock file", function()
|
||||
assert.falsy(pcall(fetch.fetch_and_unpack_rock, "http://localhost:8080/file/a_rock.lua"))
|
||||
end)
|
||||
|
||||
|
||||
it("does nothing if the rock file url is invalid", function()
|
||||
assert.falsy(pcall(fetch.fetch_and_unpack_rock, "url://invalid"))
|
||||
end)
|
||||
|
||||
|
||||
it("does nothing if the rock file url represents a nonexistent file", function()
|
||||
assert.falsy(pcall(fetch.fetch_and_unpack_rock, "url://invalid"))
|
||||
assert.falsy(pcall(fetch.fetch_and_unpack_rock, "http://localhost:8080/file/nonexistent"))
|
||||
|
@ -191,7 +191,7 @@ describe("luarocks fetch #unit #mock", function()
|
|||
describe("fetch.load_local_rockspec", function()
|
||||
local tmpdir
|
||||
local olddir
|
||||
|
||||
|
||||
before_each(function()
|
||||
tmpdir = get_tmp_path()
|
||||
olddir = lfs.currentdir()
|
||||
|
@ -199,7 +199,7 @@ describe("luarocks fetch #unit #mock", function()
|
|||
lfs.chdir(tmpdir)
|
||||
fs.change_dir(tmpdir)
|
||||
end)
|
||||
|
||||
|
||||
after_each(function()
|
||||
if olddir then
|
||||
lfs.chdir(olddir)
|
||||
|
@ -208,14 +208,14 @@ describe("luarocks fetch #unit #mock", function()
|
|||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
it("returns a table representing the rockspec from the given file skipping some checks if the quick argument is enabled", function()
|
||||
local rockspec = fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec", true)
|
||||
assert.same(rockspec.name, "a_rock")
|
||||
assert.same(rockspec.version, "1.0-1")
|
||||
assert.same(rockspec.source.url, "http://localhost:8080/file/a_rock.lua")
|
||||
assert.same(rockspec.description, { summary = "An example rockspec" })
|
||||
|
||||
|
||||
write_file("missing_mandatory_field-1.0-1.rockspec", [[
|
||||
package="missing_mandatory_field"
|
||||
version="1.0-1"
|
||||
|
@ -227,7 +227,7 @@ describe("luarocks fetch #unit #mock", function()
|
|||
assert.same(rockspec.name, "missing_mandatory_field")
|
||||
assert.same(rockspec.version, "1.0-1")
|
||||
assert.same(rockspec.source.url, "http://example.com/foo.tar.gz")
|
||||
|
||||
|
||||
write_file("unknown_field-1.0-1.rockspec", [[
|
||||
package="unknown_field"
|
||||
version="1.0-1"
|
||||
|
@ -246,7 +246,7 @@ describe("luarocks fetch #unit #mock", function()
|
|||
assert.falsy(fetch.load_local_rockspec("missing_mandatory_field-1.0-1.rockspec"))
|
||||
assert.falsy(fetch.load_local_rockspec("unknown_field-1.0-1.rockspec"))
|
||||
end)
|
||||
|
||||
|
||||
it("returns a table representing the rockspec from the given file", function()
|
||||
path.use_tree(testing_paths.testing_tree)
|
||||
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()
|
|||
assert.same(rockspec.description, { summary = "An example rockspec" })
|
||||
assert.same(rockspec.source.url, "http://localhost:8080/file/a_rock.lua")
|
||||
end)
|
||||
|
||||
|
||||
it("returns false if the rockspec in invalid", function()
|
||||
assert.falsy(fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/invalid_validate-args-1.5.4-1.rockspec"))
|
||||
end)
|
||||
|
||||
|
||||
it("returns false if the rockspec version is not supported", function()
|
||||
assert.falsy(fetch.load_local_rockspec("invalid_version.rockspec"))
|
||||
end)
|
||||
|
||||
|
||||
it("returns false if the rockspec doesn't pass the type checking", function()
|
||||
write_file("type_mismatch_string-1.0-1.rockspec", [[
|
||||
package="type_mismatch_version"
|
||||
|
@ -271,7 +271,7 @@ describe("luarocks fetch #unit #mock", function()
|
|||
]], finally)
|
||||
assert.falsy(fetch.load_local_rockspec("type_mismatch_string-1.0-1.rockspec"))
|
||||
end)
|
||||
|
||||
|
||||
it("returns false if the rockspec file name is not right", function()
|
||||
write_file("invalid_rockspec_name.rockspec", [[
|
||||
package="invalid_rockspec_name"
|
||||
|
@ -280,12 +280,12 @@ describe("luarocks fetch #unit #mock", function()
|
|||
url = "http://example.com/foo.tar.gz"
|
||||
}
|
||||
build = {
|
||||
|
||||
|
||||
}
|
||||
]], finally)
|
||||
assert.falsy(fetch.load_local_rockspec("invalid_rockspec_name.rockspec"))
|
||||
end)
|
||||
|
||||
|
||||
it("returns false if the version in the rockspec file name doesn't match the version declared in the rockspec", function()
|
||||
write_file("inconsistent_versions-1.0-1.rockspec", [[
|
||||
package="inconsistent_versions"
|
||||
|
@ -294,13 +294,13 @@ describe("luarocks fetch #unit #mock", function()
|
|||
url = "http://example.com/foo.tar.gz"
|
||||
}
|
||||
build = {
|
||||
|
||||
|
||||
}
|
||||
]], finally)
|
||||
assert.falsy(fetch.load_local_rockspec("inconsistent_versions-1.0-1.rockspec"))
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("fetch.load_rockspec", function()
|
||||
it("returns a table containing the requested rockspec by downloading it into a temporary directory", function()
|
||||
path.use_tree(testing_paths.testing_tree)
|
||||
|
@ -315,11 +315,11 @@ describe("luarocks fetch #unit #mock", function()
|
|||
assert.same(rockspec.description, { summary = "An example rockspec" })
|
||||
assert.same(rockspec.source.url, "http://localhost:8080/file/a_rock.lua")
|
||||
end)
|
||||
|
||||
|
||||
it("returns a table containing the requested rockspec by downloading it into a given directory", function()
|
||||
local tmpdir = get_tmp_path()
|
||||
lfs.mkdir(tmpdir)
|
||||
|
||||
|
||||
path.use_tree(testing_paths.testing_tree)
|
||||
local rockspec = fetch.load_rockspec("http://localhost:8080/file/a_rock-1.0-1.rockspec", tmpdir)
|
||||
assert.same(rockspec.name, "a_rock")
|
||||
|
@ -327,23 +327,23 @@ describe("luarocks fetch #unit #mock", function()
|
|||
assert.same(rockspec.description, { summary = "An example rockspec" })
|
||||
assert.same(rockspec.source.url, "http://localhost:8080/file/a_rock.lua")
|
||||
assert.truthy(lfs.attributes(tmpdir .. "/a_rock-1.0-1.rockspec"))
|
||||
|
||||
|
||||
lfs.rmdir(tmpdir)
|
||||
end)
|
||||
|
||||
|
||||
it("returns false if the given download directory doesn't exist", function()
|
||||
assert.falsy(fetch.load_rockspec("http://localhost:8080/file/a_rock-1.0-1.rockspec", "nonexistent"))
|
||||
end)
|
||||
|
||||
|
||||
it("returns false if the given filename is not a valid rockspec name", function()
|
||||
assert.falsy(fetch.load_rockspec("http://localhost:8080/file/a_rock.lua"))
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("fetch.get_sources", function()
|
||||
local tmpdir
|
||||
local olddir
|
||||
|
||||
|
||||
before_each(function()
|
||||
tmpdir = get_tmp_path()
|
||||
olddir = lfs.currentdir()
|
||||
|
@ -351,7 +351,7 @@ describe("luarocks fetch #unit #mock", function()
|
|||
lfs.chdir(tmpdir)
|
||||
fs.change_dir(tmpdir)
|
||||
end)
|
||||
|
||||
|
||||
after_each(function()
|
||||
if olddir then
|
||||
lfs.chdir(olddir)
|
||||
|
@ -360,13 +360,13 @@ describe("luarocks fetch #unit #mock", function()
|
|||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
it("downloads the sources for building a rock and returns the resulting source filename and its parent directory", function()
|
||||
local rockspec = assert(fetch.load_rockspec("http://localhost:8080/file/a_rock-1.0-1.rockspec"))
|
||||
local file, dir = fetch.get_sources(rockspec, false)
|
||||
assert.truthy(are_same_files(dir .. "/a_rock.lua", file))
|
||||
end)
|
||||
|
||||
|
||||
it("downloads the sources for building a rock into a given directory and returns the resulting source filename and its parent directory", function()
|
||||
local tmpdir = get_tmp_path()
|
||||
lfs.mkdir(tmpdir)
|
||||
|
@ -376,7 +376,7 @@ describe("luarocks fetch #unit #mock", function()
|
|||
assert.truthy(are_same_files(dir .. "/a_rock.lua", file))
|
||||
lfs.rmdir(tmpdir)
|
||||
end)
|
||||
|
||||
|
||||
it("downloads the sources for building a rock, extracts the downloaded tarball and returns the resulting source filename and its parent directory", function()
|
||||
local rockspec = assert(fetch.load_rockspec("http://localhost:8080/file/busted_project-0.1-1.rockspec"))
|
||||
local file, dir = fetch.get_sources(rockspec, true)
|
||||
|
@ -385,12 +385,12 @@ describe("luarocks fetch #unit #mock", function()
|
|||
assert.truthy(lfs.attributes(dir .. "/busted_project/sum.lua"))
|
||||
assert.truthy(lfs.attributes(dir .. "/busted_project/spec/sum_spec.lua"))
|
||||
end)
|
||||
|
||||
|
||||
it("returns false and does nothing if the destination directory doesn't exist", function()
|
||||
local rockspec = assert(fetch.load_rockspec("http://localhost:8080/file/a_rock-1.0-1.rockspec"))
|
||||
assert.falsy(fetch.get_sources(rockspec, false, "nonexistent"))
|
||||
end)
|
||||
|
||||
|
||||
it("returns false and does nothing if the rockspec source url is invalid", function()
|
||||
write_file("invalid_url-1.0-1.rockspec", [[
|
||||
package="invalid_url"
|
||||
|
@ -399,13 +399,13 @@ describe("luarocks fetch #unit #mock", function()
|
|||
url = "http://localhost:8080/file/nonexistent"
|
||||
}
|
||||
build = {
|
||||
|
||||
|
||||
}
|
||||
]], finally)
|
||||
local rockspec = assert(fetch.load_rockspec("invalid_url-1.0-1.rockspec"))
|
||||
assert.falsy(fetch.get_sources(rockspec, false))
|
||||
end)
|
||||
|
||||
|
||||
it("returns false and does nothing if the downloaded rockspec has an invalid md5 checksum", function()
|
||||
write_file("invalid_checksum-1.0-1.rockspec", [[
|
||||
package="invalid_checksum"
|
||||
|
@ -415,7 +415,7 @@ describe("luarocks fetch #unit #mock", function()
|
|||
md5 = "invalid"
|
||||
}
|
||||
build = {
|
||||
|
||||
|
||||
}
|
||||
]], finally)
|
||||
local rockspec = assert(fetch.load_rockspec("invalid_checksum-1.0-1.rockspec"))
|
||||
|
@ -429,7 +429,7 @@ describe("luarocks fetch #unit #mock", function()
|
|||
setup(function()
|
||||
git = git_repo.start()
|
||||
end)
|
||||
|
||||
|
||||
teardown(function()
|
||||
if git then
|
||||
git:stop()
|
||||
|
|
142
spec/fs_spec.lua
142
spec/fs_spec.lua
|
@ -62,7 +62,7 @@ describe("luarocks.fs #unit", function()
|
|||
end
|
||||
|
||||
local runner
|
||||
|
||||
|
||||
setup(function()
|
||||
cfg.init()
|
||||
fs.init()
|
||||
|
@ -70,7 +70,7 @@ describe("luarocks.fs #unit", function()
|
|||
runner.init(testing_paths.testrun_dir .. "/luacov.config")
|
||||
runner.tick = true
|
||||
end)
|
||||
|
||||
|
||||
teardown(function()
|
||||
runner.shutdown()
|
||||
end)
|
||||
|
@ -122,10 +122,10 @@ describe("luarocks.fs #unit", function()
|
|||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("fs.execute_string", function()
|
||||
local tmpdir
|
||||
|
||||
|
||||
after_each(function()
|
||||
if tmpdir then
|
||||
lfs.rmdir(tmpdir)
|
||||
|
@ -140,7 +140,7 @@ describe("luarocks.fs #unit", function()
|
|||
assert.falsy(fs.execute_string("invalidcommand"))
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("fs.dir_iterator", function()
|
||||
local tmpfile1
|
||||
local tmpfile2
|
||||
|
@ -218,7 +218,7 @@ describe("luarocks.fs #unit", function()
|
|||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("fs.is_writable", function()
|
||||
local tmpfile
|
||||
local tmpdir
|
||||
|
@ -268,7 +268,7 @@ describe("luarocks.fs #unit", function()
|
|||
assert.falsy(fs.is_writable("/nonexistent"))
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("fs.set_time #unix", function()
|
||||
local tmpfile
|
||||
local tmpdir
|
||||
|
@ -787,13 +787,13 @@ describe("luarocks.fs #unit", function()
|
|||
assert.truthy(exists_file(tmpdir))
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("fs.list_dir", function()
|
||||
local intfile1
|
||||
local intfile2
|
||||
local intdir
|
||||
local tmpdir
|
||||
|
||||
|
||||
before_each(function()
|
||||
if intfile1 then
|
||||
os.remove(intfile1)
|
||||
|
@ -812,7 +812,7 @@ describe("luarocks.fs #unit", function()
|
|||
tmpdir = nil
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
it("returns a table with the contents of the given directory", function()
|
||||
tmpdir = get_tmp_path()
|
||||
lfs.mkdir(tmpdir)
|
||||
|
@ -828,18 +828,18 @@ describe("luarocks.fs #unit", function()
|
|||
assert.truthy(result[2] == "intfile1" or result[2] == "intdir")
|
||||
assert.is_not.same(result[1], result[2])
|
||||
end)
|
||||
|
||||
|
||||
it("returns an empty table if the argument is a file", function()
|
||||
intfile1 = get_tmp_path()
|
||||
create_file(intfile1)
|
||||
local result = fs.list_dir(intfile1)
|
||||
assert.same(#result, 0)
|
||||
end)
|
||||
|
||||
|
||||
it("does nothing if the argument is nonexistent", function()
|
||||
assert.same(fs.list_dir("/nonexistent"), {})
|
||||
end)
|
||||
|
||||
|
||||
it("does nothing if the argument doesn't have the proper permissions", function()
|
||||
tmpdir = get_tmp_path()
|
||||
lfs.mkdir(tmpdir)
|
||||
|
@ -1017,13 +1017,13 @@ describe("luarocks.fs #unit", function()
|
|||
assert.falsy(exists_file(dstdir .. "/internalfile"))
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("fs.find", function()
|
||||
local tmpdir
|
||||
local intdir
|
||||
local intfile1
|
||||
local intfile2
|
||||
|
||||
|
||||
after_each(function()
|
||||
if intfile1 then
|
||||
os.remove(intfile1)
|
||||
|
@ -1042,7 +1042,7 @@ describe("luarocks.fs #unit", function()
|
|||
tmpdir = nil
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
local create_dir_tree = function()
|
||||
tmpdir = get_tmp_path()
|
||||
lfs.mkdir(tmpdir)
|
||||
|
@ -1053,7 +1053,7 @@ describe("luarocks.fs #unit", function()
|
|||
intfile2 = intdir .. "/intfile2"
|
||||
create_file(intfile2)
|
||||
end
|
||||
|
||||
|
||||
it("returns a table of all the contents in the directory given as argument", function()
|
||||
create_dir_tree()
|
||||
local contents = {}
|
||||
|
@ -1068,7 +1068,7 @@ describe("luarocks.fs #unit", function()
|
|||
assert.same(contents["intdir"], true)
|
||||
assert.same(contents["intdir/intfile2"], true)
|
||||
end)
|
||||
|
||||
|
||||
it("uses the current working directory if the argument is nil", function()
|
||||
create_dir_tree()
|
||||
local olddir = fs.current_dir()
|
||||
|
@ -1085,7 +1085,7 @@ describe("luarocks.fs #unit", function()
|
|||
assert.same(contents["intfile2"], true)
|
||||
fs.change_dir(olddir)
|
||||
end)
|
||||
|
||||
|
||||
it("returns an empty table if the argument is nonexistent", function()
|
||||
local contents = fs.find("/nonexistent")
|
||||
local count = 0
|
||||
|
@ -1094,7 +1094,7 @@ describe("luarocks.fs #unit", function()
|
|||
end
|
||||
assert.same(count, 0)
|
||||
end)
|
||||
|
||||
|
||||
it("returns an empty table if the argument is a file", function()
|
||||
intfile1 = get_tmp_path()
|
||||
create_file(intfile1)
|
||||
|
@ -1105,7 +1105,7 @@ describe("luarocks.fs #unit", function()
|
|||
end
|
||||
assert.same(count, 0)
|
||||
end)
|
||||
|
||||
|
||||
it("does nothing if the argument doesn't have the proper permissions", function()
|
||||
tmpdir = get_tmp_path()
|
||||
lfs.mkdir(tmpdir)
|
||||
|
@ -1113,12 +1113,12 @@ describe("luarocks.fs #unit", function()
|
|||
assert.same(fs.find(tmpdir), {})
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("fs.move", function()
|
||||
local srcfile
|
||||
local dstfile
|
||||
local tmpdir
|
||||
|
||||
|
||||
after_each(function()
|
||||
if srcfile then
|
||||
os.remove(srcfile)
|
||||
|
@ -1133,7 +1133,7 @@ describe("luarocks.fs #unit", function()
|
|||
tmpdir = nil
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
it("returns true and moves the source (together with its permissions) to the destination", function()
|
||||
srcfile = get_tmp_path()
|
||||
create_file(srcfile)
|
||||
|
@ -1149,7 +1149,7 @@ describe("luarocks.fs #unit", function()
|
|||
assert.same(oldperms, lfs.attributes(dstfile, "permissions"))
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
it("returns true and moves the source (with custom permissions) to the destination", function()
|
||||
srcfile = get_tmp_path()
|
||||
create_file(srcfile)
|
||||
|
@ -1161,13 +1161,13 @@ describe("luarocks.fs #unit", function()
|
|||
local dstcontents = assert(fd:read("*a"))
|
||||
assert.same(dstcontents, "foo")
|
||||
end)
|
||||
|
||||
|
||||
it("returns false and does nothing if the source doesn't exist", function()
|
||||
dstfile = get_tmp_path()
|
||||
assert.falsy(fs.move("/nonexistent", dstfile))
|
||||
assert.falsy(fs.exists(dstfile))
|
||||
end)
|
||||
|
||||
|
||||
it("returns false and does nothing if the destination already exists", function()
|
||||
srcfile = get_tmp_path()
|
||||
create_file(srcfile)
|
||||
|
@ -1179,7 +1179,7 @@ describe("luarocks.fs #unit", function()
|
|||
local dstcontents = assert(fd:read("*a"))
|
||||
assert.same(dstcontents, "bar")
|
||||
end)
|
||||
|
||||
|
||||
it("returns false and does nothing if the destination path doesn't have the proper permissions", function()
|
||||
srcfile = get_tmp_path()
|
||||
create_file(srcfile)
|
||||
|
@ -1190,17 +1190,17 @@ describe("luarocks.fs #unit", function()
|
|||
assert.falsy(fs.exists(tmpdir .. "/dstfile"))
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("fs.is_lua", function()
|
||||
local tmpfile
|
||||
|
||||
|
||||
after_each(function()
|
||||
if tmpfile then
|
||||
os.remove(tmpfile)
|
||||
tmpfile = nil
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
it("returns true if the argument is a valid lua script", function()
|
||||
tmpfile = get_tmp_path()
|
||||
create_file(tmpfile, "print(\"foo\")")
|
||||
|
@ -1212,13 +1212,13 @@ describe("luarocks.fs #unit", function()
|
|||
create_file(tmpfile, "#!/usr/bin/env lua\n\nprint(\"foo\")")
|
||||
assert.truthy(fs.is_lua(tmpfile))
|
||||
end)
|
||||
|
||||
|
||||
it("returns false if the argument is not a valid lua script", function()
|
||||
tmpfile = os.tmpname()
|
||||
create_file(tmpfile)
|
||||
assert.falsy(fs.is_lua(tmpfile))
|
||||
end)
|
||||
|
||||
|
||||
it("returns false if the argument is a valid lua script but doesn't have the proper permissions", function()
|
||||
tmpfile = get_tmp_path()
|
||||
create_file(tmpfile, "print(\"foo\")")
|
||||
|
@ -1281,15 +1281,15 @@ describe("luarocks.fs #unit", function()
|
|||
assert.falsy(exists_file(tmpdir))
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("fs.download #mock", function()
|
||||
local tmpfile
|
||||
local tmpdir
|
||||
|
||||
|
||||
setup(function()
|
||||
test_env.mock_server_init()
|
||||
end)
|
||||
|
||||
|
||||
teardown(function()
|
||||
test_env.mock_server_done()
|
||||
end)
|
||||
|
@ -1304,7 +1304,7 @@ describe("luarocks.fs #unit", function()
|
|||
tmpdir = nil
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
it("returns true and fetches the url argument into the specified filename", function()
|
||||
tmpfile = get_tmp_path()
|
||||
assert.truthy(fs.download("http://localhost:8080/file/a_rock.lua", tmpfile))
|
||||
|
@ -1316,7 +1316,7 @@ describe("luarocks.fs #unit", function()
|
|||
fd:close()
|
||||
assert.same(downloadcontent, originalcontent)
|
||||
end)
|
||||
|
||||
|
||||
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()
|
||||
tmpdir = get_tmp_path()
|
||||
lfs.mkdir(tmpdir)
|
||||
|
@ -1332,33 +1332,33 @@ describe("luarocks.fs #unit", function()
|
|||
assert.same(downloadcontent, originalcontent)
|
||||
fs.pop_dir()
|
||||
end)
|
||||
|
||||
|
||||
it("returns false and does nothing if the url argument contains a nonexistent file", function()
|
||||
tmpfile = get_tmp_path()
|
||||
assert.falsy(fs.download("http://localhost:8080/file/nonexistent", tmpfile))
|
||||
end)
|
||||
|
||||
|
||||
it("returns false and does nothing if the url argument is invalid", function()
|
||||
assert.falsy(fs.download("invalidurl"))
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("fs.zip", function()
|
||||
local tmpdir
|
||||
local olddir
|
||||
|
||||
|
||||
before_each(function()
|
||||
olddir = lfs.currentdir()
|
||||
tmpdir = get_tmp_path()
|
||||
lfs.mkdir(tmpdir)
|
||||
chdir(tmpdir)
|
||||
|
||||
|
||||
write_file("file1", "content1", finally)
|
||||
write_file("file2", "content2", finally)
|
||||
lfs.mkdir("dir")
|
||||
write_file("dir/file3", "content3", finally)
|
||||
end)
|
||||
|
||||
|
||||
after_each(function()
|
||||
if olddir then
|
||||
chdir(olddir)
|
||||
|
@ -1368,12 +1368,12 @@ describe("luarocks.fs #unit", function()
|
|||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
it("returns true and creates a zip archive of the given files", function()
|
||||
assert.truthy(fs.zip("archive.zip", "file1", "file2", "dir"))
|
||||
assert.truthy(exists_file("archive.zip"))
|
||||
end)
|
||||
|
||||
|
||||
it("returns false and does nothing if the files specified in the arguments are invalid", function()
|
||||
assert.falsy(fs.zip("archive.zip", "nonexistent"))
|
||||
assert.falsy(exists_file("nonexistent"))
|
||||
|
@ -1381,7 +1381,7 @@ describe("luarocks.fs #unit", function()
|
|||
end)
|
||||
|
||||
describe("fs.bunzip2", function()
|
||||
|
||||
|
||||
it("uncompresses a .bz2 file", function()
|
||||
local input = testing_paths.fixtures_dir .. "/abc.bz2"
|
||||
local output = os.tmpname()
|
||||
|
@ -1393,25 +1393,25 @@ describe("luarocks.fs #unit", function()
|
|||
local abc = ("a"):rep(100000)..("b"):rep(100000)..("c"):rep(100000)
|
||||
assert.same(abc, content)
|
||||
end)
|
||||
|
||||
|
||||
end)
|
||||
|
||||
|
||||
describe("fs.unzip", function()
|
||||
local tmpdir
|
||||
local olddir
|
||||
|
||||
|
||||
before_each(function()
|
||||
olddir = lfs.currentdir()
|
||||
tmpdir = get_tmp_path()
|
||||
lfs.mkdir(tmpdir)
|
||||
chdir(tmpdir)
|
||||
|
||||
|
||||
write_file("file1", "content1", finally)
|
||||
write_file("file2", "content2", finally)
|
||||
lfs.mkdir("dir")
|
||||
write_file("dir/file3", "content3", finally)
|
||||
end)
|
||||
|
||||
|
||||
after_each(function()
|
||||
if olddir then
|
||||
chdir(olddir)
|
||||
|
@ -1421,33 +1421,33 @@ describe("luarocks.fs #unit", function()
|
|||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
it("returns true and unzips the given zip archive", function()
|
||||
assert.truthy(fs.zip("archive.zip", "file1", "file2", "dir"))
|
||||
os.remove("file1")
|
||||
os.remove("file2")
|
||||
lfs.rmdir("dir")
|
||||
|
||||
|
||||
assert.truthy(fs.unzip("archive.zip"))
|
||||
assert.truthy(exists_file("file1"))
|
||||
assert.truthy(exists_file("file2"))
|
||||
assert.truthy(exists_file("dir/file3"))
|
||||
|
||||
|
||||
local fd
|
||||
|
||||
|
||||
fd = assert(io.open("file1", "r"))
|
||||
assert.same(fd:read("*a"), "content1")
|
||||
fd:close()
|
||||
|
||||
|
||||
fd = assert(io.open("file2", "r"))
|
||||
assert.same(fd:read("*a"), "content2")
|
||||
fd:close()
|
||||
|
||||
|
||||
fd = assert(io.open("dir/file3", "r"))
|
||||
assert.same(fd:read("*a"), "content3")
|
||||
fd:close()
|
||||
end)
|
||||
|
||||
|
||||
it("does nothing if the given archive is invalid", function()
|
||||
assert.falsy(fs.unzip("archive.zip"))
|
||||
end)
|
||||
|
@ -1456,14 +1456,14 @@ describe("luarocks.fs #unit", function()
|
|||
describe("fs.wrap_script", function()
|
||||
local tmpdir
|
||||
local olddir
|
||||
|
||||
|
||||
before_each(function()
|
||||
olddir = lfs.currentdir()
|
||||
tmpdir = get_tmp_path()
|
||||
lfs.mkdir(tmpdir)
|
||||
chdir(tmpdir)
|
||||
end)
|
||||
|
||||
|
||||
after_each(function()
|
||||
if olddir then
|
||||
chdir(olddir)
|
||||
|
@ -1484,20 +1484,20 @@ describe("luarocks.fs #unit", function()
|
|||
assert.same("Hello World", data)
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("fs.copy_binary", function()
|
||||
local tmpdir
|
||||
local olddir
|
||||
|
||||
|
||||
before_each(function()
|
||||
olddir = lfs.currentdir()
|
||||
tmpdir = get_tmp_path()
|
||||
lfs.mkdir(tmpdir)
|
||||
chdir(tmpdir)
|
||||
|
||||
|
||||
write_file("test.exe", "", finally)
|
||||
end)
|
||||
|
||||
|
||||
after_each(function()
|
||||
if olddir then
|
||||
chdir(olddir)
|
||||
|
@ -1506,7 +1506,7 @@ describe("luarocks.fs #unit", function()
|
|||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
it("returns true and copies the given binary file to the file specified in the dest argument", function()
|
||||
assert.truthy(fs.copy_binary("test.exe", lfs.currentdir() .. "/copy.exe"))
|
||||
assert.truthy(exists_file("copy.exe"))
|
||||
|
@ -1519,17 +1519,17 @@ describe("luarocks.fs #unit", function()
|
|||
fd:close()
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
it("returns false and does nothing if the source file is invalid", function()
|
||||
assert.falsy(fs.copy_binary("invalid.exe", "copy.exe"))
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("fs.modules", function()
|
||||
local tmpdir
|
||||
local olddir
|
||||
local oldpath
|
||||
|
||||
|
||||
before_each(function()
|
||||
olddir = lfs.currentdir()
|
||||
tmpdir = get_tmp_path()
|
||||
|
@ -1547,7 +1547,7 @@ describe("luarocks.fs #unit", function()
|
|||
oldpath = package.path
|
||||
package.path = package.path .. tmpdir .. "/?.lua;"
|
||||
end)
|
||||
|
||||
|
||||
after_each(function()
|
||||
if olddir then
|
||||
chdir(olddir)
|
||||
|
@ -1583,7 +1583,7 @@ describe("luarocks.fs #unit", function()
|
|||
end)
|
||||
|
||||
describe("#unix fs._unix_rwx_to_number", function()
|
||||
|
||||
|
||||
it("converts permissions in rwx notation to numeric ones", function()
|
||||
assert.same(tonumber("0644", 8), fs._unix_rwx_to_number("rw-r--r--"))
|
||||
assert.same(tonumber("0755", 8), fs._unix_rwx_to_number("rwxr-xr-x"))
|
||||
|
|
|
@ -6,17 +6,17 @@ local fun = require("luarocks.fun")
|
|||
|
||||
describe("luarocks.fun #unit", function()
|
||||
local runner
|
||||
|
||||
|
||||
setup(function()
|
||||
runner = require("luacov.runner")
|
||||
runner.init(testing_paths.testrun_dir .. "/luacov.config")
|
||||
runner.tick = true
|
||||
end)
|
||||
|
||||
|
||||
teardown(function()
|
||||
runner.shutdown()
|
||||
end)
|
||||
|
||||
|
||||
describe("fun.concat", function()
|
||||
it("returns the concatenation of the two tables given as arguments", function()
|
||||
local t1, t2
|
||||
|
|
|
@ -16,11 +16,11 @@ describe("luarocks help #integration", function()
|
|||
it("invalid argument", function()
|
||||
assert.is_false(run.luarocks_bool("help invalid"))
|
||||
end)
|
||||
|
||||
|
||||
it("config", function()
|
||||
assert.is_true(run.luarocks_bool("help config"))
|
||||
end)
|
||||
|
||||
|
||||
it("luarocks-admin help with no flags/arguments", function()
|
||||
assert.is_true(run.luarocks_admin_bool(test_env.quiet("help")))
|
||||
end)
|
||||
|
|
|
@ -19,7 +19,7 @@ describe("luarocks init #integration", function()
|
|||
local myproject = tmpdir .. "/myproject"
|
||||
lfs.mkdir(myproject)
|
||||
lfs.chdir(myproject)
|
||||
|
||||
|
||||
assert(run.luarocks("init"))
|
||||
if is_win then
|
||||
assert.truthy(lfs.attributes(myproject .. "/lua.bat"))
|
||||
|
@ -41,7 +41,7 @@ describe("luarocks init #integration", function()
|
|||
local myproject = tmpdir .. "/myproject"
|
||||
lfs.mkdir(myproject)
|
||||
lfs.chdir(myproject)
|
||||
|
||||
|
||||
assert(run.luarocks("init"))
|
||||
if is_win then
|
||||
assert.truthy(lfs.attributes(myproject .. "/lua.bat"))
|
||||
|
@ -74,18 +74,18 @@ describe("luarocks init #integration", function()
|
|||
end
|
||||
end, finally)
|
||||
end)
|
||||
|
||||
|
||||
it("with given arguments", function()
|
||||
test_env.run_in_tmp(function(tmpdir)
|
||||
local myproject = tmpdir .. "/myproject"
|
||||
lfs.mkdir(myproject)
|
||||
lfs.chdir(myproject)
|
||||
|
||||
|
||||
assert(run.luarocks("init customname 1.0"))
|
||||
assert.truthy(lfs.attributes(myproject .. "/customname-1.0-1.rockspec"))
|
||||
end, finally)
|
||||
end)
|
||||
|
||||
|
||||
it("with --lua-versions", function()
|
||||
test_env.run_in_tmp(function(tmpdir)
|
||||
local myproject = tmpdir .. "/myproject"
|
||||
|
@ -107,14 +107,14 @@ describe("luarocks init #integration", function()
|
|||
local myproject = tmpdir .. "/myproject"
|
||||
copy_dir(testing_paths.fixtures_dir .. "/git_repo", myproject)
|
||||
lfs.chdir(myproject)
|
||||
|
||||
|
||||
assert(run.luarocks("init"))
|
||||
local fd = assert(io.open(myproject .. "/myproject-dev-1.rockspec", "r"))
|
||||
local content = assert(fd:read("*a"))
|
||||
assert.truthy(content:find("summary = \"Test repo\""))
|
||||
assert.truthy(content:find("detailed = .+Test repo.+"))
|
||||
assert.truthy(content:find("license = \"MIT\""))
|
||||
|
||||
|
||||
fd = assert(io.open(myproject .. "/.gitignore", "r"))
|
||||
content = assert(fd:read("*a"))
|
||||
assert.truthy(content:find("/foo"))
|
||||
|
@ -155,17 +155,17 @@ describe("luarocks init #integration", function()
|
|||
|
||||
os.remove(rockspec_filename)
|
||||
os.remove("my_dependency-1.0-1.rockspec")
|
||||
|
||||
|
||||
-- re-run init
|
||||
assert(run.luarocks("init"))
|
||||
|
||||
-- file is recreated
|
||||
assert.truthy(lfs.attributes(rockspec_filename))
|
||||
|
||||
|
||||
local fd = assert(io.open(rockspec_filename, "rb"))
|
||||
local rockspec = assert(fd:read("*a"))
|
||||
fd:close()
|
||||
|
||||
|
||||
assert.no.match("my_dependency", rockspec, 1, true)
|
||||
assert.no.match("config", rockspec, 1, true)
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ describe("luarocks install #integration", function()
|
|||
|
||||
it("fails invalid patch", function()
|
||||
assert.is_false(run.luarocks_bool("install " .. testing_paths.fixtures_dir .. "/invalid_patch-0.1-1.rockspec"))
|
||||
end)
|
||||
end)
|
||||
|
||||
it("fails invalid rock", function()
|
||||
assert.is_false(run.luarocks_bool("install \"invalid.rock\" "))
|
||||
|
@ -101,7 +101,7 @@ describe("luarocks install #integration", function()
|
|||
assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/wsapi/1.6-1/doc"))
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("#namespaces", function()
|
||||
it("installs a namespaced package from the command-line", function()
|
||||
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()
|
|||
assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/sailor/blank-app/.htaccess"))
|
||||
assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/sailor/blank-app/.htaccess~"))
|
||||
end)
|
||||
|
||||
|
||||
it("only-deps of luasocket packed rock", function()
|
||||
assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket 3.0rc1-2"))
|
||||
local output = run.luarocks("install --only-deps " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock")
|
||||
|
@ -256,20 +256,20 @@ describe("luarocks install #integration", function()
|
|||
end)
|
||||
|
||||
describe("New install functionality based on pull request 552", function()
|
||||
it("break dependencies warning", function()
|
||||
it("break dependencies warning", function()
|
||||
assert.is_true(run.luarocks_bool("install say 1.2"))
|
||||
assert.is_true(run.luarocks_bool("install luassert"))
|
||||
assert.is_true(run.luarocks_bool("install say 1.0"))
|
||||
assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/say/1.2-1"))
|
||||
end)
|
||||
it("break dependencies force", function()
|
||||
it("break dependencies force", function()
|
||||
assert.is_true(run.luarocks_bool("install say 1.2"))
|
||||
assert.is_true(run.luarocks_bool("install luassert"))
|
||||
local output = run.luarocks("install --force say 1.0")
|
||||
assert.is.truthy(output:find("Checking stability of dependencies"))
|
||||
assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/say/1.2-1"))
|
||||
end)
|
||||
it("break dependencies force fast", function()
|
||||
it("break dependencies force fast", function()
|
||||
assert.is_true(run.luarocks_bool("install say 1.2"))
|
||||
assert.is_true(run.luarocks_bool("install luassert"))
|
||||
assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/say/1.2-1"))
|
||||
|
@ -337,7 +337,7 @@ describe("luarocks install #integration", function()
|
|||
setup(function()
|
||||
git = git_repo.start()
|
||||
end)
|
||||
|
||||
|
||||
teardown(function()
|
||||
if git then
|
||||
git:stop()
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
local test_env = require("spec.util.test_env")
|
||||
local run = test_env.run
|
||||
local get_tmp_path = test_env.get_tmp_path
|
||||
local testing_paths = test_env.testing_paths
|
||||
local write_file = test_env.write_file
|
||||
|
||||
test_env.unload_luarocks()
|
||||
|
@ -12,7 +11,7 @@ local extra_rocks = {
|
|||
}
|
||||
|
||||
describe("luarocks lint #integration", function()
|
||||
|
||||
|
||||
before_each(function()
|
||||
test_env.setup_specs(extra_rocks)
|
||||
end)
|
||||
|
@ -24,25 +23,25 @@ describe("luarocks lint #integration", function()
|
|||
it("invalid argument", function()
|
||||
assert.is_false(run.luarocks_bool("lint invalid"))
|
||||
end)
|
||||
|
||||
|
||||
it("OK", function()
|
||||
assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1"))
|
||||
local output = run.luarocks("lint validate-args-1.5.4-1.rockspec")
|
||||
assert.are.same(output, "")
|
||||
assert.is_true(os.remove("validate-args-1.5.4-1.rockspec"))
|
||||
end)
|
||||
|
||||
|
||||
describe("mismatch set", function()
|
||||
local tmpdir
|
||||
local olddir
|
||||
|
||||
|
||||
before_each(function()
|
||||
tmpdir = get_tmp_path()
|
||||
olddir = lfs.currentdir()
|
||||
lfs.mkdir(tmpdir)
|
||||
lfs.chdir(tmpdir)
|
||||
end)
|
||||
|
||||
|
||||
after_each(function()
|
||||
if olddir then
|
||||
lfs.chdir(olddir)
|
||||
|
@ -51,7 +50,7 @@ describe("luarocks lint #integration", function()
|
|||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
it("mismatch string", function()
|
||||
write_file("type_mismatch_string-1.0-1.rockspec", [[
|
||||
package="type_mismatch_version"
|
||||
|
@ -59,7 +58,7 @@ describe("luarocks lint #integration", function()
|
|||
]], finally)
|
||||
assert.is_false(run.luarocks_bool("lint type_mismatch_string-1.0-1.rockspec"))
|
||||
end)
|
||||
|
||||
|
||||
it("mismatch version", function()
|
||||
write_file("type_mismatch_version-1.0-1.rockspec", [[
|
||||
package="type_mismatch_version"
|
||||
|
@ -67,7 +66,7 @@ describe("luarocks lint #integration", function()
|
|||
]], finally)
|
||||
assert.is_false(run.luarocks_bool("lint type_mismatch_version-1.0-1.rockspec"))
|
||||
end)
|
||||
|
||||
|
||||
it("mismatch table", function()
|
||||
write_file("type_mismatch_table-1.0-1.rockspec", [[
|
||||
package="type_mismatch_table"
|
||||
|
@ -77,7 +76,7 @@ describe("luarocks lint #integration", function()
|
|||
]], finally)
|
||||
assert.is_false(run.luarocks_bool("lint type_mismatch_table-1.0-1.rockspec"))
|
||||
end)
|
||||
|
||||
|
||||
it("mismatch no build table", function()
|
||||
write_file("no_build_table-1.0-1.rockspec", [[
|
||||
package = "no_build_table"
|
||||
|
|
|
@ -37,7 +37,7 @@ describe("luarocks list #integration", function()
|
|||
assert.is.truthy(output:find("say"))
|
||||
assert.matches("1.0-1 < ", output, 1, true)
|
||||
end)
|
||||
|
||||
|
||||
it("invalid tree", function()
|
||||
local output = run.luarocks("--tree=/some/invalid/tree list")
|
||||
assert(output:find("Rocks installed for Lua "..test_env.lua_version.." in /some/invalid/tree", 1, true))
|
||||
|
|
|
@ -38,7 +38,7 @@ describe("luarocks make #integration", function()
|
|||
test_env.remove_dir("luasocket-3.0rc1-2")
|
||||
os.remove("luasocket-3.0rc1-2.src.rock")
|
||||
end)
|
||||
|
||||
|
||||
-- make luasocket
|
||||
assert.is_true(run.luarocks_bool("download --source luasocket 3.0rc1-2"))
|
||||
assert.is_true(run.luarocks_bool("unpack luasocket-3.0rc1-2.src.rock"))
|
||||
|
@ -85,13 +85,13 @@ describe("luarocks make #integration", function()
|
|||
assert.is_true(run.luarocks_bool("unpack lxsh-0.8.6-2.src.rock"))
|
||||
assert.is_true(lfs.chdir("lxsh-0.8.6-2/lxsh-0.8.6-1/"))
|
||||
end)
|
||||
|
||||
|
||||
-- delete downloaded and unpacked files
|
||||
after_each(function()
|
||||
assert(lfs.chdir(testing_paths.testrun_dir))
|
||||
test_env.remove_dir("lxsh-0.8.6-2")
|
||||
assert.is_true(os.remove("lxsh-0.8.6-2.src.rock"))
|
||||
end)
|
||||
end)
|
||||
|
||||
it("default rockspec", function()
|
||||
assert.is_true(run.luarocks_bool("new_version lxsh-0.8.6-2.rockspec"))
|
||||
|
@ -105,14 +105,14 @@ describe("luarocks make #integration", function()
|
|||
finally(function()
|
||||
os.remove("rockspec")
|
||||
end)
|
||||
|
||||
|
||||
test_env.copy("lxsh-0.8.6-2.rockspec", "rockspec")
|
||||
assert.is_true(run.luarocks_bool("make"))
|
||||
|
||||
assert.is_true(run.luarocks_bool("show lxsh"))
|
||||
assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
|
||||
end)
|
||||
|
||||
|
||||
it("ambiguous rockspec", function()
|
||||
assert.is.truthy(os.rename("lxsh-0.8.6-2.rockspec", "lxsh2-0.8.6-2.rockspec"))
|
||||
local output = run.luarocks("make")
|
||||
|
@ -131,7 +131,7 @@ describe("luarocks make #integration", function()
|
|||
assert.is_false(run.luarocks_bool("show lxsh"))
|
||||
assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
|
||||
end)
|
||||
|
||||
|
||||
it("pack binary rock", function()
|
||||
assert.is_true(run.luarocks_bool("make --deps-mode=none --pack-binary-rock"))
|
||||
assert.is.truthy(lfs.attributes("lxsh-0.8.6-2.all.rock"))
|
||||
|
@ -150,7 +150,7 @@ describe("luarocks make #integration", function()
|
|||
"a_rock 1.0"
|
||||
}
|
||||
build = {
|
||||
type = "builtin",
|
||||
type = "builtin",
|
||||
modules = {
|
||||
test = "test.lua"
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ describe("luarocks make #integration", function()
|
|||
"a_rock >= 0.8"
|
||||
}
|
||||
build = {
|
||||
type = "builtin",
|
||||
type = "builtin",
|
||||
modules = {
|
||||
test = "test.lua"
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ describe("luarocks make #integration", function()
|
|||
"a_rock >= 0.8"
|
||||
}
|
||||
build = {
|
||||
type = "builtin",
|
||||
type = "builtin",
|
||||
modules = {
|
||||
test = "test.lua"
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ describe("luarocks make #integration", function()
|
|||
local deploy_lib_dir = testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION
|
||||
local deploy_lua_dir = testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION
|
||||
local so = test_env.lib_extension
|
||||
|
||||
|
||||
before_each(function()
|
||||
test_env.copy_dir(testing_paths.fixtures_dir .. "/double_deploy_type", "ddt")
|
||||
end)
|
||||
|
@ -279,7 +279,7 @@ describe("luarocks make #integration", function()
|
|||
assert.is.falsy(lfs.attributes(deploy_lib_dir.."/ddt."..so.."~"))
|
||||
assert.is.falsy(lfs.attributes(deploy_lua_dir.."/ddt.lua~"))
|
||||
assert.is.falsy(lfs.attributes(deploy_lua_dir.."/ddt_file~"))
|
||||
|
||||
|
||||
assert.is_true(run.luarocks_bool("make ddt/double_deploy_type-0.2.0-1.rockspec"))
|
||||
assert.is.truthy(lfs.attributes(deploy_lib_dir.."/ddt."..so))
|
||||
assert.is.truthy(lfs.attributes(deploy_lua_dir.."/ddt.lua"))
|
||||
|
|
|
@ -15,7 +15,7 @@ describe("luarocks new_version #integration", function()
|
|||
setup(function()
|
||||
test_env.setup_specs(extra_rocks)
|
||||
end)
|
||||
|
||||
|
||||
describe("basic tests", function()
|
||||
it("with no flags/arguments", function()
|
||||
finally(function()
|
||||
|
@ -26,7 +26,7 @@ describe("luarocks new_version #integration", function()
|
|||
assert(lfs.chdir("empty"))
|
||||
assert.is_false(run.luarocks_bool("new_version"))
|
||||
end)
|
||||
|
||||
|
||||
it("with invalid", function()
|
||||
assert.is_false(run.luarocks_bool("new_version invalid"))
|
||||
end)
|
||||
|
@ -53,7 +53,7 @@ describe("luarocks new_version #integration", function()
|
|||
assert.is.truthy(lfs.attributes("abelhas-1.2-1.rockspec"))
|
||||
test_env.remove_files(lfs.currentdir(), "abelhas%-")
|
||||
end)
|
||||
|
||||
|
||||
it("of luacov with tag", function()
|
||||
assert.is_true(run.luarocks_bool("download --rockspec luacov 0.13.0"))
|
||||
assert.is_true(run.luarocks_bool("new_version luacov-0.13.0-1.rockspec --tag v0.3"))
|
||||
|
|
|
@ -35,7 +35,7 @@ describe("luarocks pack #integration", function()
|
|||
it("not installed rock", function()
|
||||
assert.is_false(run.luarocks_bool("pack cjson"))
|
||||
end)
|
||||
|
||||
|
||||
it("not installed rock from non existing manifest", function()
|
||||
assert.is_false(run.luarocks_bool("pack /non/exist/temp.manif"))
|
||||
end)
|
||||
|
@ -66,7 +66,7 @@ describe("luarocks pack #integration", function()
|
|||
setup(function()
|
||||
test_env.mock_server_init()
|
||||
end)
|
||||
|
||||
|
||||
teardown(function()
|
||||
test_env.mock_server_done()
|
||||
end)
|
||||
|
@ -79,7 +79,7 @@ describe("luarocks pack #integration", function()
|
|||
assert(run.luarocks_bool("pack a_rock-1.0-1.rockspec"))
|
||||
assert.is_truthy(lfs.attributes("a_rock-1.0-1.src.rock"))
|
||||
end)
|
||||
|
||||
|
||||
describe("namespaced dependencies", function()
|
||||
it("can pack rockspec with namespaced dependencies", function()
|
||||
finally(function()
|
||||
|
|
|
@ -16,7 +16,7 @@ describe("luarocks path #integration", function()
|
|||
|
||||
if _VERSION:match("[23]") then
|
||||
local v = _VERSION:gsub("Lua (%d+)%.(%d+)", "%1_%2")
|
||||
|
||||
|
||||
it("with LUA_PATH_"..v, function()
|
||||
local output = run.luarocks("path", {
|
||||
["LUA_PATH_"..v] = package.path,
|
||||
|
@ -49,23 +49,23 @@ describe("luarocks path #integration", function()
|
|||
it("--lr-path", function()
|
||||
assert.is_true(run.luarocks_bool("path --lr-path"))
|
||||
end)
|
||||
|
||||
|
||||
it("--lr-cpath", function()
|
||||
assert.is_true(run.luarocks_bool("path --lr-cpath"))
|
||||
end)
|
||||
|
||||
|
||||
it("--tree", function()
|
||||
assert.is_true(run.luarocks_bool("path --tree=lua_modules"))
|
||||
end)
|
||||
|
||||
|
||||
it("--project-tree", function()
|
||||
local path1 = "/share/lua/5%." .. test_env.lua_version:sub(3, 3) .. "/%?%.lua"
|
||||
local path2 = "/share/lua/5%." .. test_env.lua_version:sub(3, 3) .. "/%?/init%.lua"
|
||||
|
||||
|
||||
local path = run.luarocks("path --project-tree=foo")
|
||||
assert.truthy(path:find("foo" .. path1))
|
||||
assert.truthy(path:find("foo" .. path2))
|
||||
|
||||
|
||||
path = run.luarocks("path --project-tree=foo --tree=bar")
|
||||
assert.falsy(path:find("foo" .. path1))
|
||||
assert.falsy(path:find("foo" .. path2))
|
||||
|
|
|
@ -6,17 +6,17 @@ local persist = require("luarocks.persist")
|
|||
|
||||
describe("luarocks.persist #unit", function()
|
||||
local runner
|
||||
|
||||
|
||||
setup(function()
|
||||
runner = require("luacov.runner")
|
||||
runner.init(testing_paths.testrun_dir .. "/luacov.config")
|
||||
runner.tick = true
|
||||
end)
|
||||
|
||||
|
||||
teardown(function()
|
||||
runner.shutdown()
|
||||
end)
|
||||
|
||||
|
||||
describe("persist.save_from_table_to_string", function()
|
||||
it("simple table", function()
|
||||
assert.are.same([[
|
||||
|
|
|
@ -26,11 +26,11 @@ describe("luarocks remove #integration", function()
|
|||
it("invalid rock", function()
|
||||
assert.is_false(run.luarocks_bool("remove invalid.rock"))
|
||||
end)
|
||||
|
||||
|
||||
it("missing rock", function()
|
||||
assert.is_false(run.luarocks_bool("remove missing_rock"))
|
||||
end)
|
||||
|
||||
|
||||
it("invalid argument", function()
|
||||
assert.is_false(run.luarocks_bool("remove luacov --deps-mode"))
|
||||
end)
|
||||
|
@ -62,7 +62,7 @@ describe("luarocks remove #integration", function()
|
|||
assert.is_false(run.luarocks_bool("remove coxpcall"))
|
||||
assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/coxpcall"))
|
||||
end)
|
||||
|
||||
|
||||
it("force", function()
|
||||
assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/coxpcall"))
|
||||
assert.is_true(run.luarocks_bool("build copas"))
|
||||
|
@ -71,7 +71,7 @@ describe("luarocks remove #integration", function()
|
|||
assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/coxpcall"))
|
||||
assert.is.truthy(output:find("Checking stability of dependencies"))
|
||||
end)
|
||||
|
||||
|
||||
it("force fast", function()
|
||||
assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/coxpcall"))
|
||||
assert.is_true(run.luarocks_bool("build copas"))
|
||||
|
@ -85,7 +85,7 @@ describe("luarocks remove #integration", function()
|
|||
it("#admin remove #ssh", function()
|
||||
assert.is_true(run.luarocks_admin_bool("--server=testing remove coxpcall-1.16.0-1.src.rock"))
|
||||
end)
|
||||
|
||||
|
||||
it("#admin remove missing", function()
|
||||
assert.is_false(run.luarocks_admin_bool("--server=testing remove"))
|
||||
end)
|
||||
|
|
|
@ -8,7 +8,7 @@ local extra_rocks = {
|
|||
}
|
||||
|
||||
describe("luarocks search #integration", function()
|
||||
|
||||
|
||||
before_each(function()
|
||||
test_env.setup_specs(extra_rocks)
|
||||
end)
|
||||
|
@ -20,15 +20,15 @@ describe("luarocks search #integration", function()
|
|||
it("zlib", function()
|
||||
assert.is_true(run.luarocks_bool("search zlib"))
|
||||
end)
|
||||
|
||||
|
||||
it("zlib 1.1", function()
|
||||
assert.is_true(run.luarocks_bool("search zlib 1.1"))
|
||||
end)
|
||||
|
||||
|
||||
it("missing rock", function()
|
||||
assert.is_true(run.luarocks_bool("search missing_rock"))
|
||||
end)
|
||||
|
||||
|
||||
it("with flag all", function()
|
||||
assert.is_true(run.luarocks_bool("search --all"))
|
||||
end)
|
||||
|
|
|
@ -5,7 +5,7 @@ local testing_paths = test_env.testing_paths
|
|||
test_env.unload_luarocks()
|
||||
|
||||
describe("luarocks show #integration", function()
|
||||
|
||||
|
||||
before_each(function()
|
||||
test_env.setup_specs()
|
||||
end)
|
||||
|
@ -13,12 +13,12 @@ describe("luarocks show #integration", function()
|
|||
it("with no flags/arguments", function()
|
||||
assert.is_false(run.luarocks_bool("show"))
|
||||
end)
|
||||
|
||||
|
||||
describe("basic tests with flags", function()
|
||||
it("invalid", function()
|
||||
assert.is_false(run.luarocks_bool("show invalid"))
|
||||
end)
|
||||
|
||||
|
||||
it("luacov", function()
|
||||
local output = run.luarocks("show luacov")
|
||||
assert.is.truthy(output:match("LuaCov"))
|
||||
|
@ -28,12 +28,12 @@ describe("luarocks show #integration", function()
|
|||
local output = run.luarocks("show LuaCov")
|
||||
assert.is.truthy(output:match("LuaCov"))
|
||||
end)
|
||||
|
||||
|
||||
it("modules of luacov", function()
|
||||
local output = run.luarocks("show --modules luacov")
|
||||
assert.match("luacov.*luacov.defaults.*luacov.reporter.*luacov.reporter.default.*luacov.runner.*luacov.stats.*luacov.tick", output)
|
||||
end)
|
||||
|
||||
|
||||
it("--deps", function()
|
||||
assert(run.luarocks_bool("build has_namespaced_dep --server=" .. testing_paths.fixtures_dir .. "/a_repo" ))
|
||||
local output = run.luarocks("show --deps has_namespaced_dep")
|
||||
|
@ -45,21 +45,21 @@ describe("luarocks show #integration", function()
|
|||
local output = run.luarocks("show has_namespaced_dep")
|
||||
assert.match("a_user/a_rock.*2.0", output)
|
||||
end)
|
||||
|
||||
|
||||
it("rockspec of luacov", function()
|
||||
local output = run.luarocks("show --rockspec luacov")
|
||||
assert.is.truthy(output:match("luacov--0.13.0--1.rockspec"))
|
||||
end)
|
||||
|
||||
|
||||
it("mversion of luacov", function()
|
||||
local output = run.luarocks("show --mversion luacov")
|
||||
assert.is.truthy(output:match("0.13.0--1"))
|
||||
end)
|
||||
|
||||
|
||||
it("rock tree of luacov", function()
|
||||
local output = run.luarocks("show --rock-tree luacov")
|
||||
end)
|
||||
|
||||
|
||||
it("rock directory of luacov", function()
|
||||
local output = run.luarocks("show --rock-dir luacov")
|
||||
end)
|
||||
|
@ -67,7 +67,7 @@ describe("luarocks show #integration", function()
|
|||
it("issues URL of luacov", function()
|
||||
local output = run.luarocks("show --issues luacov")
|
||||
end)
|
||||
|
||||
|
||||
it("labels of luacov", function()
|
||||
local output = run.luarocks("show --labels luacov")
|
||||
end)
|
||||
|
|
|
@ -8,7 +8,7 @@ describe("luarocks.core.sysdetect #unix #unit", function()
|
|||
os.execute("[ -e binary-samples ] || git clone --depth=1 https://github.com/hishamhm/binary-samples")
|
||||
os.execute("cd binary-samples && git pull")
|
||||
end)
|
||||
|
||||
|
||||
local files = {
|
||||
["."] = "ignore",
|
||||
[".."] = "ignore",
|
||||
|
@ -56,7 +56,7 @@ describe("luarocks.core.sysdetect #unix #unit", function()
|
|||
["elf-Haiku-GCC7-WebPositive"] = {"haiku", "x86"},
|
||||
["pe-cygwin-ls.exe"] = {"cygwin", "x86"},
|
||||
}
|
||||
|
||||
|
||||
describe("detect_file", function()
|
||||
it("detects system and processor", function()
|
||||
for f in lfs.dir("binary-samples") do
|
||||
|
|
|
@ -17,7 +17,7 @@ local extra_rocks = {
|
|||
"/luassert-1.8.0-0.rockspec",
|
||||
"/lua-term-0.7-1.rockspec",
|
||||
"/penlight-1.5.4-1.rockspec",
|
||||
"/mediator_lua-1.1.2-0.rockspec",
|
||||
"/mediator_lua-1.1.2-0.rockspec",
|
||||
}
|
||||
|
||||
describe("luarocks test #integration", function()
|
||||
|
@ -59,7 +59,7 @@ describe("luarocks test #integration", function()
|
|||
test_env.remove_dir("busted_project-0.1-1")
|
||||
os.remove("busted_project-0.1-1.src.rock")
|
||||
end)
|
||||
|
||||
|
||||
-- make luassert
|
||||
assert.is_true(run.luarocks_bool("download --server="..testing_paths.fixtures_repo_dir.." busted_project 0.1-1"))
|
||||
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")
|
|||
|
||||
describe("LuaRocks test #unit", function()
|
||||
local runner
|
||||
|
||||
|
||||
lazy_setup(function()
|
||||
cfg.init()
|
||||
fs.init()
|
||||
|
@ -92,14 +92,14 @@ describe("LuaRocks test #unit", function()
|
|||
runner.init(testing_paths.testrun_dir .. "/luacov.config")
|
||||
runner.tick = true
|
||||
end)
|
||||
|
||||
|
||||
lazy_teardown(function()
|
||||
runner.shutdown()
|
||||
end)
|
||||
|
||||
|
||||
local tmpdir
|
||||
local olddir
|
||||
|
||||
|
||||
local create_tmp_dir = function()
|
||||
tmpdir = get_tmp_path()
|
||||
olddir = lfs.currentdir()
|
||||
|
@ -107,7 +107,7 @@ describe("LuaRocks test #unit", function()
|
|||
lfs.chdir(tmpdir)
|
||||
fs.change_dir(tmpdir)
|
||||
end
|
||||
|
||||
|
||||
local destroy_tmp_dir = function()
|
||||
if olddir then
|
||||
lfs.chdir(olddir)
|
||||
|
@ -116,47 +116,47 @@ describe("LuaRocks test #unit", function()
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe("test.command", function()
|
||||
describe("command.detect_type", function()
|
||||
before_each(function()
|
||||
create_tmp_dir()
|
||||
end)
|
||||
|
||||
|
||||
after_each(function()
|
||||
destroy_tmp_dir()
|
||||
end)
|
||||
|
||||
|
||||
it("returns true if test.lua exists", function()
|
||||
write_file("test.lua", "", finally)
|
||||
assert.truthy(test_command.detect_type())
|
||||
end)
|
||||
|
||||
|
||||
it("returns false if test.lua doesn't exist", function()
|
||||
assert.falsy(test_command.detect_type())
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("command.run_tests", function()
|
||||
before_each(function()
|
||||
create_tmp_dir()
|
||||
end)
|
||||
|
||||
|
||||
after_each(function()
|
||||
destroy_tmp_dir()
|
||||
end)
|
||||
|
||||
|
||||
it("returns the result of the executed tests", function()
|
||||
write_file("test.lua", "assert(1==1)", finally)
|
||||
assert.truthy(test_command.run_tests(nil, {}))
|
||||
|
||||
|
||||
write_file("test.lua", "assert(1==2)", finally)
|
||||
assert.falsy(test_command.run_tests(nil, {}))
|
||||
end)
|
||||
|
||||
|
||||
it("returns the result of the executed tests with custom arguments and test command", function()
|
||||
write_file("test.lua", "assert(1==1)", finally)
|
||||
|
||||
|
||||
local test = {
|
||||
script = "test.lua",
|
||||
flags = {
|
||||
|
@ -167,76 +167,76 @@ describe("LuaRocks test #unit", function()
|
|||
}
|
||||
assert.truthy(test_command.run_tests(test, {}))
|
||||
end)
|
||||
|
||||
|
||||
it("returns false and does nothing if the test script doesn't exist", function()
|
||||
assert.falsy(test_command.run_tests(nil, {}))
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("test.busted", function()
|
||||
describe("busted.detect_type", function()
|
||||
before_each(function()
|
||||
create_tmp_dir()
|
||||
end)
|
||||
|
||||
|
||||
after_each(function()
|
||||
destroy_tmp_dir()
|
||||
end)
|
||||
|
||||
|
||||
it("returns true if .busted exists", function()
|
||||
write_file(".busted", "", finally)
|
||||
assert.truthy(test_busted.detect_type())
|
||||
end)
|
||||
|
||||
|
||||
it("returns false if .busted doesn't exist", function()
|
||||
assert.falsy(test_busted.detect_type())
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("busted.run_tests", function()
|
||||
before_each(function()
|
||||
path.use_tree(testing_paths.testing_sys_tree)
|
||||
create_tmp_dir()
|
||||
end)
|
||||
|
||||
|
||||
after_each(function()
|
||||
destroy_tmp_dir()
|
||||
end)
|
||||
|
||||
|
||||
pending("returns the result of the executed tests", function()
|
||||
-- FIXME: busted issue
|
||||
write_file("test_spec.lua", "assert(1==1)", finally)
|
||||
assert.truthy(test_busted.run_tests(nil, {}))
|
||||
|
||||
|
||||
write_file("test_spec.lua", "assert(1==2)", finally)
|
||||
assert.falsy(test_busted.run_tests())
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("test", function()
|
||||
describe("test.run_test_suite", function()
|
||||
before_each(function()
|
||||
create_tmp_dir()
|
||||
end)
|
||||
|
||||
|
||||
after_each(function()
|
||||
destroy_tmp_dir()
|
||||
end)
|
||||
|
||||
|
||||
it("returns false if the given rockspec cannot be loaded", function()
|
||||
assert.falsy(test.run_test_suite("invalid", nil, {}))
|
||||
end)
|
||||
|
||||
|
||||
it("returns false if no test type was detected", function()
|
||||
assert.falsy(test.run_test_suite({ package = "test" }, nil, {}))
|
||||
end)
|
||||
|
||||
|
||||
it("returns the result of executing the tests specified in the given rockspec", function()
|
||||
write_file("test.lua", "assert(1==1)", finally)
|
||||
assert.truthy(test.run_test_suite({ test_dependencies = {} }, nil, {}))
|
||||
|
||||
|
||||
write_file("test.lua", "assert(1==2)", finally)
|
||||
assert.falsy(test.run_test_suite({ test_dependencies = {} }, nil, {}))
|
||||
end)
|
||||
|
|
|
@ -8,7 +8,7 @@ local fs = require("luarocks.fs")
|
|||
local cfg = require("luarocks.core.cfg")
|
||||
local patch = require("luarocks.tools.patch")
|
||||
|
||||
local lao =
|
||||
local lao =
|
||||
[[The Nameless is the origin of Heaven and Earth;
|
||||
The named is the mother of all things.
|
||||
|
||||
|
@ -23,7 +23,7 @@ They both may be called deep and profound.
|
|||
Deeper and more profound,
|
||||
The door of all subtleties!]]
|
||||
|
||||
local tzu =
|
||||
local tzu =
|
||||
[[The Way that can be told of is not the eternal Way;
|
||||
The name that can be named is not the eternal name.
|
||||
The Nameless is the origin of Heaven and Earth;
|
||||
|
@ -36,7 +36,7 @@ The two are the same,
|
|||
But after they are produced,
|
||||
they have different names.]]
|
||||
|
||||
local valid_patch1 =
|
||||
local valid_patch1 =
|
||||
[[--- lao 2002-02-21 23:30:39.942229878 -0800
|
||||
+++ tzu 2002-02-21 23:30:50.442260588 -0800
|
||||
@@ -1,7 +1,6 @@
|
||||
|
@ -57,7 +57,7 @@ local valid_patch1 =
|
|||
+Deeper and more profound,
|
||||
+The door of all subtleties!]]
|
||||
|
||||
local valid_patch2 =
|
||||
local valid_patch2 =
|
||||
[[--- /dev/null 1969-02-21 23:30:39.942229878 -0800
|
||||
+++ tzu 2002-02-21 23:30:50.442260588 -0800
|
||||
@@ -1,7 +1,6 @@
|
||||
|
@ -78,7 +78,7 @@ local valid_patch2 =
|
|||
+Deeper and more profound,
|
||||
+The door of all subtleties!]]
|
||||
|
||||
local invalid_patch1 =
|
||||
local invalid_patch1 =
|
||||
[[--- lao 2002-02-21 23:30:39.942229878 -0800
|
||||
+++ tzu 2002-02-21 23:30:50.442260588 -0800
|
||||
@@ -1,7 +1,6 @@
|
||||
|
@ -101,7 +101,7 @@ local invalid_patch1 =
|
|||
+Deeper and more profound,
|
||||
+The door of all subtleties!]]
|
||||
|
||||
local invalid_patch2 =
|
||||
local invalid_patch2 =
|
||||
[[--- lao 2002-02-21 23:30:39.942229878 -0800
|
||||
+++ tzu 2002-02-21 23:30:50.442260588 -0800
|
||||
@@ -1,7 +1,6 @@
|
||||
|
@ -123,7 +123,7 @@ local invalid_patch2 =
|
|||
? ...
|
||||
+The door of all subtleties!]]
|
||||
|
||||
local invalid_patch3 =
|
||||
local invalid_patch3 =
|
||||
[[--- lao 2002-02-21 23:30:39.942229878 -0800
|
||||
+++ tzu 2002-02-21 23:30:50.442260588 -0800
|
||||
@@ -1,7 +1,6 @@
|
||||
|
@ -147,7 +147,7 @@ local invalid_patch3 =
|
|||
|
||||
describe("Luarocks patch test #unit", function()
|
||||
local runner
|
||||
|
||||
|
||||
setup(function()
|
||||
cfg.init()
|
||||
fs.init()
|
||||
|
@ -155,51 +155,51 @@ describe("Luarocks patch test #unit", function()
|
|||
runner.init(testing_paths.testrun_dir .. "/luacov.config")
|
||||
runner.tick = true
|
||||
end)
|
||||
|
||||
|
||||
teardown(function()
|
||||
runner.shutdown()
|
||||
end)
|
||||
|
||||
|
||||
describe("patch.read_patch", function()
|
||||
it("returns a table with the patch file info and the result of parsing the file", function()
|
||||
local t, result
|
||||
|
||||
|
||||
write_file("test.patch", valid_patch1, finally)
|
||||
t, result = patch.read_patch("test.patch")
|
||||
assert.truthy(result)
|
||||
assert.truthy(t)
|
||||
|
||||
|
||||
write_file("test.patch", invalid_patch1, finally)
|
||||
t, result = patch.read_patch("test.patch")
|
||||
assert.falsy(result)
|
||||
assert.truthy(t)
|
||||
|
||||
|
||||
write_file("test.patch", invalid_patch2, finally)
|
||||
t, result = patch.read_patch("test.patch")
|
||||
assert.falsy(result)
|
||||
assert.truthy(t)
|
||||
|
||||
|
||||
write_file("test.patch", invalid_patch3, finally)
|
||||
t, result = patch.read_patch("test.patch")
|
||||
assert.falsy(result)
|
||||
assert.truthy(t)
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("patch.apply_patch", function()
|
||||
local tmpdir
|
||||
local olddir
|
||||
|
||||
|
||||
before_each(function()
|
||||
tmpdir = get_tmp_path()
|
||||
olddir = lfs.currentdir()
|
||||
lfs.mkdir(tmpdir)
|
||||
lfs.chdir(tmpdir)
|
||||
|
||||
|
||||
write_file("lao", tzu, finally)
|
||||
write_file("tzu", lao, finally)
|
||||
end)
|
||||
|
||||
|
||||
after_each(function()
|
||||
if olddir then
|
||||
lfs.chdir(olddir)
|
||||
|
@ -208,44 +208,44 @@ describe("Luarocks patch test #unit", function()
|
|||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
it("applies the given patch and returns the result of patching", function()
|
||||
write_file("test.patch", valid_patch1, finally)
|
||||
local p = patch.read_patch("test.patch")
|
||||
local result = patch.apply_patch(p)
|
||||
assert.truthy(result)
|
||||
end)
|
||||
|
||||
|
||||
it("applies the given patch with custom arguments and returns the result of patching", function()
|
||||
write_file("test.patch", valid_patch2, finally)
|
||||
local p = patch.read_patch("test.patch")
|
||||
local result = patch.apply_patch(p, nil, true)
|
||||
assert.truthy(result)
|
||||
end)
|
||||
|
||||
|
||||
it("fails if the patch file is invalid", function()
|
||||
write_file("test.patch", invalid_patch1, finally)
|
||||
local p = patch.read_patch("test.patch")
|
||||
local result = pcall(patch.apply_patch, p)
|
||||
assert.falsy(result)
|
||||
end)
|
||||
|
||||
|
||||
it("returns false if the files from the patch doesn't exist", function()
|
||||
os.remove("lao")
|
||||
os.remove("tzu")
|
||||
|
||||
|
||||
write_file("test.patch", valid_patch1, finally)
|
||||
local p = patch.read_patch("test.patch")
|
||||
local result = patch.apply_patch(p)
|
||||
assert.falsy(result)
|
||||
end)
|
||||
|
||||
|
||||
it("returns false if the target file was already patched", function()
|
||||
write_file("test.patch", valid_patch1, finally)
|
||||
local p = patch.read_patch("test.patch")
|
||||
local result = patch.apply_patch(p)
|
||||
assert.truthy(result)
|
||||
|
||||
|
||||
result = patch.apply_patch(p)
|
||||
assert.falsy(result)
|
||||
end)
|
||||
|
|
|
@ -11,7 +11,7 @@ local extra_rocks = {
|
|||
}
|
||||
|
||||
describe("luarocks unpack #integration", function()
|
||||
|
||||
|
||||
before_each(function()
|
||||
test_env.setup_specs(extra_rocks)
|
||||
end)
|
||||
|
@ -20,11 +20,11 @@ describe("luarocks unpack #integration", function()
|
|||
it("with no flags/arguments", function()
|
||||
assert.is_false(run.luarocks_bool("unpack"))
|
||||
end)
|
||||
|
||||
|
||||
it("with invalid rockspec", function()
|
||||
assert.is_false(run.luarocks_bool("unpack invalid.rockspec"))
|
||||
end)
|
||||
|
||||
|
||||
it("with invalid patch", function()
|
||||
assert.is_false(run.luarocks_bool("unpack " .. testing_paths.fixtures_dir .. "/invalid_patch-0.1-1.rockspec"))
|
||||
end)
|
||||
|
@ -35,14 +35,14 @@ describe("luarocks unpack #integration", function()
|
|||
assert.is_true(run.luarocks_bool("unpack cprint"))
|
||||
test_env.remove_dir("cprint-0.1-2")
|
||||
end)
|
||||
|
||||
|
||||
it("src", function()
|
||||
assert.is_true(run.luarocks_bool("download --source cprint"))
|
||||
assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.src.rock"))
|
||||
os.remove("cprint-0.1-2.src.rock")
|
||||
test_env.remove_dir("cprint-0.1-2")
|
||||
end)
|
||||
|
||||
|
||||
it("src", function()
|
||||
assert.is_true(run.luarocks_bool("download --rockspec cprint"))
|
||||
assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.rockspec"))
|
||||
|
|
|
@ -17,15 +17,15 @@ describe("luarocks upload #integration", function()
|
|||
it("invalid rockspec", function()
|
||||
assert.is_false(run.luarocks_bool("upload invalid.rockspec"))
|
||||
end)
|
||||
|
||||
|
||||
it("api key invalid", function()
|
||||
assert.is_false(run.luarocks_bool("upload --api-key=invalid invalid.rockspec"))
|
||||
end)
|
||||
|
||||
|
||||
it("api key invalid and skip-pack", function()
|
||||
assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --skip-pack " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec"))
|
||||
end)
|
||||
|
||||
|
||||
it("force #unix", function()
|
||||
assert.is_true(test_env.need_rock("dkjson"))
|
||||
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()
|
|||
|
||||
describe("tests with Xavante server #mock", function()
|
||||
before_each(test_env.mock_server_init)
|
||||
|
||||
|
||||
after_each(test_env.mock_server_done)
|
||||
|
||||
it("rockspec with api-key", function()
|
||||
|
|
|
@ -95,4 +95,4 @@ server:add_resource("/shutdown", {
|
|||
})
|
||||
|
||||
-- This loads the restserver.xavante plugin
|
||||
server:enable("restserver.xavante"):start()
|
||||
server:enable("restserver.xavante"):start()
|
||||
|
|
|
@ -55,7 +55,7 @@ local function Q(arg)
|
|||
if arg:match("^"..drive_letter) then
|
||||
arg = arg:gsub("/", "\\")
|
||||
end
|
||||
|
||||
|
||||
if arg == "\\" then
|
||||
return '\\' -- CHDIR needs special handling for root dir
|
||||
end
|
||||
|
@ -128,10 +128,10 @@ end
|
|||
function test_env.execute_helper(command, print_command, env_variables)
|
||||
local final_command = ""
|
||||
|
||||
if print_command then
|
||||
if print_command then
|
||||
print("[EXECUTING]: " .. command)
|
||||
end
|
||||
|
||||
|
||||
local unset_variables = {
|
||||
"LUA_PATH",
|
||||
"LUA_CPATH",
|
||||
|
@ -178,7 +178,7 @@ end
|
|||
-- @return true/false boolean: status of the command execution
|
||||
local function execute_bool(command, print_command, env_variables)
|
||||
command = test_env.execute_helper(command, print_command, env_variables)
|
||||
|
||||
|
||||
local redirect_filename
|
||||
local redirect = ""
|
||||
if print_command ~= nil then
|
||||
|
@ -438,11 +438,11 @@ end
|
|||
-- @return env_variables table: table with created environment variables
|
||||
local function create_env(testing_paths)
|
||||
local luaversion_short = _VERSION:gsub("Lua ", "")
|
||||
|
||||
|
||||
if test_env.LUAJIT_V then
|
||||
luaversion_short="5.1"
|
||||
end
|
||||
|
||||
|
||||
local env_variables = {}
|
||||
env_variables.GNUPGHOME = testing_paths.gpg_dir
|
||||
env_variables.LUA_VERSION = luaversion_short
|
||||
|
@ -481,7 +481,7 @@ local function make_run_function(cmd_name, exec_function, with_coverage, do_prin
|
|||
if with_coverage then
|
||||
cmd_prefix = cmd_prefix .. "-e \"require('luacov.runner')('" .. test_env.testing_paths.testrun_dir .. "/luacov.config')\" "
|
||||
end
|
||||
|
||||
|
||||
if cmd_name then
|
||||
cmd_prefix = cmd_prefix .. test_env.testing_paths.src_dir .. "/bin/" .. cmd_name .. " "
|
||||
end
|
||||
|
@ -547,7 +547,7 @@ local function build_environment(rocks, env_variables)
|
|||
move_file(rock .. "-*.rock", testing_paths.testing_cache)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
test_env.copy_dir(testing_paths.testing_tree, testing_paths.testing_tree_copy)
|
||||
test_env.copy_dir(testing_paths.testing_sys_tree, testing_paths.testing_sys_tree_copy)
|
||||
end
|
||||
|
@ -653,7 +653,7 @@ function test_env.setup_specs(extra_rocks)
|
|||
end
|
||||
|
||||
test_env.main()
|
||||
|
||||
|
||||
-- preload before meddling with package.path
|
||||
require("spec.util.git_repo")
|
||||
|
||||
|
@ -666,8 +666,8 @@ function test_env.setup_specs(extra_rocks)
|
|||
test_env.setup_done = true
|
||||
title("RUNNING TESTS")
|
||||
end
|
||||
|
||||
if extra_rocks then
|
||||
|
||||
if extra_rocks then
|
||||
local make_manifest = download_rocks(extra_rocks, test_env.testing_paths.testing_server)
|
||||
if make_manifest then
|
||||
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)
|
|||
if test_env.RESET_ENV then
|
||||
reset_environment(test_env.testing_paths, test_env.md5sums, test_env.env_variables)
|
||||
end
|
||||
|
||||
|
||||
lfs.chdir(test_env.testing_paths.testrun_dir)
|
||||
end
|
||||
|
||||
|
@ -903,7 +903,7 @@ local function prepare_mock_server_binary_rocks()
|
|||
end
|
||||
|
||||
---
|
||||
-- Main function to create config files and testing environment
|
||||
-- Main function to create config files and testing environment
|
||||
function test_env.main()
|
||||
local testing_paths = test_env.testing_paths
|
||||
|
||||
|
@ -954,7 +954,7 @@ function test_env.main()
|
|||
local env_vars = {
|
||||
LUAROCKS_CONFIG = test_env.testing_paths.testrun_dir .. "/testing_config.lua"
|
||||
}
|
||||
|
||||
|
||||
build_environment(rocks, env_vars)
|
||||
|
||||
prepare_mock_server_binary_rocks()
|
||||
|
|
|
@ -33,7 +33,7 @@ describe("Basic tests #integration", function()
|
|||
local delete_path = lfs.currentdir()
|
||||
assert.is_true(os.remove(delete_path))
|
||||
|
||||
local output = run.luarocks("")
|
||||
local output = run.luarocks("")
|
||||
assert.is.falsy(output:find("the Lua package manager"))
|
||||
assert.is_true(lfs.chdir(main_path))
|
||||
|
||||
|
@ -44,7 +44,7 @@ describe("Basic tests #integration", function()
|
|||
it("--timeout", function()
|
||||
assert.is.truthy(run.luarocks("--timeout=10"))
|
||||
end)
|
||||
|
||||
|
||||
it("--timeout invalid", function()
|
||||
assert.is_false(run.luarocks_bool("--timeout=abc"))
|
||||
end)
|
||||
|
@ -61,17 +61,17 @@ local core_util = require("luarocks.core.util")
|
|||
|
||||
describe("luarocks.util #unit", function()
|
||||
local runner
|
||||
|
||||
|
||||
setup(function()
|
||||
runner = require("luacov.runner")
|
||||
runner.init(testing_paths.testrun_dir .. "/luacov.config")
|
||||
runner.tick = true
|
||||
end)
|
||||
|
||||
|
||||
teardown(function()
|
||||
runner.shutdown()
|
||||
end)
|
||||
|
||||
|
||||
describe("util.sortedpairs", function()
|
||||
local function collect(iter, state, var)
|
||||
local collected = {}
|
||||
|
@ -122,30 +122,30 @@ describe("luarocks.util #unit", function()
|
|||
}, {"k3", {"k2", {"sub order"}}, "k1"})))
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("core.util.show_table", function()
|
||||
it("returns a pretty-printed string containing the representation of the given table", function()
|
||||
local result
|
||||
|
||||
|
||||
local t1 = {1, 2, 3}
|
||||
result = core_util.show_table(t1)
|
||||
assert.truthy(result:find("[1] = 1", 1, true))
|
||||
assert.truthy(result:find("[2] = 2", 1, true))
|
||||
assert.truthy(result:find("[3] = 3", 1, true))
|
||||
|
||||
|
||||
local t2 = {a = 1, b = 2, c = 3}
|
||||
result = core_util.show_table(t2)
|
||||
assert.truthy(result:find("[\"a\"] = 1", 1, true))
|
||||
assert.truthy(result:find("[\"b\"] = 2", 1, true))
|
||||
assert.truthy(result:find("[\"c\"] = 3", 1, true))
|
||||
|
||||
|
||||
local t3 = {a = 1, b = "2", c = {3}}
|
||||
result = core_util.show_table(t3)
|
||||
assert.truthy(result:find("[\"a\"] = 1", 1, true))
|
||||
assert.truthy(result:find("[\"b\"] = \"2\"", 1, true))
|
||||
assert.truthy(result:find("[\"c\"] = {", 1, true))
|
||||
assert.truthy(result:find("[1] = 3", 1, true))
|
||||
|
||||
|
||||
local t4 = {a = 1, b = {c = 2, d = {e = "4"}}}
|
||||
result = core_util.show_table(t4)
|
||||
assert.truthy(result:find("[\"a\"] = 1", 1, true))
|
||||
|
@ -155,7 +155,7 @@ describe("luarocks.util #unit", function()
|
|||
assert.truthy(result:find("[\"e\"] = \"4\"", 1, true))
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
describe("core.util.cleanup_path", function()
|
||||
it("does not change order of existing items of prepended path", function()
|
||||
local sys_path = '/usr/local/bin;/usr/bin'
|
||||
|
|
|
@ -13,7 +13,7 @@ local extra_rocks = {
|
|||
}
|
||||
|
||||
describe("luarocks which #integration", function()
|
||||
|
||||
|
||||
setup(function()
|
||||
test_env.setup_specs(extra_rocks)
|
||||
test_env.unload_luarocks() -- need to be required here, because hardcoded is created after first loading of specs
|
||||
|
|
|
@ -12,18 +12,18 @@ describe("luarocks write_rockspec tests #integration", function()
|
|||
it("fails with invalid argument", function()
|
||||
assert.is_false(run.luarocks_bool("write_rockspec invalid"))
|
||||
end)
|
||||
|
||||
|
||||
it("fails with invalid zip", function()
|
||||
assert.is_false(run.luarocks_bool("write_rockspec http://example.com/invalid.zip"))
|
||||
end)
|
||||
|
||||
describe("from #git #unix", function()
|
||||
local git
|
||||
|
||||
|
||||
setup(function()
|
||||
git = git_repo.start()
|
||||
end)
|
||||
|
||||
|
||||
teardown(function()
|
||||
git:stop()
|
||||
end)
|
||||
|
@ -46,21 +46,21 @@ describe("luarocks write_rockspec tests #integration", function()
|
|||
assert.is_true(run.luarocks_bool("write_rockspec git://localhost/testrock"))
|
||||
assert.is.truthy(lfs.attributes("testrock-dev-1.rockspec"))
|
||||
end)
|
||||
|
||||
|
||||
it("runs with --tag", function()
|
||||
finally(function() os.remove("testrock-2.3.0-1.rockspec") end)
|
||||
assert.is_true(run.luarocks_bool("write_rockspec git://localhost/testrock --tag=v2.3.0"))
|
||||
assert.is.truthy(lfs.attributes("testrock-2.3.0-1.rockspec"))
|
||||
-- TODO check contents
|
||||
end)
|
||||
|
||||
|
||||
it("runs with format flag", function()
|
||||
finally(function() os.remove("testrock-dev-1.rockspec") end)
|
||||
assert.is_true(run.luarocks_bool("write_rockspec git://localhost/testrock --rockspec-format=1.1 --lua-versions=5.1,5.2"))
|
||||
assert.is.truthy(lfs.attributes("testrock-dev-1.rockspec"))
|
||||
-- TODO check contents
|
||||
end)
|
||||
|
||||
|
||||
it("runs with full flags", function()
|
||||
finally(function() os.remove("testrock-dev-1.rockspec") end)
|
||||
assert.is_true(run.luarocks_bool("write_rockspec git://localhost/testrock --lua-versions=5.1,5.2 --license=\"MIT/X11\" "
|
||||
|
|
|
@ -24,7 +24,7 @@ function cache.get_server_urls(server, upload_server)
|
|||
elseif upload_server.http then download_url = "http://"..upload_server.http
|
||||
elseif upload_server.ftp then download_url = "ftp://"..upload_server.ftp
|
||||
end
|
||||
|
||||
|
||||
if upload_server.ftp then login_url = "ftp://"..upload_server.ftp
|
||||
elseif upload_server.sftp then login_url = "sftp://"..upload_server.sftp
|
||||
end
|
||||
|
@ -57,7 +57,7 @@ local function download_cache(protocol, server_path, user, password)
|
|||
return fs.execute(cfg.variables.RSYNC.." "..cfg.variables.RSYNCFLAGS.." -e ssh "..user.."@"..srv..":"..path.."/ ./")
|
||||
elseif protocol == "file" then
|
||||
return fs.copy_contents(server_path, ".")
|
||||
else
|
||||
else
|
||||
local login_info = ""
|
||||
if user then login_info = " --user="..user end
|
||||
if password then login_info = login_info .. " --password="..password end
|
||||
|
@ -74,7 +74,7 @@ function cache.refresh_local_cache(url, given_user, given_password)
|
|||
end
|
||||
|
||||
fs.change_dir(local_cache)
|
||||
|
||||
|
||||
util.printout("Refreshing cache "..local_cache.."...")
|
||||
|
||||
ok = download_cache(protocol, server_path, user, password)
|
||||
|
|
|
@ -40,23 +40,23 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server, do
|
|||
assert(type(rockfiles) == "table")
|
||||
assert(type(server) == "string")
|
||||
assert(type(upload_server) == "table" or not upload_server)
|
||||
|
||||
|
||||
local download_url, login_url = cache.get_server_urls(server, upload_server)
|
||||
local at = fs.current_dir()
|
||||
local refresh_fn = refresh and cache.refresh_local_cache or cache.split_server_url
|
||||
|
||||
|
||||
local local_cache, protocol, server_path, user, password = refresh_fn(download_url, cfg.upload_user, cfg.upload_password)
|
||||
if not local_cache then
|
||||
return nil, protocol
|
||||
end
|
||||
|
||||
|
||||
if not login_url then
|
||||
login_url = protocol.."://"..server_path
|
||||
end
|
||||
|
||||
|
||||
local ok, err = fs.change_dir(at)
|
||||
if not ok then return nil, err end
|
||||
|
||||
|
||||
local files = {}
|
||||
for _, rockfile in ipairs(rockfiles) do
|
||||
if fs.exists(rockfile) then
|
||||
|
@ -77,9 +77,9 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server, do
|
|||
|
||||
util.printout("Updating manifest...")
|
||||
writer.make_manifest(local_cache, "one", true)
|
||||
|
||||
|
||||
zip_manifests()
|
||||
|
||||
|
||||
if fs.exists("index.html") then
|
||||
do_index = true
|
||||
end
|
||||
|
|
|
@ -27,13 +27,13 @@ end
|
|||
-- or nil and an error message.
|
||||
function make_manifest.command(args)
|
||||
local repo = args.repository or cfg.rocks_dir
|
||||
|
||||
|
||||
util.printout("Making manifest for "..repo)
|
||||
|
||||
|
||||
if repo:match("/lib/luarocks") and not args.local_tree then
|
||||
util.warning("This looks like a local rocks tree, but you did not pass --local-tree.")
|
||||
end
|
||||
|
||||
|
||||
local ok, err = writer.make_manifest(repo, deps.get_deps_mode(args), not args.local_tree)
|
||||
if ok and not args.local_tree then
|
||||
util.printout("Generating index.html for "..repo)
|
||||
|
|
|
@ -18,7 +18,7 @@ function refresh_cache.command(args)
|
|||
local server, upload_server = cache.get_upload_server(args.server)
|
||||
if not server then return nil, upload_server end
|
||||
local download_url = cache.get_server_urls(server, upload_server)
|
||||
|
||||
|
||||
local ok, err = cache.refresh_local_cache(download_url, cfg.upload_user, cfg.upload_password)
|
||||
if not ok then
|
||||
return nil, err
|
||||
|
|
|
@ -32,7 +32,7 @@ local function remove_files_from_server(refresh, rockfiles, server, upload_serve
|
|||
local download_url, login_url = cache.get_server_urls(server, upload_server)
|
||||
local at = fs.current_dir()
|
||||
local refresh_fn = refresh and cache.refresh_local_cache or cache.split_server_url
|
||||
|
||||
|
||||
local local_cache, protocol, server_path, user, password = refresh_fn(download_url, cfg.upload_user, cfg.upload_password)
|
||||
if not local_cache then
|
||||
return nil, protocol
|
||||
|
@ -40,10 +40,10 @@ local function remove_files_from_server(refresh, rockfiles, server, upload_serve
|
|||
if protocol ~= "rsync" then
|
||||
return nil, "This command requires 'rsync', check your configuration."
|
||||
end
|
||||
|
||||
|
||||
local ok, err = fs.change_dir(at)
|
||||
if not ok then return nil, err end
|
||||
|
||||
|
||||
local nr_files = 0
|
||||
for _, rockfile in ipairs(rockfiles) do
|
||||
local basename = dir.base_name(rockfile)
|
||||
|
|
|
@ -87,7 +87,7 @@ local index_footer_begin = [[
|
|||
<a href="manifest">manifest file</a>
|
||||
]]
|
||||
local index_manifest_ver = [[
|
||||
• <a href="manifest-$VER">Lua $VER manifest file</a> (<a href="manifest-$VER.zip">zip</a>)
|
||||
• <a href="manifest-$VER">Lua $VER manifest file</a> (<a href="manifest-$VER.zip">zip</a>)
|
||||
]]
|
||||
local index_footer_end = [[
|
||||
</p>
|
||||
|
@ -129,7 +129,7 @@ function index.make_index(repo)
|
|||
end
|
||||
local manifest = manif.load_manifest(repo)
|
||||
local out = io.open(dir.path(repo, "index.html"), "w")
|
||||
|
||||
|
||||
out:write(index_header)
|
||||
for package, version_list in util.sortedpairs(manifest.repository) do
|
||||
local latest_rockspec = nil
|
||||
|
|
|
@ -328,7 +328,7 @@ local function write_rock_dir_files(rockspec, opts)
|
|||
local name, version = rockspec.name, rockspec.version
|
||||
|
||||
fs.copy(rockspec.local_abs_filename, path.rockspec_file(name, version), "read")
|
||||
|
||||
|
||||
local deplock_file = deplocks.get_abs_filename(rockspec.name)
|
||||
if deplock_file then
|
||||
fs.copy(deplock_file, dir.path(path.install_dir(name, version), "luarocks.lock"), "read")
|
||||
|
@ -375,7 +375,7 @@ function build.build_rockspec(rockspec, opts)
|
|||
if opts.pin then
|
||||
deplocks.init(rockspec.name, ".")
|
||||
end
|
||||
|
||||
|
||||
ok, err = process_dependencies(rockspec, opts)
|
||||
if not ok then return nil, err end
|
||||
|
||||
|
@ -385,7 +385,7 @@ function build.build_rockspec(rockspec, opts)
|
|||
deplocks.write_file()
|
||||
end
|
||||
return name, version
|
||||
end
|
||||
end
|
||||
|
||||
local dirs, err
|
||||
local rollback
|
||||
|
@ -405,13 +405,13 @@ function build.build_rockspec(rockspec, opts)
|
|||
|
||||
ok, err = build.apply_patches(rockspec)
|
||||
if not ok then return nil, err end
|
||||
|
||||
|
||||
ok, err = check_macosx_deployment_target(rockspec)
|
||||
if not ok then return nil, err end
|
||||
|
||||
|
||||
ok, err = run_build_driver(rockspec, opts.no_install)
|
||||
if not ok then return nil, err end
|
||||
|
||||
|
||||
if opts.no_install then
|
||||
fs.pop_dir()
|
||||
if opts.need_to_fetch then
|
||||
|
@ -422,7 +422,7 @@ function build.build_rockspec(rockspec, opts)
|
|||
|
||||
ok, err = install_files(rockspec, dirs)
|
||||
if not ok then return nil, err end
|
||||
|
||||
|
||||
for _, d in pairs(dirs) do
|
||||
fs.remove_dir_if_empty(d.name)
|
||||
end
|
||||
|
@ -441,7 +441,7 @@ function build.build_rockspec(rockspec, opts)
|
|||
|
||||
ok, err = repos.deploy_files(name, version, repos.should_wrap_bin_scripts(rockspec), opts.deps_mode)
|
||||
if not ok then return nil, err end
|
||||
|
||||
|
||||
util.remove_scheduled_function(rollback)
|
||||
rollback = util.schedule_function(function()
|
||||
repos.delete_version(name, version, opts.deps_mode)
|
||||
|
|
|
@ -266,7 +266,7 @@ function builtin.run(rockspec, no_install)
|
|||
local lib_modules = {}
|
||||
local luadir = path.lua_dir(rockspec.name, rockspec.version)
|
||||
local libdir = path.lib_dir(rockspec.name, rockspec.version)
|
||||
|
||||
|
||||
if not build.modules then
|
||||
if rockspec:format_is_at_least("3.0") then
|
||||
local libs, incdirs, libdirs = autoextract_libs(rockspec.external_dependencies, rockspec.variables)
|
||||
|
|
|
@ -36,7 +36,7 @@ function cmake.run(rockspec, no_install)
|
|||
|
||||
-- Execute cmake with variables.
|
||||
local args = ""
|
||||
|
||||
|
||||
-- Try to pick the best generator. With msvc and x64, CMake does not select it by default so we need to be explicit.
|
||||
if cfg.cmake_generator then
|
||||
args = args .. ' -G"'..cfg.cmake_generator.. '"'
|
||||
|
@ -71,7 +71,7 @@ function cmake.run(rockspec, no_install)
|
|||
return nil, "Failed installing."
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ function command.run(rockspec, not_install)
|
|||
assert(rockspec:type() == "rockspec")
|
||||
|
||||
local build = rockspec.build
|
||||
|
||||
|
||||
util.variable_substitutions(build, rockspec.variables)
|
||||
|
||||
local env = {
|
||||
|
|
|
@ -13,7 +13,7 @@ local cfg = require("luarocks.core.cfg")
|
|||
-- configured through variables.MAKE in the config files, or
|
||||
-- the appropriate platform-specific default).
|
||||
-- @param pass boolean: If true, run make; if false, do nothing.
|
||||
-- @param target string: The make target; an empty string indicates
|
||||
-- @param target string: The make target; an empty string indicates
|
||||
-- the default target.
|
||||
-- @param variables table: A table containing string-string key-value
|
||||
-- pairs representing variable assignments to be passed to make.
|
||||
|
@ -42,7 +42,7 @@ function make.run(rockspec, not_install)
|
|||
assert(rockspec:type() == "rockspec")
|
||||
|
||||
local build = rockspec.build
|
||||
|
||||
|
||||
if build.build_pass == nil then build.build_pass = true end
|
||||
if build.install_pass == nil then build.install_pass = true end
|
||||
build.build_variables = build.build_variables or {}
|
||||
|
@ -56,9 +56,9 @@ function make.run(rockspec, not_install)
|
|||
build.install_target = "-f "..makefile.." "..build.install_target
|
||||
end
|
||||
|
||||
if build.variables then
|
||||
if build.variables then
|
||||
for var, val in pairs(build.variables) do
|
||||
build.build_variables[var] = val
|
||||
build.build_variables[var] = val
|
||||
build.install_variables[var] = val
|
||||
end
|
||||
end
|
||||
|
@ -67,9 +67,9 @@ function make.run(rockspec, not_install)
|
|||
|
||||
util.variable_substitutions(build.build_variables, rockspec.variables)
|
||||
util.variable_substitutions(build.install_variables, rockspec.variables)
|
||||
|
||||
|
||||
local auto_variables = { "CC" }
|
||||
|
||||
|
||||
for _, variable in pairs(auto_variables) do
|
||||
if not build.build_variables[variable] then
|
||||
build.build_variables[variable] = rockspec.variables[variable]
|
||||
|
@ -79,7 +79,7 @@ function make.run(rockspec, not_install)
|
|||
end
|
||||
end
|
||||
|
||||
-- backwards compatibility
|
||||
-- backwards compatibility
|
||||
local make_cmd = cfg.make or rockspec.variables.MAKE
|
||||
|
||||
local ok = make_pass(make_cmd, build.build_pass, build.build_target, build.build_variables)
|
||||
|
|
|
@ -63,7 +63,7 @@ do
|
|||
end
|
||||
|
||||
process_tree_args = function(args, project_dir)
|
||||
|
||||
|
||||
if args.global then
|
||||
cfg.local_by_default = false
|
||||
end
|
||||
|
@ -221,7 +221,7 @@ do
|
|||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
local function find_default_lua_version(args, project_dir)
|
||||
if hardcoded.FORCE_CONFIG then
|
||||
return nil
|
||||
|
@ -250,7 +250,7 @@ do
|
|||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
local function find_version_from_config(dirname)
|
||||
return fun.find(util.lua_versions("descending"), function(v)
|
||||
if util.exists(dir.path(dirname, ".luarocks", "config-"..v..".lua")) then
|
||||
|
@ -258,12 +258,12 @@ do
|
|||
end
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
local function detect_lua_via_args(args, project_dir)
|
||||
local lua_version = args.lua_version
|
||||
or find_default_lua_version(args, project_dir)
|
||||
or (project_dir and find_version_from_config(project_dir))
|
||||
|
||||
|
||||
if args.lua_dir then
|
||||
local detected, err = util.find_lua(args.lua_dir, lua_version)
|
||||
if not detected then
|
||||
|
@ -274,7 +274,7 @@ do
|
|||
end
|
||||
return detected
|
||||
end
|
||||
|
||||
|
||||
if lua_version then
|
||||
local detected = search_lua_in_path(lua_version)
|
||||
if detected then
|
||||
|
@ -284,10 +284,10 @@ do
|
|||
lua_version = lua_version,
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
return {}
|
||||
end
|
||||
|
||||
|
||||
detect_config_via_args = function(args)
|
||||
local project_dir, given = find_project_dir(args.project_tree)
|
||||
local detected = detect_lua_via_args(args, project_dir)
|
||||
|
@ -304,15 +304,15 @@ do
|
|||
return detected
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
init_config = function(args)
|
||||
local detected = detect_config_via_args(args)
|
||||
|
||||
|
||||
local ok, err = cfg.init(detected, util.warning)
|
||||
if not ok then
|
||||
return nil, err
|
||||
end
|
||||
|
||||
|
||||
return (detected.lua_dir ~= nil)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -145,7 +145,7 @@ function cmd_build.command(args)
|
|||
return name, version, errcode
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
local ok, err = fs.check_command_permissions(args)
|
||||
if not ok then
|
||||
return nil, err, cmd.errorcodes.PERMISSIONDENIED
|
||||
|
|
|
@ -29,7 +29,7 @@ Query information about the LuaRocks configuration.
|
|||
* `lua_dir` is a special key as it checks for a valid Lua installation
|
||||
(equivalent to --lua-dir) and sets several keys at once.
|
||||
* `lua_version` is a special key as it changes the default Lua version
|
||||
used by LuaRocks commands (equivalent to passing --lua-version).
|
||||
used by LuaRocks commands (equivalent to passing --lua-version).
|
||||
|
||||
Examples:
|
||||
luarocks config variables.OPENSSL_DIR /usr/local/openssl
|
||||
|
@ -114,7 +114,7 @@ local function traverse_varstring(var, tbl, fn, missing_parent)
|
|||
k, r = var:match("^([^[]+)(%[.*)$")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if k then
|
||||
if not tbl[k] and missing_parent then
|
||||
missing_parent(tbl, k)
|
||||
|
@ -131,7 +131,7 @@ local function traverse_varstring(var, tbl, fn, missing_parent)
|
|||
if i then
|
||||
var = tonumber(i)
|
||||
end
|
||||
|
||||
|
||||
return fn(tbl, var)
|
||||
end
|
||||
|
||||
|
@ -179,12 +179,12 @@ local function write_entries(keys, scope, do_unset)
|
|||
if scope == "project" and not cfg.config_files.project then
|
||||
return nil, "Current directory is not part of a project. You may want to run `luarocks init`."
|
||||
end
|
||||
|
||||
|
||||
local tbl, err = persist.load_config_file_if_basic(cfg.config_files[scope].file, cfg)
|
||||
if not tbl then
|
||||
return nil, err
|
||||
end
|
||||
|
||||
|
||||
for var, val in util.sortedpairs(keys) do
|
||||
traverse_varstring(var, tbl, function(t, k)
|
||||
if do_unset then
|
||||
|
@ -242,7 +242,7 @@ end
|
|||
function config_cmd.command(args)
|
||||
deps.check_lua_incdir(cfg.variables, args.lua_version or cfg.lua_version)
|
||||
deps.check_lua_libdir(cfg.variables, args.lua_version or cfg.lua_version)
|
||||
|
||||
|
||||
-- deprecated flags
|
||||
if args.lua_incdir then
|
||||
print(cfg.variables.LUA_INCDIR)
|
||||
|
@ -287,7 +287,7 @@ function config_cmd.command(args)
|
|||
end
|
||||
print("Lua version will default to " .. args.value .. " in " .. prefix)
|
||||
end
|
||||
|
||||
|
||||
if args.key == "lua_dir" and args.value then
|
||||
local scope = get_scope(args)
|
||||
local keys = {
|
||||
|
|
|
@ -67,7 +67,7 @@ function doc.command(args)
|
|||
return try_to_open_homepage(args.rock, args.namespace, args.version)
|
||||
end
|
||||
local name, version = iname, iversion
|
||||
|
||||
|
||||
local rockspec, err = fetch.load_local_rockspec(path.rockspec_file(name, version, repo))
|
||||
if not rockspec then return nil,err end
|
||||
local descript = rockspec.description or {}
|
||||
|
@ -77,7 +77,7 @@ function doc.command(args)
|
|||
end
|
||||
|
||||
local directory = path.install_dir(name, version, repo)
|
||||
|
||||
|
||||
local docdir
|
||||
local directories = { "doc", "docs" }
|
||||
for _, d in ipairs(directories) do
|
||||
|
@ -101,7 +101,7 @@ function doc.command(args)
|
|||
local htmlpatt = "%.html?$"
|
||||
local extensions = { htmlpatt, "%.md$", "%.txt$", "%.textile$", "" }
|
||||
local basenames = { "index", "readme", "manual" }
|
||||
|
||||
|
||||
local porcelain = args.porcelain
|
||||
if #files > 0 then
|
||||
util.title("Documentation files for "..name.." "..version, porcelain)
|
||||
|
@ -116,11 +116,11 @@ function doc.command(args)
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if args.list then
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
for _, extension in ipairs(extensions) do
|
||||
for _, basename in ipairs(basenames) do
|
||||
local filename = basename..extension
|
||||
|
|
|
@ -43,7 +43,7 @@ function cmd_download.command(args)
|
|||
elseif args.arch then
|
||||
arch = args.arch
|
||||
end
|
||||
|
||||
|
||||
local dl, err = download.download(arch, args.name, args.namespace, args.version, args.all, args.check_lua_versions)
|
||||
return dl and true, err
|
||||
end
|
||||
|
|
|
@ -30,7 +30,7 @@ local function write_gitignore(entries)
|
|||
fd:close()
|
||||
gitignore = "\n" .. gitignore .. "\n"
|
||||
end
|
||||
|
||||
|
||||
fd = io.open(".gitignore", gitignore and "a" or "w")
|
||||
for _, entry in ipairs(entries) do
|
||||
entry = "/" .. entry
|
||||
|
@ -64,7 +64,7 @@ function init.command(args)
|
|||
if not ok then
|
||||
return nil, err
|
||||
end
|
||||
|
||||
|
||||
local has_rockspec = false
|
||||
for file in fs.dir() do
|
||||
if file:match("%.rockspec$") then
|
||||
|
@ -97,7 +97,7 @@ function init.command(args)
|
|||
fs.delete(lua_wrapper)
|
||||
fs.delete(config_file)
|
||||
end
|
||||
|
||||
|
||||
local config_tbl, err = persist.load_config_file_if_basic(config_file, cfg)
|
||||
if config_tbl then
|
||||
local globals = {
|
||||
|
@ -131,7 +131,7 @@ function init.command(args)
|
|||
else
|
||||
util.printout("Will not attempt to overwrite " .. config_file)
|
||||
end
|
||||
|
||||
|
||||
ok, err = persist.save_default_lua_version(".luarocks", cfg.lua_version)
|
||||
if not ok then
|
||||
util.printout("Failed setting default Lua version: " .. err)
|
||||
|
@ -158,7 +158,7 @@ function init.command(args)
|
|||
write_lua_wrapper = false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if write_lua_wrapper then
|
||||
local interp = dir.path(cfg.variables["LUA_BINDIR"], cfg.lua_interpreter)
|
||||
if util.check_lua_version(interp, cfg.lua_version) then
|
||||
|
|
|
@ -75,16 +75,16 @@ function install.install_binary_rock(rock_file, opts)
|
|||
if not name then
|
||||
return nil, "Filename "..rock_file.." does not match format 'name-version-revision.arch.rock'."
|
||||
end
|
||||
|
||||
|
||||
if arch ~= "all" and arch ~= cfg.arch then
|
||||
return nil, "Incompatible architecture "..arch, "arch"
|
||||
end
|
||||
if repos.is_installed(name, version) then
|
||||
repos.delete_version(name, version, opts.deps_mode)
|
||||
end
|
||||
|
||||
|
||||
local install_dir = path.install_dir(name, version)
|
||||
|
||||
|
||||
local rollback = util.schedule_function(function()
|
||||
fs.delete(install_dir)
|
||||
fs.remove_dir_if_empty(path.versions_dir(name))
|
||||
|
@ -139,7 +139,7 @@ end
|
|||
-- @param rock_file string: local or remote filename of a rock.
|
||||
-- @param opts table: installation options
|
||||
-- @return (string, string) or (nil, string, [string]): Name and version of
|
||||
-- the rock whose dependencies were installed if succeeded or nil and an error message
|
||||
-- the rock whose dependencies were installed if succeeded or nil and an error message
|
||||
-- followed by an error code.
|
||||
function install.install_binary_rock_deps(rock_file, opts)
|
||||
assert(type(rock_file) == "string")
|
||||
|
@ -149,7 +149,7 @@ function install.install_binary_rock_deps(rock_file, opts)
|
|||
if not name then
|
||||
return nil, "Filename "..rock_file.." does not match format 'name-version-revision.arch.rock'."
|
||||
end
|
||||
|
||||
|
||||
if arch ~= "all" and arch ~= cfg.arch then
|
||||
return nil, "Incompatible architecture "..arch, "arch"
|
||||
end
|
||||
|
@ -158,7 +158,7 @@ function install.install_binary_rock_deps(rock_file, opts)
|
|||
|
||||
local ok, err, errcode = fetch.fetch_and_unpack_rock(rock_file, install_dir, opts.verify)
|
||||
if not ok then return nil, err, errcode end
|
||||
|
||||
|
||||
local rockspec, err = fetch.load_rockspec(path.rockspec_file(name, version))
|
||||
if err then
|
||||
return nil, "Failed loading rockspec for installed package: "..err, errcode
|
||||
|
|
|
@ -33,8 +33,8 @@ function lint.command(args)
|
|||
end
|
||||
|
||||
local ok = true
|
||||
|
||||
-- This should have been done in the type checker,
|
||||
|
||||
-- This should have been done in the type checker,
|
||||
-- but it would break compatibility of other commands.
|
||||
-- Making 'lint' alone be stricter shouldn't be a problem,
|
||||
-- because extra-strict checks is what lint-type commands
|
||||
|
|
|
@ -36,13 +36,13 @@ local function check_outdated(trees, query)
|
|||
|
||||
local query_available = queries.new(name:lower())
|
||||
local results_available, err = search.search_repos(query_available)
|
||||
|
||||
|
||||
if results_available[name] then
|
||||
local available_versions = util.keys(results_available[name])
|
||||
table.sort(available_versions, vers.compare_versions)
|
||||
local latest_available = available_versions[1]
|
||||
local latest_available_repo = results_available[name][latest_available][1].repo
|
||||
|
||||
|
||||
if vers.compare_versions(latest_available, latest_installed) then
|
||||
table.insert(outdated, { name = name, installed = latest_installed, available = latest_available, repo = latest_available_repo })
|
||||
end
|
||||
|
@ -76,11 +76,11 @@ function list.command(args)
|
|||
trees = { args.tree }
|
||||
title = title .. " in " .. args.tree
|
||||
end
|
||||
|
||||
|
||||
if args.outdated then
|
||||
return list_outdated(trees, query, args.porcelain)
|
||||
end
|
||||
|
||||
|
||||
local results = {}
|
||||
for _, tree in ipairs(trees) do
|
||||
local ok, err, errcode = search.local_manifest_search(results, path.rocks_dir(tree), query)
|
||||
|
|
|
@ -60,7 +60,7 @@ local function try_replace(tbl, field, old, new)
|
|||
if new_field ~= old_field then
|
||||
util.printout("Guessing new '"..field.."' field as "..new_field)
|
||||
tbl[field] = new_field
|
||||
return true
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
@ -104,7 +104,7 @@ local function check_url_and_update_md5(out_rs, invalid_is_error)
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function update_source_section(out_rs, url, tag, old_ver, new_ver)
|
||||
if tag then
|
||||
out_rs.source.tag = tag
|
||||
|
@ -144,7 +144,7 @@ local function update_source_section(out_rs, url, tag, old_ver, new_ver)
|
|||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
function new_version.command(args)
|
||||
if not args.rock then
|
||||
local err
|
||||
|
@ -153,7 +153,7 @@ function new_version.command(args)
|
|||
return nil, err
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local filename, err
|
||||
if args.rock:match("rockspec$") then
|
||||
filename, err = fetch.fetch_url(args.rock)
|
||||
|
@ -178,7 +178,7 @@ function new_version.command(args)
|
|||
if args.tag and not args.new_version then
|
||||
args.new_version = args.tag:gsub("^v", "")
|
||||
end
|
||||
|
||||
|
||||
local out_dir
|
||||
if args.dir then
|
||||
out_dir = dir.normalize(args.dir)
|
||||
|
@ -196,7 +196,7 @@ function new_version.command(args)
|
|||
new_rev = tonumber(old_rev) + 1
|
||||
end
|
||||
local new_rockver = new_ver:gsub("-", "")
|
||||
|
||||
|
||||
local out_rs, err = persist.load_into_table(filename)
|
||||
local out_name = out_rs.package:lower()
|
||||
out_rs.version = new_rockver.."-"..new_rev
|
||||
|
@ -207,21 +207,21 @@ function new_version.command(args)
|
|||
if out_rs.build and out_rs.build.type == "module" then
|
||||
out_rs.build.type = "builtin"
|
||||
end
|
||||
|
||||
|
||||
local out_filename = out_name.."-"..new_rockver.."-"..new_rev..".rockspec"
|
||||
if out_dir then
|
||||
out_filename = dir.path(out_dir, out_filename)
|
||||
fs.make_dir(out_dir)
|
||||
end
|
||||
persist.save_from_table(out_filename, out_rs, type_rockspec.order)
|
||||
|
||||
|
||||
util.printout("Wrote "..out_filename)
|
||||
|
||||
local valid_out_rs, err = fetch.load_local_rockspec(out_filename)
|
||||
if not valid_out_rs then
|
||||
return nil, "Failed loading generated rockspec: "..err
|
||||
end
|
||||
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
|
|
@ -10,11 +10,11 @@ local fs = require("luarocks.fs")
|
|||
function path_cmd.add_to_parser(parser)
|
||||
local cmd = parser:command("path", [[
|
||||
Returns the package path currently configured for this installation
|
||||
of LuaRocks, formatted as shell commands to update LUA_PATH and LUA_CPATH.
|
||||
of LuaRocks, formatted as shell commands to update LUA_PATH and LUA_CPATH.
|
||||
|
||||
On Unix systems, you may run:
|
||||
On Unix systems, you may run:
|
||||
eval `luarocks path`
|
||||
And on Windows:
|
||||
And on Windows:
|
||||
luarocks path > "%temp%\_lrp.bat" && call "%temp%\_lrp.bat" && del "%temp%\_lrp.bat"]],
|
||||
util.see_also())
|
||||
:summary("Return the currently configured package path.")
|
||||
|
@ -56,7 +56,7 @@ function path_cmd.command(args)
|
|||
lr_cpath = lr_cpath .. ";" .. package.cpath
|
||||
lr_bin = lr_bin .. path_sep .. clean_path
|
||||
end
|
||||
|
||||
|
||||
local lpath_var, lcpath_var = util.lua_path_variables()
|
||||
|
||||
util.printout(fs.export_cmd(lpath_var, util.cleanup_path(lr_path, ';', cfg.lua_version, args.append)))
|
||||
|
|
|
@ -42,7 +42,7 @@ function purge.command(args)
|
|||
if type(tree) ~= "string" then
|
||||
return nil, "The --tree argument is mandatory. "..util.see_help("purge")
|
||||
end
|
||||
|
||||
|
||||
local results = {}
|
||||
if not fs.is_dir(tree) then
|
||||
return nil, "Directory not found: "..tree
|
||||
|
|
|
@ -42,10 +42,10 @@ end
|
|||
function cmd_remove.command(args)
|
||||
local name = args.rock
|
||||
local deps_mode = deps.get_deps_mode(args)
|
||||
|
||||
|
||||
local ok, err = fs.check_command_permissions(args)
|
||||
if not ok then return nil, err, cmd.errorcodes.PERMISSIONDENIED end
|
||||
|
||||
|
||||
local rock_type = name:match("%.(rock)$") or name:match("%.(rockspec)$")
|
||||
local version = args.version
|
||||
local filename = name
|
||||
|
|
|
@ -63,7 +63,7 @@ function cmd_search.command(args)
|
|||
if not args.name and not args.all then
|
||||
return nil, "Enter name and version or use --all. "..util.see_help("search")
|
||||
end
|
||||
|
||||
|
||||
local query = queries.new(name, args.namespace, args.version, true)
|
||||
local result_tree, err = search.search_repos(query)
|
||||
local porcelain = args.porcelain
|
||||
|
|
|
@ -100,7 +100,7 @@ local function keys_as_string(t, sep)
|
|||
return table.concat(keys, sep or " ")
|
||||
end
|
||||
|
||||
local function word_wrap(line)
|
||||
local function word_wrap(line)
|
||||
local width = tonumber(os.getenv("COLUMNS")) or 80
|
||||
if width > 80 then width = 80 end
|
||||
if #line > width then
|
||||
|
@ -265,7 +265,7 @@ end
|
|||
-- @return boolean: True if succeeded, nil on errors.
|
||||
function show.command(args)
|
||||
local query = queries.new(args.rock, args.namespace, args.version, true)
|
||||
|
||||
|
||||
local name, version, repo, repo_url = search.pick_installed_rock(query, args.tree)
|
||||
if not name then
|
||||
return nil, version
|
||||
|
|
|
@ -33,9 +33,9 @@ function cmd_test.command(args)
|
|||
if args.rockspec and args.rockspec:match("rockspec$") then
|
||||
return test.run_test_suite(args.rockspec, args.test_type, args.args)
|
||||
end
|
||||
|
||||
|
||||
table.insert(args.args, 1, args.rockspec)
|
||||
|
||||
|
||||
local rockspec, err = util.get_default_rockspec()
|
||||
if not rockspec then
|
||||
return nil, err
|
||||
|
|
|
@ -32,7 +32,7 @@ end
|
|||
-- files specified in the rockspec, and unpack them inside the directory.
|
||||
-- @param rockspec_file string: The URL for a rockspec file.
|
||||
-- @param dir_name string: The directory where to store and unpack files.
|
||||
-- @return table or (nil, string): the loaded rockspec table or
|
||||
-- @return table or (nil, string): the loaded rockspec table or
|
||||
-- nil and an error message.
|
||||
local function unpack_rockspec(rockspec_file, dir_name)
|
||||
assert(type(rockspec_file) == "string")
|
||||
|
@ -61,7 +61,7 @@ end
|
|||
-- @param dir_name string: The directory where to unpack.
|
||||
-- @param kind string: the kind of rock file, as in the second-level
|
||||
-- extension in the rock filename (eg. "src", "all", "linux-x86")
|
||||
-- @return table or (nil, string): the loaded rockspec table or
|
||||
-- @return table or (nil, string): the loaded rockspec table or
|
||||
-- nil and an error message.
|
||||
local function unpack_rock(rock_file, dir_name, kind)
|
||||
assert(type(rock_file) == "string")
|
||||
|
@ -102,7 +102,7 @@ end
|
|||
-- by an error message.
|
||||
local function run_unpacker(file, force)
|
||||
assert(type(file) == "string")
|
||||
|
||||
|
||||
local base_name = dir.base_name(file)
|
||||
local dir_name, kind, extension = base_name:match("(.*)%.([^.]+)%.(rock)$")
|
||||
if not extension then
|
||||
|
@ -139,7 +139,7 @@ local function run_unpacker(file, force)
|
|||
return nil, "Failed copying unpacked rockspec into unpacked source directory."
|
||||
end
|
||||
end
|
||||
util.printout()
|
||||
util.printout()
|
||||
util.printout("Done. You may now enter directory ")
|
||||
util.printout(dir.path(dir_name, rockspec.source.dir))
|
||||
util.printout("and type 'luarocks make' to build.")
|
||||
|
|
|
@ -53,7 +53,7 @@ function upload.command(args)
|
|||
version = rockspec.version
|
||||
})
|
||||
if not res then return nil, err end
|
||||
|
||||
|
||||
if not res.module then
|
||||
util.printout("Will create new module (" .. tostring(rockspec.package) .. ")")
|
||||
end
|
||||
|
@ -87,7 +87,7 @@ function upload.command(args)
|
|||
util.printout("Signed packed rock: "..rock_sigfname)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local multipart = require("luarocks.upload.multipart")
|
||||
|
||||
res, err = api:method("upload", nil, {
|
||||
|
@ -95,13 +95,13 @@ function upload.command(args)
|
|||
rockspec_sig = sigfname and multipart.new_file(sigfname),
|
||||
})
|
||||
if not res then return nil, err end
|
||||
|
||||
|
||||
if res.is_new and #res.manifests == 0 then
|
||||
util.printerr("Warning: module not added to root manifest due to name taken.")
|
||||
end
|
||||
|
||||
|
||||
local module_url = res.module_url
|
||||
|
||||
|
||||
if rock_fname then
|
||||
if (not res.version) or (not res.version.id) then
|
||||
return nil, "Invalid response from server."
|
||||
|
@ -113,7 +113,7 @@ function upload.command(args)
|
|||
})
|
||||
if not res then return nil, err end
|
||||
end
|
||||
|
||||
|
||||
util.printout()
|
||||
util.printout("Done: " .. tostring(module_url))
|
||||
util.printout()
|
||||
|
|
|
@ -137,7 +137,7 @@ do
|
|||
return url
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function detect_scm_url(directory)
|
||||
return detect_url_from_command("git", "config --get remote.origin.url", directory) or
|
||||
detect_url_from_command("hg", "paths default", directory)
|
||||
|
@ -230,7 +230,7 @@ local function fill_as_builtin(rockspec, libs)
|
|||
libdirs[#libdirs+1] = "$("..upper.."_LIBDIR)"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
rockspec.build.modules, rockspec.build.install, rockspec.build.copy_directories = builtin.autodetect_modules(libs, incdirs, libdirs)
|
||||
end
|
||||
|
||||
|
@ -302,10 +302,10 @@ function write_rockspec.command(args)
|
|||
version = version or "dev"
|
||||
|
||||
local filename = args.output or dir.path(fs.current_dir(), name:lower().."-"..version.."-1.rockspec")
|
||||
|
||||
|
||||
local url = detect_url(location)
|
||||
local homepage = detect_homepage(url, args.homepage)
|
||||
|
||||
|
||||
local rockspec, err = rockspecs.from_persisted_table(filename, {
|
||||
rockspec_format = args.rockspec_format,
|
||||
package = name,
|
||||
|
@ -327,11 +327,11 @@ function write_rockspec.command(args)
|
|||
})
|
||||
assert(not err, err)
|
||||
rockspec.source.protocol = protocol
|
||||
|
||||
|
||||
if not next(rockspec.dependencies) then
|
||||
util.warning("Please specify supported Lua versions with --lua-versions=<ver>. "..util.see_help("write_rockspec"))
|
||||
end
|
||||
|
||||
|
||||
local local_dir = location
|
||||
|
||||
if location:match("://") then
|
||||
|
@ -354,11 +354,11 @@ function write_rockspec.command(args)
|
|||
local_dir = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if not local_dir then
|
||||
local_dir = "."
|
||||
end
|
||||
|
||||
|
||||
local libs = nil
|
||||
if args.lib then
|
||||
libs = {}
|
||||
|
@ -391,16 +391,16 @@ function write_rockspec.command(args)
|
|||
util.title("Please fill in the source.license field manually or use --license.")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
fill_as_builtin(rockspec, libs)
|
||||
|
||||
|
||||
rockspec_cleanup(rockspec)
|
||||
|
||||
|
||||
persist.save_from_table(filename, rockspec, type_rockspec.order)
|
||||
|
||||
util.printout()
|
||||
util.printout()
|
||||
util.printout("Wrote template at "..filename.." -- you should now edit and finish it.")
|
||||
util.printout()
|
||||
util.printout()
|
||||
|
||||
return true
|
||||
end
|
||||
|
|
|
@ -558,7 +558,7 @@ local cfg = {}
|
|||
|
||||
--- Initializes the LuaRocks configuration for variables, paths
|
||||
-- and OS detection.
|
||||
-- @param detected table containing information detected about the
|
||||
-- @param detected table containing information detected about the
|
||||
-- environment. All fields below are optional:
|
||||
-- * lua_version (in x.y format, e.g. "5.3")
|
||||
-- * lua_bindir (e.g. "/usr/local/bin")
|
||||
|
@ -575,7 +575,7 @@ function cfg.init(detected, warning)
|
|||
if not hc_ok then
|
||||
hardcoded = {}
|
||||
end
|
||||
|
||||
|
||||
local init = cfg.init
|
||||
|
||||
----------------------------------------
|
||||
|
@ -595,7 +595,7 @@ function cfg.init(detected, warning)
|
|||
end
|
||||
|
||||
-- Use detected values as defaults, overridable via config files or CLI args
|
||||
|
||||
|
||||
local first_arg = get_first_arg()
|
||||
|
||||
cfg.lua_version = detected.lua_version or hardcoded.LUA_VERSION or _VERSION:sub(5)
|
||||
|
@ -778,7 +778,7 @@ function cfg.init(detected, warning)
|
|||
and home_config_file
|
||||
or sys_config_file),
|
||||
}
|
||||
|
||||
|
||||
cfg.cache = {}
|
||||
|
||||
----------------------------------------
|
||||
|
|
|
@ -6,7 +6,7 @@ local require = nil
|
|||
|
||||
local function unquote(c)
|
||||
local first, last = c:sub(1,1), c:sub(-1)
|
||||
if (first == '"' and last == '"') or
|
||||
if (first == '"' and last == '"') or
|
||||
(first == "'" and last == "'") then
|
||||
return c:sub(2,-2)
|
||||
end
|
||||
|
@ -40,7 +40,7 @@ end
|
|||
-- @return string, string: the protocol, and the pathname without the protocol.
|
||||
function dir.split_url(url)
|
||||
assert(type(url) == "string")
|
||||
|
||||
|
||||
url = unquote(url)
|
||||
local protocol, pathname = url:match("^([^:]*)://(.*)")
|
||||
if not protocol then
|
||||
|
|
|
@ -94,7 +94,7 @@ function manif.scan_dependencies(name, version, tree_manifests, dest)
|
|||
if pkgdeps then
|
||||
for _, dep in ipairs(pkgdeps) do
|
||||
local pkg, constraints = dep.name, dep.constraints
|
||||
|
||||
|
||||
for _, t in ipairs(tree_manifests) do
|
||||
local entries = t.manifest.repository[pkg]
|
||||
if entries then
|
||||
|
|
|
@ -66,9 +66,9 @@ function persist.load_into_table(filename, tbl)
|
|||
}
|
||||
local save_mt = getmetatable(result)
|
||||
setmetatable(result, globals_mt)
|
||||
|
||||
|
||||
local ok, err, errcode = persist.run_file(filename, result)
|
||||
|
||||
|
||||
setmetatable(result, save_mt)
|
||||
|
||||
if not ok then
|
||||
|
|
|
@ -15,7 +15,7 @@ end
|
|||
local function read_int8(fd)
|
||||
if io.type(fd) == "closed file" then
|
||||
return nil
|
||||
end
|
||||
end
|
||||
local s = fd:read(1)
|
||||
if not s then
|
||||
fd:close()
|
||||
|
@ -44,7 +44,7 @@ end
|
|||
local function read(fd, bytes, endian)
|
||||
if io.type(fd) == "closed file" then
|
||||
return nil
|
||||
end
|
||||
end
|
||||
local s = fd:read(bytes)
|
||||
if not s
|
||||
then fd:close()
|
||||
|
@ -138,7 +138,7 @@ end
|
|||
local function detect_elf_system(fd, hdr, sections)
|
||||
local system = e_osabi[hdr.osabi]
|
||||
local endian = hdr.endian
|
||||
|
||||
|
||||
if system == "sysv" then
|
||||
local abitag = sections[".note.ABI-tag"]
|
||||
if abitag then
|
||||
|
@ -154,7 +154,7 @@ local function detect_elf_system(fd, hdr, sections)
|
|||
elseif sections[".note.openbsd.ident"] then
|
||||
return "openbsd"
|
||||
end
|
||||
|
||||
|
||||
local gnu_version_r = sections[".gnu.version_r"]
|
||||
if gnu_version_r then
|
||||
|
||||
|
@ -170,7 +170,7 @@ local function detect_elf_system(fd, hdr, sections)
|
|||
|
||||
fd:seek("set", dynstr + vn_file)
|
||||
local libname = fd:read(64):gsub("%z.*", "")
|
||||
|
||||
|
||||
if hdr.e_type == 0x03 and libname == "libroot.so" then
|
||||
return "haiku"
|
||||
elseif libname:match("linux") then
|
||||
|
@ -190,7 +190,7 @@ local function detect_elf_system(fd, hdr, sections)
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return system
|
||||
end
|
||||
|
||||
|
@ -207,7 +207,7 @@ local function read_elf_header(fd)
|
|||
if not hdr.osabi then
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
local endian = hdr.endian
|
||||
fd:seek("set", 0x10)
|
||||
hdr.e_type = read(fd, 2, endian)
|
||||
|
@ -221,10 +221,10 @@ local function read_elf_header(fd)
|
|||
if elfversion ~= 1 then
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
local word = (hdr.bits == 1) and 4 or 8
|
||||
hdr.word = word
|
||||
|
||||
|
||||
hdr.e_entry = read(fd, word, endian)
|
||||
hdr.e_phoff = read(fd, word, endian)
|
||||
hdr.e_shoff = read(fd, word, endian)
|
||||
|
@ -235,7 +235,7 @@ local function read_elf_header(fd)
|
|||
hdr.e_shentsize = read(fd, 2, endian)
|
||||
hdr.e_shnum = read(fd, 2, endian)
|
||||
hdr.e_shstrndx = read(fd, 2, endian)
|
||||
|
||||
|
||||
return hdr, processor
|
||||
end
|
||||
|
||||
|
@ -323,7 +323,7 @@ local function detect_pe(fd)
|
|||
fd:seek("set", peoffset + 4) -- move to position of Machine section
|
||||
local machine = read(fd, 2, LITTLE)
|
||||
local processor = pe_machine[machine]
|
||||
|
||||
|
||||
local rdata_pos = fd:read(736):match(".rdata%z%z............(....)")
|
||||
if rdata_pos then
|
||||
rdata_pos = bytes2number(rdata_pos, LITTLE)
|
||||
|
@ -333,7 +333,7 @@ local function detect_pe(fd)
|
|||
system = "cygwin"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return system, processor or "unknown"
|
||||
end
|
||||
|
||||
|
@ -363,7 +363,7 @@ local cache_processor
|
|||
function sysdetect.detect(input_file)
|
||||
local dirsep = package.config:sub(1,1)
|
||||
local files
|
||||
|
||||
|
||||
if input_file then
|
||||
files = { input_file }
|
||||
else
|
||||
|
|
|
@ -5,7 +5,7 @@ local require = nil
|
|||
--------------------------------------------------------------------------------
|
||||
|
||||
--- Run a process and read a its output.
|
||||
-- Equivalent to io.popen(cmd):read("*l"), except that it
|
||||
-- Equivalent to io.popen(cmd):read("*l"), except that it
|
||||
-- closes the fd right away.
|
||||
-- @param cmd string: The command to execute
|
||||
-- @param spec string: "*l" by default, to read a single line.
|
||||
|
@ -63,7 +63,7 @@ function util.show_table(t, tname, top_indent)
|
|||
local autoref -- for self references
|
||||
|
||||
local function is_empty_table(tbl) return next(tbl) == nil end
|
||||
|
||||
|
||||
local function basic_serialize(o)
|
||||
local so = tostring(o)
|
||||
if type(o) == "function" then
|
||||
|
@ -71,7 +71,7 @@ function util.show_table(t, tname, top_indent)
|
|||
-- info.name is nil because o is not a calling level
|
||||
if info.what == "C" then
|
||||
return ("%q"):format(so .. ", C function")
|
||||
else
|
||||
else
|
||||
-- the information is defined through lines
|
||||
return ("%q"):format(so .. ", defined in (" .. info.linedefined .. "-" .. info.lastlinedefined .. ")" .. info.source)
|
||||
end
|
||||
|
@ -81,14 +81,14 @@ function util.show_table(t, tname, top_indent)
|
|||
return ("%q"):format(so)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function add_to_cart(value, name, indent, saved, field)
|
||||
indent = indent or ""
|
||||
saved = saved or {}
|
||||
field = field or name
|
||||
|
||||
|
||||
cart = cart .. indent .. field
|
||||
|
||||
|
||||
if type(value) ~= "table" then
|
||||
cart = cart .. " = " .. basic_serialize(value) .. ";\n"
|
||||
else
|
||||
|
@ -113,7 +113,7 @@ function util.show_table(t, tname, top_indent)
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
tname = tname or "__unnamed__"
|
||||
if type(t) ~= "table" then
|
||||
return tname .. " = " .. basic_serialize(t)
|
||||
|
@ -189,7 +189,7 @@ function util.cleanup_path(list, sep, lua_version, keep_first)
|
|||
local part = parts[i]:gsub("//", "/")
|
||||
if lua_version then
|
||||
part = part:gsub("/lua/([%d.]+)/", function(part_version)
|
||||
if part_version:sub(1, #lua_version) ~= lua_version then
|
||||
if part_version:sub(1, #lua_version) ~= lua_version then
|
||||
return "/lua/"..lua_version.."/"
|
||||
end
|
||||
end)
|
||||
|
|
|
@ -63,11 +63,11 @@ local version_mt = {
|
|||
return not (v2 < v1)
|
||||
end,
|
||||
--- Return version as a string.
|
||||
-- @param v The version table.
|
||||
-- @param v The version table.
|
||||
-- @return The string representation.
|
||||
__tostring = function(v)
|
||||
return v.string
|
||||
end,
|
||||
end,
|
||||
}
|
||||
|
||||
local version_cache = {}
|
||||
|
@ -102,7 +102,7 @@ function vers.parse_version(vstring)
|
|||
version[i] = version[i] and version[i] + number/100000 or number
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
|
||||
-- trim leading and trailing spaces
|
||||
local v = vstring:match("^%s*(.*)%s*$")
|
||||
version.string = v
|
||||
|
@ -164,7 +164,7 @@ local function partial_match(version, requested)
|
|||
if type(version) ~= "table" then version = vers.parse_version(version) end
|
||||
if type(requested) ~= "table" then requested = vers.parse_version(requested) end
|
||||
if not version or not requested then return false end
|
||||
|
||||
|
||||
for i, ri in ipairs(requested) do
|
||||
local vi = version[i] or 0
|
||||
if ri ~= vi then return false end
|
||||
|
|
|
@ -46,10 +46,10 @@ function deplocks.load(root_rock_name, dirname)
|
|||
-- could not open, maybe file does not exist
|
||||
return true, nil
|
||||
end
|
||||
|
||||
|
||||
deplock_abs_filename = fs.absolute_name(filename)
|
||||
deplock_root_rock_name = root_rock_name
|
||||
|
||||
|
||||
deptable = result
|
||||
return true, filename
|
||||
end
|
||||
|
@ -58,7 +58,7 @@ function deplocks.add(depskey, name, version)
|
|||
if deptable_mode == "locked" then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local dk = deptable[depskey]
|
||||
if not dk then
|
||||
dk = {}
|
||||
|
@ -89,7 +89,7 @@ end
|
|||
|
||||
-- a table-like interface to deplocks
|
||||
function deplocks.proxy(depskey)
|
||||
return setmetatable({}, {
|
||||
return setmetatable({}, {
|
||||
__index = function(_, k)
|
||||
return deplocks.get(depskey, k)
|
||||
end,
|
||||
|
|
|
@ -47,7 +47,7 @@ local function prepare_get_versions(deps_mode, rocks_provided, depskey, blacklis
|
|||
end
|
||||
versions, locations = manif.get_versions(dep, deps_mode)
|
||||
end
|
||||
|
||||
|
||||
if blacklist and blacklist[dep.name] then
|
||||
local orig_versions = versions
|
||||
versions = {}
|
||||
|
@ -57,9 +57,9 @@ local function prepare_get_versions(deps_mode, rocks_provided, depskey, blacklis
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local lockversion = deplocks.get(depskey, dep.name)
|
||||
|
||||
|
||||
return versions, locations, lockversion, provided ~= nil
|
||||
end
|
||||
end
|
||||
|
@ -81,9 +81,9 @@ end
|
|||
local function match_dep(dep, get_versions)
|
||||
assert(type(dep) == "table")
|
||||
assert(type(get_versions) == "function")
|
||||
|
||||
|
||||
local versions, locations, lockversion, provided = get_versions(dep)
|
||||
|
||||
|
||||
local latest_version
|
||||
local latest_vstring
|
||||
for _, vstring in ipairs(versions) do
|
||||
|
@ -95,7 +95,7 @@ local function match_dep(dep, get_versions)
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if lockversion and not locations[lockversion] then
|
||||
local latest_matching_msg = ""
|
||||
if latest_vstring and latest_vstring ~= lockversion then
|
||||
|
@ -104,7 +104,7 @@ local function match_dep(dep, get_versions)
|
|||
util.printout("Forcing " .. dep.name .. " to pinned version " .. lockversion .. latest_matching_msg)
|
||||
return nil, nil, queries.new(dep.name, dep.namespace, lockversion)
|
||||
end
|
||||
|
||||
|
||||
return latest_vstring, locations[latest_vstring], dep, provided
|
||||
end
|
||||
|
||||
|
@ -113,7 +113,7 @@ local function match_all_deps(dependencies, get_versions)
|
|||
assert(type(get_versions) == "function")
|
||||
|
||||
local matched, missing, no_upgrade = {}, {}, {}
|
||||
|
||||
|
||||
for _, dep in ipairs(dependencies) do
|
||||
local found, _, provided
|
||||
found, _, dep, provided = match_dep(dep, get_versions)
|
||||
|
@ -169,7 +169,7 @@ end
|
|||
-- @param version string: package version.
|
||||
-- @param dependencies table: array of dependencies.
|
||||
-- @param deps_mode string: Which trees to check dependencies for
|
||||
-- @param rocks_provided table: A table of auto-dependencies provided
|
||||
-- @param rocks_provided table: A table of auto-dependencies provided
|
||||
-- by this Lua implementation for the given dependency.
|
||||
-- "one" for the current default tree, "all" for all trees,
|
||||
-- "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
|
|||
assert(type(dependencies) == "table")
|
||||
assert(type(deps_mode) == "string")
|
||||
assert(type(rocks_provided) == "table")
|
||||
|
||||
|
||||
if deps_mode == "none" then
|
||||
return
|
||||
end
|
||||
|
@ -270,7 +270,7 @@ local function check_supported_platforms(rockspec)
|
|||
return nil, "This rockspec for "..rockspec.package.." does not support "..plats.." platforms."
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
@ -295,7 +295,7 @@ function deps.fulfill_dependencies(rockspec, depskey, deps_mode, verify, deplock
|
|||
local name = rockspec.name
|
||||
local version = rockspec.version
|
||||
local rocks_provided = rockspec.rocks_provided
|
||||
|
||||
|
||||
local ok, filename, err = deplocks.load(name, deplock_dir or ".")
|
||||
if filename then
|
||||
util.printout("Using dependencies pinned in lockfile: " .. filename)
|
||||
|
@ -530,7 +530,7 @@ local function check_external_dependency(name, ext_files, vars, mode, cache)
|
|||
local err_files = {program = {}, header = {}, library = {}}
|
||||
|
||||
local dirs = get_external_deps_dirs(mode)
|
||||
|
||||
|
||||
local prefixes
|
||||
if vars[name .. "_DIR"] then
|
||||
prefixes = { vars[name .. "_DIR"] }
|
||||
|
@ -539,7 +539,7 @@ local function check_external_dependency(name, ext_files, vars, mode, cache)
|
|||
else
|
||||
prefixes = cfg.external_deps_dirs
|
||||
end
|
||||
|
||||
|
||||
for _, prefix in ipairs(prefixes) do
|
||||
prefix = resolve_prefix(prefix, dirs)
|
||||
if cfg.is_platform("mingw32") and name == "LUA" then
|
||||
|
@ -556,7 +556,7 @@ local function check_external_dependency(name, ext_files, vars, mode, cache)
|
|||
return true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return nil, err_dirname, err_testfile, err_files
|
||||
end
|
||||
|
||||
|
@ -575,7 +575,7 @@ end
|
|||
-- nil and an error message if any test failed.
|
||||
function deps.check_external_deps(rockspec, mode)
|
||||
assert(rockspec:type() == "rockspec")
|
||||
|
||||
|
||||
if not rockspec.external_dependencies then
|
||||
rockspec.external_dependencies = builtin.autodetect_external_dependencies(rockspec.build)
|
||||
end
|
||||
|
@ -587,7 +587,7 @@ function deps.check_external_deps(rockspec, mode)
|
|||
local ok, err_dirname, err_testfile, err_files = check_external_dependency(name, ext_files, rockspec.variables, mode)
|
||||
if not ok then
|
||||
local lines = {"Could not find "..err_testfile.." file for "..name}
|
||||
|
||||
|
||||
local err_paths = {}
|
||||
for _, err_file in ipairs(err_files[err_testfile]) do
|
||||
if not err_paths[err_file] then
|
||||
|
@ -595,10 +595,10 @@ function deps.check_external_deps(rockspec, mode)
|
|||
table.insert(lines, " No file "..err_file)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
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.")
|
||||
table.insert(lines, "Example: luarocks install "..rockspec.name.." "..name.."_DIR=/usr/local")
|
||||
|
||||
|
||||
return nil, table.concat(lines, "\n"), "dependency"
|
||||
end
|
||||
end
|
||||
|
@ -700,7 +700,7 @@ function deps.check_lua_incdir(vars)
|
|||
if vars.LUA_INCDIR then
|
||||
return lua_h_exists(vars.LUA_INCDIR, cfg.lua_version)
|
||||
end
|
||||
|
||||
|
||||
if vars.LUA_DIR then
|
||||
vars.LUA_INCDIR = find_lua_incdir(vars.LUA_DIR, cfg.lua_version, ljv)
|
||||
if vars.LUA_INCDIR then
|
||||
|
|
|
@ -175,7 +175,7 @@ local function fetch_and_verify_signature_for(url, filename, tmpdir)
|
|||
if not sig_file then
|
||||
return nil, "Could not fetch signature file for verification: " .. err, errcode
|
||||
end
|
||||
|
||||
|
||||
local ok, err = signing.verify_signature(filename, sig_file)
|
||||
if not ok then
|
||||
return nil, "Failed signature verification: " .. err
|
||||
|
@ -269,7 +269,7 @@ function fetch.load_local_rockspec(rel_filename, quick)
|
|||
if not tbl then
|
||||
return nil, "Could not load rockspec file "..abs_filename.." ("..err..")"
|
||||
end
|
||||
|
||||
|
||||
local rockspec, err = rockspecs.from_persisted_table(abs_filename, tbl, err, quick)
|
||||
if not rockspec then
|
||||
return nil, abs_filename .. ": " .. err
|
||||
|
@ -279,12 +279,12 @@ function fetch.load_local_rockspec(rel_filename, quick)
|
|||
if basename ~= "rockspec" and basename ~= name_version .. ".rockspec" then
|
||||
return nil, "Inconsistency between rockspec filename ("..basename..") and its contents ("..name_version..".rockspec)."
|
||||
end
|
||||
|
||||
|
||||
return rockspec
|
||||
end
|
||||
|
||||
--- Load a local or remote rockspec into a table.
|
||||
-- This is the entry point for the LuaRocks tools.
|
||||
-- This is the entry point for the LuaRocks tools.
|
||||
-- Only the LuaRocks runtime loader should use
|
||||
-- load_local_rockspec directly.
|
||||
-- @param filename string: Local or remote filename of a rockspec.
|
||||
|
@ -425,7 +425,7 @@ function fetch.fetch_sources(rockspec, extract, dest_dir)
|
|||
return nil, "Unknown protocol "..protocol
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if cfg.only_sources_from
|
||||
and rockspec.source.pathname
|
||||
and #rockspec.source.pathname > 0 then
|
||||
|
|
|
@ -150,7 +150,7 @@ function git.get_sources(rockspec, extract, dest_dir, depth)
|
|||
return nil, 'Failed to fetch submodules.'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if not rockspec.source.tag then
|
||||
rockspec.source.identifier = git_identifier(git_cmd, rockspec.version)
|
||||
end
|
||||
|
|
|
@ -132,7 +132,7 @@ function fs_lua.is_tool_available(tool_cmd, tool_name, arg)
|
|||
|
||||
if ok then
|
||||
return true
|
||||
else
|
||||
else
|
||||
local msg = "'%s' program not found. Make sure %s is installed and is available in your PATH " ..
|
||||
"(or you may want to edit the 'variables.%s' value in file '%s')"
|
||||
return nil, msg:format(tool_cmd, tool_name, tool_name:upper(), cfg.config_files.nearest)
|
||||
|
@ -535,7 +535,7 @@ end
|
|||
--- Internal implementation function for fs.dir.
|
||||
-- Yields a filename on each iteration.
|
||||
-- @param at string: directory to list
|
||||
-- @return nil or (nil and string): an error message on failure
|
||||
-- @return nil or (nil and string): an error message on failure
|
||||
function fs_lua.dir_iterator(at)
|
||||
local pok, iter, arg = pcall(lfs.dir, at)
|
||||
if not pok then
|
||||
|
@ -707,7 +707,7 @@ local redirect_protocols = {
|
|||
|
||||
local function request(url, method, http, loop_control) -- luacheck: ignore 431
|
||||
local result = {}
|
||||
|
||||
|
||||
if cfg.verbose then
|
||||
print(method, url)
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ local dir_stack = {}
|
|||
|
||||
do
|
||||
local tool_cache = {}
|
||||
|
||||
|
||||
local tool_options = {
|
||||
downloader = {
|
||||
desc = "downloader",
|
||||
|
@ -147,7 +147,7 @@ function tools.use_downloader(url, filename, cache)
|
|||
assert(type(filename) == "string" or not filename)
|
||||
|
||||
filename = fs.absolute_name(filename or dir.base_name(url))
|
||||
|
||||
|
||||
local downloader, err = fs.which_tool("downloader")
|
||||
if not downloader then
|
||||
return nil, err
|
||||
|
|
|
@ -76,7 +76,7 @@ function unix.wrap_script(script, target, deps_mode, name, version, ...)
|
|||
assert(type(deps_mode) == "string")
|
||||
assert(type(name) == "string" or not name)
|
||||
assert(type(version) == "string" or not version)
|
||||
|
||||
|
||||
local wrapper = io.open(target, "w")
|
||||
if not wrapper then
|
||||
return nil, "Could not open "..target.." for writing."
|
||||
|
@ -153,7 +153,7 @@ function unix.is_actual_binary(filename)
|
|||
return first ~= "#!"
|
||||
end
|
||||
|
||||
function unix.copy_binary(filename, dest)
|
||||
function unix.copy_binary(filename, dest)
|
||||
return fs.copy(filename, dest, "exec")
|
||||
end
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ end
|
|||
--- Copy a file.
|
||||
-- @param src string: Pathname of source
|
||||
-- @param dest string: Pathname of destination
|
||||
-- @param perm string ("read" or "exec") or nil: Permissions for destination
|
||||
-- @param perm string ("read" or "exec") or nil: Permissions for destination
|
||||
-- file or nil to use the source permissions
|
||||
-- @return boolean or (boolean, string): true on success, false on failure,
|
||||
-- plus an error message.
|
||||
|
|
|
@ -217,7 +217,7 @@ function win32.is_actual_binary(name)
|
|||
return false
|
||||
end
|
||||
|
||||
function win32.copy_binary(filename, dest)
|
||||
function win32.copy_binary(filename, dest)
|
||||
local ok, err = fs.copy(filename, dest)
|
||||
if not ok then
|
||||
return nil, err
|
||||
|
|
|
@ -110,7 +110,7 @@ function manif.load_manifest(repo_url, lua_version, versioned_only)
|
|||
break
|
||||
end
|
||||
end
|
||||
if not pathname then
|
||||
if not pathname then
|
||||
return nil, err, errcode
|
||||
end
|
||||
end
|
||||
|
@ -236,7 +236,7 @@ end
|
|||
function manif.get_versions(dep, deps_mode)
|
||||
assert(type(dep) == "table")
|
||||
assert(type(deps_mode) == "string")
|
||||
|
||||
|
||||
local name = dep.name
|
||||
local namespace = dep.namespace
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ end
|
|||
local function update_dependencies(manifest, deps_mode)
|
||||
assert(type(manifest) == "table")
|
||||
assert(type(deps_mode) == "string")
|
||||
|
||||
|
||||
for pkg, versions in pairs(manifest.repository) do
|
||||
for version, repositories in pairs(versions) do
|
||||
for _, repo in ipairs(repositories) do
|
||||
|
@ -160,7 +160,7 @@ local function filter_by_lua_version(manifest, lua_version, repodir, cache)
|
|||
assert(type(manifest) == "table")
|
||||
assert(type(repodir) == "string")
|
||||
assert((not cache) or type(cache) == "table")
|
||||
|
||||
|
||||
cache = cache or {}
|
||||
lua_version = vers.parse_version(lua_version)
|
||||
for pkg, versions in pairs(manifest.repository) do
|
||||
|
@ -176,7 +176,7 @@ local function filter_by_lua_version(manifest, lua_version, repodir, cache)
|
|||
if rockspec then
|
||||
cache[pathname] = rockspec
|
||||
for _, dep in ipairs(rockspec.dependencies) do
|
||||
if dep.name == "lua" then
|
||||
if dep.name == "lua" then
|
||||
if not vers.match_constraints(lua_version, dep.constraints) then
|
||||
table.insert(to_remove, version)
|
||||
end
|
||||
|
|
|
@ -91,13 +91,13 @@ function pack.pack_installed_rock(query, tree)
|
|||
if not fs.exists(prefix) then
|
||||
return nil, "'"..name.." "..version.."' does not seem to be an installed rock."
|
||||
end
|
||||
|
||||
|
||||
local rock_manifest, err = manif.load_rock_manifest(name, version, root)
|
||||
if not rock_manifest then return nil, err end
|
||||
|
||||
local name_version = name .. "-" .. version
|
||||
local rock_file = fs.absolute_name(name_version .. "."..cfg.arch..".rock")
|
||||
|
||||
|
||||
local temp_dir = fs.make_temp_dir("pack")
|
||||
fs.copy_contents(prefix, temp_dir)
|
||||
|
||||
|
@ -111,7 +111,7 @@ function pack.pack_installed_rock(query, tree)
|
|||
local ok, err = copy_back_files(name, version, rock_manifest.lua, path.deploy_lua_dir(repo), dir.path(temp_dir, "lua"), "read")
|
||||
if not ok then return nil, "Failed copying back files: " .. err end
|
||||
end
|
||||
|
||||
|
||||
local ok, err = fs.change_dir(temp_dir)
|
||||
if not ok then return nil, err end
|
||||
if not is_binary and not repos.has_binaries(name, version) then
|
||||
|
|
|
@ -49,7 +49,7 @@ function path.manifest_file(tree)
|
|||
end
|
||||
|
||||
--- Get the directory for all versions of a package in a tree.
|
||||
-- @param name string: The package name.
|
||||
-- @param name string: The package name.
|
||||
-- @return string: The resulting path -- does not guarantee that
|
||||
-- @param tree string or nil: If given, specifies the local tree to use.
|
||||
-- the package (and by extension, the path) exists.
|
||||
|
@ -59,7 +59,7 @@ function path.versions_dir(name, tree)
|
|||
end
|
||||
|
||||
--- Get the local installation directory (prefix) for a package.
|
||||
-- @param name string: The package name.
|
||||
-- @param name string: The package name.
|
||||
-- @param version string: The package version.
|
||||
-- @param tree string or nil: If given, specifies the local tree to use.
|
||||
-- @return string: The resulting path -- does not guarantee that
|
||||
|
@ -71,7 +71,7 @@ function path.install_dir(name, version, tree)
|
|||
end
|
||||
|
||||
--- Get the local filename of the rockspec of an installed rock.
|
||||
-- @param name string: The package name.
|
||||
-- @param name string: The package name.
|
||||
-- @param version string: The package version.
|
||||
-- @param tree string or nil: If given, specifies the local tree to use.
|
||||
-- @return string: The resulting path -- does not guarantee that
|
||||
|
@ -83,7 +83,7 @@ function path.rockspec_file(name, version, tree)
|
|||
end
|
||||
|
||||
--- Get the local filename of the rock_manifest file of an installed rock.
|
||||
-- @param name string: The package name.
|
||||
-- @param name string: The package name.
|
||||
-- @param version string: The package version.
|
||||
-- @param tree string or nil: If given, specifies the local tree to use.
|
||||
-- @return string: The resulting path -- does not guarantee that
|
||||
|
@ -107,7 +107,7 @@ function path.rock_namespace_file(name, version, tree)
|
|||
end
|
||||
|
||||
--- Get the local installation directory for C libraries of a package.
|
||||
-- @param name string: The package name.
|
||||
-- @param name string: The package name.
|
||||
-- @param version string: The package version.
|
||||
-- @param tree string or nil: If given, specifies the local tree to use.
|
||||
-- @return string: The resulting path -- does not guarantee that
|
||||
|
@ -119,7 +119,7 @@ function path.lib_dir(name, version, tree)
|
|||
end
|
||||
|
||||
--- Get the local installation directory for Lua modules of a package.
|
||||
-- @param name string: The package name.
|
||||
-- @param name string: The package name.
|
||||
-- @param version string: The package version.
|
||||
-- @param tree string or nil: If given, specifies the local tree to use.
|
||||
-- @return string: The resulting path -- does not guarantee that
|
||||
|
@ -131,7 +131,7 @@ function path.lua_dir(name, version, tree)
|
|||
end
|
||||
|
||||
--- Get the local installation directory for documentation of a package.
|
||||
-- @param name string: The package name.
|
||||
-- @param name string: The package name.
|
||||
-- @param version string: The package version.
|
||||
-- @param tree string or nil: If given, specifies the local tree to use.
|
||||
-- @return string: The resulting path -- does not guarantee that
|
||||
|
@ -143,7 +143,7 @@ function path.doc_dir(name, version, tree)
|
|||
end
|
||||
|
||||
--- Get the local installation directory for configuration files of a package.
|
||||
-- @param name string: The package name.
|
||||
-- @param name string: The package name.
|
||||
-- @param version string: The package version.
|
||||
-- @param tree string or nil: If given, specifies the local tree to use.
|
||||
-- @return string: The resulting path -- does not guarantee that
|
||||
|
@ -156,7 +156,7 @@ end
|
|||
|
||||
--- Get the local installation directory for command-line scripts
|
||||
-- of a package.
|
||||
-- @param name string: The package name.
|
||||
-- @param name string: The package name.
|
||||
-- @param version string: The package version.
|
||||
-- @param tree string or nil: If given, specifies the local tree to use.
|
||||
-- @return string: The resulting path -- does not guarantee that
|
||||
|
|
|
@ -85,7 +85,7 @@ local function write_table_key_assignment(out, k, level)
|
|||
persist.write_value(out, k, level)
|
||||
out:write("]")
|
||||
end
|
||||
|
||||
|
||||
out:write(" = ")
|
||||
end
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ function queries.new(name, namespace, version, substring, arch, operator)
|
|||
assert(type(substring) == "boolean" or not substring)
|
||||
assert(type(arch) == "string" or not arch)
|
||||
assert(type(operator) == "string" or not operator)
|
||||
|
||||
|
||||
operator = operator or "=="
|
||||
|
||||
local self = {
|
||||
|
@ -99,7 +99,7 @@ do
|
|||
["="] = "==",
|
||||
["!="] = "~="
|
||||
}
|
||||
|
||||
|
||||
--- Consumes a constraint from a string, converting it to table format.
|
||||
-- For example, a string ">= 1.0, > 2.0" is converted to a table in the
|
||||
-- format {op = ">=", version={1,0}} and the rest, "> 2.0", is returned
|
||||
|
@ -110,20 +110,20 @@ do
|
|||
-- input string is invalid.
|
||||
parse_constraint = function(input)
|
||||
assert(type(input) == "string")
|
||||
|
||||
|
||||
local no_upgrade, op, version, rest = input:match("^(@?)([<>=~!]*)%s*([%w%.%_%-]+)[%s,]*(.*)")
|
||||
local _op = operators[op]
|
||||
version = vers.parse_version(version)
|
||||
if not _op then
|
||||
return nil, "Encountered bad constraint operator: '"..tostring(op).."' in '"..input.."'"
|
||||
end
|
||||
if not version then
|
||||
if not version then
|
||||
return nil, "Could not parse version from constraint: '"..input.."'"
|
||||
end
|
||||
return { op = _op, version = version, no_upgrade = no_upgrade=="@" and true or nil }, rest
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- Convert a list of constraints from string to table format.
|
||||
-- For example, a string ">= 1.0, < 2.0" is converted to a table in the format
|
||||
-- {{op = ">=", version={1,0}}, {op = "<", version={2,0}}}.
|
||||
|
@ -134,7 +134,7 @@ do
|
|||
-- or nil if the input string is invalid.
|
||||
parse_constraints = function(input)
|
||||
assert(type(input) == "string")
|
||||
|
||||
|
||||
local constraints, oinput, constraint = {}, input
|
||||
while #input > 0 do
|
||||
constraint, input = parse_constraint(input)
|
||||
|
@ -147,26 +147,26 @@ do
|
|||
return constraints
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- Prepare a query in dependency table format.
|
||||
-- @param depstr string: A dependency in string format
|
||||
-- as entered in rockspec files.
|
||||
-- @return table: A query in table format, or nil and an error message in case of errors.
|
||||
function queries.from_dep_string(depstr)
|
||||
assert(type(depstr) == "string")
|
||||
|
||||
|
||||
local ns_name, rest = depstr:match("^%s*([a-zA-Z0-9%.%-%_]*/?[a-zA-Z0-9][a-zA-Z0-9%.%-%_]*)%s*([^/]*)")
|
||||
if not ns_name then
|
||||
return nil, "failed to extract dependency name from '"..depstr.."'"
|
||||
end
|
||||
|
||||
|
||||
local constraints, err = parse_constraints(rest)
|
||||
if not constraints then
|
||||
return nil, err
|
||||
end
|
||||
|
||||
|
||||
local name, namespace = util.split_namespace(ns_name)
|
||||
|
||||
|
||||
local self = {
|
||||
name = name,
|
||||
namespace = namespace,
|
||||
|
|
|
@ -47,14 +47,14 @@ end
|
|||
-- "one" for the current default tree, "all" for all trees,
|
||||
-- "order" for all trees with priority >= the current default, "none" for no trees.
|
||||
-- @return boolean or (nil, string): true on success or nil and an error message.
|
||||
local function delete_versions(name, versions, deps_mode)
|
||||
local function delete_versions(name, versions, deps_mode)
|
||||
|
||||
for version, _ in pairs(versions) do
|
||||
util.printout("Removing "..name.." "..version.."...")
|
||||
local ok, err = repos.delete_version(name, version, deps_mode)
|
||||
if not ok then return nil, err end
|
||||
end
|
||||
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
@ -63,7 +63,7 @@ function remove.remove_search_results(results, name, deps_mode, force, fast)
|
|||
|
||||
local version = next(versions)
|
||||
local second = next(versions, version)
|
||||
|
||||
|
||||
local dependents = {}
|
||||
if not fast then
|
||||
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)
|
|||
util.printout()
|
||||
dependents = check_dependents(name, versions, deps_mode)
|
||||
end
|
||||
|
||||
|
||||
if #dependents > 0 then
|
||||
if force or fast then
|
||||
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)
|
|||
return nil, "Failed removing."
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local ok, err = delete_versions(name, versions, deps_mode)
|
||||
if not ok then return nil, err end
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ end
|
|||
-- versions of a package, or nil if none is available.
|
||||
local function get_installed_versions(name)
|
||||
assert(type(name) == "string" and not name:match("/"))
|
||||
|
||||
|
||||
local dirs = fs.list_dir(path.versions_dir(name))
|
||||
return (dirs and #dirs > 0) and dirs or nil
|
||||
end
|
||||
|
@ -61,7 +61,7 @@ end
|
|||
function repos.is_installed(name, version)
|
||||
assert(type(name) == "string" and not name:match("/"))
|
||||
assert(type(version) == "string")
|
||||
|
||||
|
||||
return fs.is_dir(path.install_dir(name, version))
|
||||
end
|
||||
|
||||
|
@ -172,11 +172,11 @@ function repos.run_hook(rockspec, hook_name)
|
|||
if not hooks then
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
if cfg.hooks_enabled == false then
|
||||
return nil, "This rockspec contains hooks, which are blocked by the 'hooks_enabled' setting in your LuaRocks configuration."
|
||||
end
|
||||
|
||||
|
||||
if not hooks.substituted_variables then
|
||||
util.variable_substitutions(hooks, rockspec.variables)
|
||||
hooks.substituted_variables = true
|
||||
|
@ -269,7 +269,7 @@ local function backup_existing(should_backup, target)
|
|||
repeat
|
||||
backup = backup.."~"
|
||||
until not fs.exists(backup) -- Slight race condition here, but shouldn't be a problem.
|
||||
|
||||
|
||||
util.warning(target.." is not tracked by this installation of LuaRocks. Moving it to "..backup)
|
||||
local move_ok, move_err = os.rename(target, backup)
|
||||
if not move_ok then
|
||||
|
@ -300,7 +300,7 @@ local function prepare_op_install()
|
|||
if not ok then
|
||||
return nil, err
|
||||
end
|
||||
|
||||
|
||||
local backup, err = backup_existing(op.backup, op.realdst or op.dst)
|
||||
if err then
|
||||
return nil, err
|
||||
|
@ -308,22 +308,22 @@ local function prepare_op_install()
|
|||
if backup then
|
||||
op.backup_file = backup
|
||||
end
|
||||
|
||||
|
||||
ok, err = op.fn(op.src, op.dst, op.backup)
|
||||
if not ok then
|
||||
return nil, err
|
||||
end
|
||||
|
||||
|
||||
rmdirs[dir.dir_name(op.src)] = true
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
local function done_op_install()
|
||||
for d, _ in pairs(rmdirs) do
|
||||
fs.remove_dir_tree_if_empty(d)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return op_install, done_op_install
|
||||
end
|
||||
|
||||
|
@ -361,7 +361,7 @@ end
|
|||
local function prepare_op_delete()
|
||||
local deletes = {}
|
||||
local rmdirs = {}
|
||||
|
||||
|
||||
local function done_op_delete()
|
||||
for _, f in ipairs(deletes) do
|
||||
os.remove(f)
|
||||
|
@ -377,12 +377,12 @@ local function prepare_op_delete()
|
|||
local suffix = check_suffix(op.name, op.suffix)
|
||||
op.name = op.name .. suffix
|
||||
end
|
||||
|
||||
|
||||
table.insert(deletes, op.name)
|
||||
|
||||
|
||||
rmdirs[dir.dir_name(op.name)] = true
|
||||
end
|
||||
|
||||
|
||||
return op_delete, done_op_delete
|
||||
end
|
||||
|
||||
|
@ -406,7 +406,7 @@ function repos.deploy_files(name, version, wrap_bin_scripts, deps_mode)
|
|||
|
||||
local rock_manifest, load_err = manif.load_rock_manifest(name, version)
|
||||
if not rock_manifest then return nil, load_err end
|
||||
|
||||
|
||||
local repo = cfg.root_dir
|
||||
local renames = {}
|
||||
local installs = {}
|
||||
|
@ -592,7 +592,7 @@ function repos.delete_version(name, version, deps_mode, quick)
|
|||
op_delete(op)
|
||||
end
|
||||
done_op_delete()
|
||||
|
||||
|
||||
if not quick then
|
||||
for _, op in ipairs(renames) do
|
||||
op_rename(op)
|
||||
|
|
|
@ -17,11 +17,11 @@ function results.new(name, version, repo, arch, namespace)
|
|||
assert(type(repo) == "string")
|
||||
assert(type(arch) == "string" or not arch)
|
||||
assert(type(namespace) == "string" or not namespace)
|
||||
|
||||
|
||||
if not namespace then
|
||||
name, namespace = util.split_namespace(name)
|
||||
end
|
||||
|
||||
|
||||
local self = {
|
||||
name = name,
|
||||
version = version,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
local rockspecs = {}
|
||||
|
||||
|
||||
local cfg = require("luarocks.core.cfg")
|
||||
local dir = require("luarocks.dir")
|
||||
local path = require("luarocks.path")
|
||||
|
@ -31,9 +31,9 @@ end
|
|||
-- if it doesn't (or if nil is passed), this function does nothing.
|
||||
local function platform_overrides(tbl)
|
||||
assert(type(tbl) == "table" or not tbl)
|
||||
|
||||
|
||||
if not tbl then return end
|
||||
|
||||
|
||||
if tbl.platforms then
|
||||
for platform in cfg.each_platform() do
|
||||
local platform_tbl = tbl.platforms[platform]
|
||||
|
@ -158,4 +158,4 @@ function rockspecs.from_persisted_table(filename, rockspec, globals, quick)
|
|||
return setmetatable(rockspec, rockspec_mt)
|
||||
end
|
||||
|
||||
return rockspecs
|
||||
return rockspecs
|
||||
|
|
|
@ -61,13 +61,13 @@ function search.disk_search(repo, query, result_tree)
|
|||
assert(type(repo) == "string")
|
||||
assert(query:type() == "query")
|
||||
assert(type(result_tree) == "table" or not result_tree)
|
||||
|
||||
|
||||
local fs = require("luarocks.fs")
|
||||
|
||||
|
||||
if not result_tree then
|
||||
result_tree = {}
|
||||
end
|
||||
|
||||
|
||||
for name in fs.dir(repo) do
|
||||
local pathname = dir.path(repo, name)
|
||||
local rname, rversion, rarch = path.parse_name(name)
|
||||
|
@ -231,13 +231,13 @@ function search.find_suitable_rock(query)
|
|||
assert(query:type() == "query")
|
||||
|
||||
local rocks_provided = util.get_rocks_provided()
|
||||
|
||||
|
||||
if rocks_provided[query.name] ~= nil then
|
||||
-- Do not install versions listed in rocks_provided.
|
||||
return nil, "Rock "..query.name.." "..rocks_provided[query.name]..
|
||||
" is already provided by VM or via 'rocks_provided' in the config file.", "provided"
|
||||
end
|
||||
|
||||
|
||||
local result_tree = search.search_repos(query)
|
||||
local first_rock = next(result_tree)
|
||||
if not first_rock then
|
||||
|
@ -270,19 +270,19 @@ function search.find_rock_checking_lua_versions(query, check_lua_versions)
|
|||
if check_lua_versions then
|
||||
util.printout(query.name .. " not found for Lua " .. cfg.lua_version .. ".")
|
||||
util.printout("Checking if available for other Lua versions...")
|
||||
|
||||
|
||||
-- Check if constraints are satisfiable with other Lua versions.
|
||||
local lua_versions = supported_lua_versions(query)
|
||||
|
||||
|
||||
if #lua_versions ~= 0 then
|
||||
-- Build a nice message in "only Lua 5.x and 5.y but not 5.z." format
|
||||
for i, lua_version in ipairs(lua_versions) do
|
||||
lua_versions[i] = "Lua "..lua_version
|
||||
end
|
||||
|
||||
|
||||
local versions_message = "only "..table.concat(lua_versions, " and ")..
|
||||
" but not Lua "..cfg.lua_version.."."
|
||||
|
||||
|
||||
if #query.constraints == 0 then
|
||||
add = query.name.." supports "..versions_message
|
||||
elseif #query.constraints == 1 and query.constraints[1].op == "==" then
|
||||
|
@ -308,7 +308,7 @@ end
|
|||
function search.print_result_tree(result_tree, porcelain)
|
||||
assert(type(result_tree) == "table")
|
||||
assert(type(porcelain) == "boolean" or not porcelain)
|
||||
|
||||
|
||||
if porcelain then
|
||||
for package, versions in util.sortedpairs(result_tree) do
|
||||
for version, repos in util.sortedpairs(versions, vers.compare_versions) do
|
||||
|
@ -320,7 +320,7 @@ function search.print_result_tree(result_tree, porcelain)
|
|||
end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
for package, versions in util.sortedpairs(result_tree) do
|
||||
local namespaces = {}
|
||||
for version, repos in util.sortedpairs(versions, vers.compare_versions) do
|
||||
|
|
|
@ -22,7 +22,7 @@ function signing.sign_file(file)
|
|||
if not gpg then
|
||||
return nil, err
|
||||
end
|
||||
|
||||
|
||||
local sigfile = file .. ".asc"
|
||||
if fs.execute(gpg, "--armor", "--output", sigfile, "--detach-sign", file) then
|
||||
return sigfile
|
||||
|
|
|
@ -22,13 +22,13 @@ local function get_test_type(rockspec)
|
|||
if rockspec.test and rockspec.test.type then
|
||||
return rockspec.test.type
|
||||
end
|
||||
|
||||
|
||||
for _, test_module in ipairs(test_modules) do
|
||||
if test_module.detect_type() then
|
||||
return test_modules[test_module]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return nil, "could not detect test type -- no test suite for " .. rockspec.package .. "?"
|
||||
end
|
||||
|
||||
|
@ -45,7 +45,7 @@ function test.run_test_suite(rockspec_arg, test_type, args)
|
|||
assert(type(rockspec_arg) == "table")
|
||||
rockspec = rockspec_arg
|
||||
end
|
||||
|
||||
|
||||
if not test_type then
|
||||
local err
|
||||
test_type, err = get_test_type(rockspec, test_type)
|
||||
|
@ -67,7 +67,7 @@ function test.run_test_suite(rockspec_arg, test_type, args)
|
|||
if not pok then
|
||||
return nil, "failed loading test execution module " .. mod_name
|
||||
end
|
||||
|
||||
|
||||
return test_mod.run_tests(rockspec.test, args)
|
||||
end
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ function command.run_tests(test, args)
|
|||
script = "test.lua"
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
if not test.script and not test.command then
|
||||
test.script = "test.lua"
|
||||
end
|
||||
|
@ -31,7 +31,7 @@ function command.run_tests(test, args)
|
|||
table.insert(args, i, test.flags[i])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local ok
|
||||
|
||||
if test.script then
|
||||
|
|
|
@ -114,7 +114,7 @@ local function file_lines(f)
|
|||
pos_beg = pos + 1
|
||||
if #line > 0 then
|
||||
return line
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -526,7 +526,7 @@ local function patch_hunks(srcname, tgtname, hunks)
|
|||
tgt:close()
|
||||
src:close()
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
local function strip_dirs(filename, strip)
|
||||
if strip == nil then return filename end
|
||||
|
@ -616,7 +616,7 @@ local function patch_file(source, target, epoch, hunks, strip, create_delete)
|
|||
end
|
||||
end
|
||||
hunklineno = 1
|
||||
|
||||
|
||||
-- todo \ No newline at end of file
|
||||
end
|
||||
-- check hunks in source file
|
||||
|
|
|
@ -30,7 +30,7 @@ local function octal_to_number(octal)
|
|||
local number = 0
|
||||
octal = octal:gsub("%s", "")
|
||||
for i = #octal,1,-1 do
|
||||
local digit = tonumber(octal:sub(i,i))
|
||||
local digit = tonumber(octal:sub(i,i))
|
||||
if not digit then
|
||||
break
|
||||
end
|
||||
|
@ -93,7 +93,7 @@ function tar.untar(filename, destdir)
|
|||
|
||||
local tar_handle = io.open(filename, "rb")
|
||||
if not tar_handle then return nil, "Error opening file "..filename end
|
||||
|
||||
|
||||
local long_name, long_link_name
|
||||
local ok, err
|
||||
local make_dir = fun.memoize(fs.make_dir)
|
||||
|
|
|
@ -129,7 +129,7 @@ end
|
|||
-- @return true if succeeded, nil in case of failure.
|
||||
local function zipwriter_close_file_in_zip(self)
|
||||
local zh = self.ziphandle
|
||||
|
||||
|
||||
if not self.in_open_file then
|
||||
return nil
|
||||
end
|
||||
|
@ -152,16 +152,16 @@ local function zipwriter_close_file_in_zip(self)
|
|||
|
||||
-- File data
|
||||
zh:write(self.data)
|
||||
|
||||
|
||||
-- Data descriptor
|
||||
zh:write(DATA_DESCRIPTOR_SIGNATURE)
|
||||
zh:write(number_to_lestring(lfh.crc32, 4))
|
||||
zh:write(number_to_lestring(lfh.compressed_size, 4))
|
||||
zh:write(number_to_lestring(lfh.uncompressed_size, 4))
|
||||
|
||||
|
||||
table.insert(self.files, lfh)
|
||||
self.in_open_file = false
|
||||
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
@ -208,9 +208,9 @@ end
|
|||
-- @return true if succeeded, nil in case of failure.
|
||||
local function zipwriter_close(self)
|
||||
local zh = self.ziphandle
|
||||
|
||||
|
||||
local central_directory_offset = zh:seek()
|
||||
|
||||
|
||||
local size_of_central_directory = 0
|
||||
-- Central directory structure
|
||||
for _, lfh in ipairs(self.files) do
|
||||
|
@ -234,7 +234,7 @@ local function zipwriter_close(self)
|
|||
zh:write(lfh.file_name)
|
||||
size_of_central_directory = size_of_central_directory + 46 + lfh.file_name_length
|
||||
end
|
||||
|
||||
|
||||
-- End of central directory record
|
||||
zh:write(END_OF_CENTRAL_DIR_SIGNATURE) -- signature
|
||||
zh:write(number_to_lestring(0, 2)) -- number of this disk
|
||||
|
@ -253,16 +253,16 @@ end
|
|||
-- @param name filename of the zipfile to be created.
|
||||
-- @return a zip handle, or nil in case of error.
|
||||
function zip.new_zipwriter(name)
|
||||
|
||||
|
||||
local zw = {}
|
||||
|
||||
|
||||
zw.ziphandle = io.open(fs.absolute_name(name), "wb")
|
||||
if not zw.ziphandle then
|
||||
return nil
|
||||
end
|
||||
zw.files = {}
|
||||
zw.in_open_file = false
|
||||
|
||||
|
||||
zw.add = zipwriter_add
|
||||
zw.close = zipwriter_close
|
||||
zw.open_new_file_in_zip = zipwriter_open_new_file_in_zip
|
||||
|
@ -381,7 +381,7 @@ local function process_end_of_central_dir(zh)
|
|||
return nil, "Could not find End of Central Directory signature"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- number of this disk (2 bytes)
|
||||
-- number of the disk with the start of the central directory (2 bytes)
|
||||
-- total number of entries in the central directory on this disk (2 bytes)
|
||||
|
@ -450,7 +450,7 @@ function zip.unzip(zipfile)
|
|||
if not cd_entries then
|
||||
return nil, cd_offset
|
||||
end
|
||||
|
||||
|
||||
local ok, err = zh:seek("set", cd_offset)
|
||||
if not ok then
|
||||
return nil, err
|
||||
|
@ -513,7 +513,7 @@ end
|
|||
function zip.gzip(input_filename, output_filename)
|
||||
assert(type(input_filename) == "string")
|
||||
assert(output_filename == nil or type(output_filename) == "string")
|
||||
|
||||
|
||||
if not output_filename then
|
||||
output_filename = input_filename .. ".gz"
|
||||
end
|
||||
|
@ -525,7 +525,7 @@ end
|
|||
function zip.gunzip(input_filename, output_filename)
|
||||
assert(type(input_filename) == "string")
|
||||
assert(output_filename == nil or type(output_filename) == "string")
|
||||
|
||||
|
||||
if not output_filename then
|
||||
output_filename = input_filename:gsub("%.gz$", "")
|
||||
end
|
||||
|
|
|
@ -64,7 +64,7 @@ local manifest_formats = type_check.declare_schemas({
|
|||
})
|
||||
|
||||
--- Type check a manifest table.
|
||||
-- Verify the correctness of elements from a
|
||||
-- Verify the correctness of elements from a
|
||||
-- manifest table, reporting on unknown fields and type
|
||||
-- mismatches.
|
||||
-- @return boolean or (nil, string): true if type checking
|
||||
|
|
|
@ -89,13 +89,13 @@ local rockspec_formats, versions = type_check.declare_schemas({
|
|||
post_install = { _type = "string" },
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
["1.1"] = {
|
||||
deploy = {
|
||||
wrap_bin_scripts = { _type = "boolean" },
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
["3.0"] = {
|
||||
description = {
|
||||
labels = {
|
||||
|
@ -135,7 +135,7 @@ local rockspec_formats, versions = type_check.declare_schemas({
|
|||
}
|
||||
})
|
||||
|
||||
type_rockspec.order = {"rockspec_format", "package", "version",
|
||||
type_rockspec.order = {"rockspec_format", "package", "version",
|
||||
{ "source", { "url", "tag", "branch", "md5" } },
|
||||
{ "description", {"summary", "detailed", "homepage", "license" } },
|
||||
"supported_platforms", "dependencies", "build_dependencies", "external_dependencies",
|
||||
|
@ -160,7 +160,7 @@ local function check_rockspec_using_version(rockspec, globals, version)
|
|||
end
|
||||
|
||||
--- Type check a rockspec table.
|
||||
-- Verify the correctness of elements from a
|
||||
-- Verify the correctness of elements from a
|
||||
-- rockspec table, reporting on unknown fields and type
|
||||
-- mismatches.
|
||||
-- @return boolean or (nil, string): true if type checking
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue