From 8f3ce333e7a1abfc6bf0488817d9eff4a2fd443f Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Tue, 16 Mar 2021 13:36:26 -0300 Subject: editorconfig: trim trailing whitespace --- spec/add_spec.lua | 8 +-- spec/build_spec.lua | 50 +++++++-------- spec/cmd_spec.lua | 2 +- spec/config_spec.lua | 32 +++++----- spec/deps_spec.lua | 4 +- spec/dir_spec.lua | 6 +- spec/doc_spec.lua | 8 +-- spec/download_spec.lua | 2 +- spec/fetch_spec.lua | 108 ++++++++++++++++---------------- spec/fs_spec.lua | 142 +++++++++++++++++++++---------------------- spec/fun_spec.lua | 6 +- spec/help_spec.lua | 4 +- spec/init_spec.lua | 20 +++--- spec/install_spec.lua | 14 ++--- spec/lint_spec.lua | 19 +++--- spec/list_spec.lua | 2 +- spec/make_spec.lua | 22 +++---- spec/new_version_spec.lua | 6 +- spec/pack_spec.lua | 6 +- spec/path_spec.lua | 12 ++-- spec/persist_spec.lua | 6 +- spec/remove_spec.lua | 10 +-- spec/search_spec.lua | 8 +-- spec/show_spec.lua | 20 +++--- spec/sysdetect_spec.lua | 4 +- spec/test_spec.lua | 64 +++++++++---------- spec/tools_spec.lua | 50 +++++++-------- spec/unpack_spec.lua | 10 +-- spec/upload_spec.lua | 8 +-- spec/util/mock-server.lua | 2 +- spec/util/test_env.lua | 28 ++++----- spec/util_spec.lua | 22 +++---- spec/which_spec.lua | 2 +- spec/write_rockspec_spec.lua | 12 ++-- 34 files changed, 359 insertions(+), 360 deletions(-) (limited to 'spec') diff --git a/spec/add_spec.lua b/spec/add_spec.lua index b0b3a171..ea6274ba 100644 --- a/spec/add_spec.lua +++ b/spec/add_spec.lua @@ -23,20 +23,20 @@ describe("LuaRocks add tests #integration", function() 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) diff --git a/spec/build_spec.lua b/spec/build_spec.lua index 7d18ae4c..7dc4af03 100644 --- a/spec/build_spec.lua +++ b/spec/build_spec.lua @@ -55,7 +55,7 @@ describe("LuaRocks build #integration", function() 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() diff --git a/spec/cmd_spec.lua b/spec/cmd_spec.lua index ad6ae7ad..d28acdf6 100644 --- a/spec/cmd_spec.lua +++ b/spec/cmd_spec.lua @@ -5,7 +5,7 @@ local run = test_env.run test_env.unload_luarocks() describe("LuaRocks command line #integration", function() - + setup(function() test_env.setup_specs() end) diff --git a/spec/config_spec.lua b/spec/config_spec.lua index f4a793c4..a14b1ec0 100644 --- a/spec/config_spec.lua +++ b/spec/config_spec.lua @@ -9,7 +9,7 @@ local hardcoded 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")) diff --git a/spec/deps_spec.lua b/spec/deps_spec.lua index b677acc4..35fd8be5 100644 --- a/spec/deps_spec.lua +++ b/spec/deps_spec.lua @@ -22,7 +22,7 @@ describe("LuaRocks deps-mode #integration", function() 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")) diff --git a/spec/dir_spec.lua b/spec/dir_spec.lua index c5162b60..1b568c8f 100644 --- a/spec/dir_spec.lua +++ b/spec/dir_spec.lua @@ -7,17 +7,17 @@ local dir = require("luarocks.dir") 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")) diff --git a/spec/doc_spec.lua b/spec/doc_spec.lua index 19cfb26a..a10bb501 100644 --- a/spec/doc_spec.lua +++ b/spec/doc_spec.lua @@ -6,7 +6,7 @@ test_env.unload_luarocks() 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", [[ diff --git a/spec/download_spec.lua b/spec/download_spec.lua index 42f72008..823e154f 100644 --- a/spec/download_spec.lua +++ b/spec/download_spec.lua @@ -28,7 +28,7 @@ describe("luarocks download #integration", function() 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")) diff --git a/spec/fetch_spec.lua b/spec/fetch_spec.lua index 6e23a8f2..8194a298 100644 --- a/spec/fetch_spec.lua +++ b/spec/fetch_spec.lua @@ -17,9 +17,9 @@ describe("luarocks fetch #unit #mock", function() 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() diff --git a/spec/fs_spec.lua b/spec/fs_spec.lua index cc36d277..5410cff7 100644 --- a/spec/fs_spec.lua +++ b/spec/fs_spec.lua @@ -62,7 +62,7 @@ describe("luarocks.fs #unit", function() 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")) diff --git a/spec/fun_spec.lua b/spec/fun_spec.lua index b3589c12..9844ec27 100644 --- a/spec/fun_spec.lua +++ b/spec/fun_spec.lua @@ -6,17 +6,17 @@ local fun = require("luarocks.fun") 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 diff --git a/spec/help_spec.lua b/spec/help_spec.lua index 70dc5a7e..08ce87a9 100644 --- a/spec/help_spec.lua +++ b/spec/help_spec.lua @@ -16,11 +16,11 @@ describe("luarocks help #integration", function() 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) diff --git a/spec/init_spec.lua b/spec/init_spec.lua index 4a9c9ab7..3bde313a 100644 --- a/spec/init_spec.lua +++ b/spec/init_spec.lua @@ -19,7 +19,7 @@ describe("luarocks init #integration", function() 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) diff --git a/spec/install_spec.lua b/spec/install_spec.lua index 78b4b28d..9bc94eb6 100644 --- a/spec/install_spec.lua +++ b/spec/install_spec.lua @@ -46,7 +46,7 @@ describe("luarocks install #integration", function() 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() diff --git a/spec/lint_spec.lua b/spec/lint_spec.lua index 75774061..ff7a03e9 100644 --- a/spec/lint_spec.lua +++ b/spec/lint_spec.lua @@ -1,7 +1,6 @@ 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" diff --git a/spec/list_spec.lua b/spec/list_spec.lua index 20af7164..a3580094 100644 --- a/spec/list_spec.lua +++ b/spec/list_spec.lua @@ -37,7 +37,7 @@ describe("luarocks list #integration", function() 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)) diff --git a/spec/make_spec.lua b/spec/make_spec.lua index c9410cce..791eeb89 100644 --- a/spec/make_spec.lua +++ b/spec/make_spec.lua @@ -38,7 +38,7 @@ describe("luarocks make #integration", function() 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")) diff --git a/spec/new_version_spec.lua b/spec/new_version_spec.lua index 2f628242..830e4d11 100644 --- a/spec/new_version_spec.lua +++ b/spec/new_version_spec.lua @@ -15,7 +15,7 @@ describe("luarocks new_version #integration", function() 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")) diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua index a0b302a3..0790c801 100644 --- a/spec/pack_spec.lua +++ b/spec/pack_spec.lua @@ -35,7 +35,7 @@ describe("luarocks pack #integration", function() 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() diff --git a/spec/path_spec.lua b/spec/path_spec.lua index 7736741c..9b2a2854 100644 --- a/spec/path_spec.lua +++ b/spec/path_spec.lua @@ -16,7 +16,7 @@ describe("luarocks path #integration", function() 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)) diff --git a/spec/persist_spec.lua b/spec/persist_spec.lua index 722331b8..f426fd83 100644 --- a/spec/persist_spec.lua +++ b/spec/persist_spec.lua @@ -6,17 +6,17 @@ local persist = require("luarocks.persist") 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([[ diff --git a/spec/remove_spec.lua b/spec/remove_spec.lua index cdac5c01..91b6a460 100644 --- a/spec/remove_spec.lua +++ b/spec/remove_spec.lua @@ -26,11 +26,11 @@ describe("luarocks remove #integration", function() 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) diff --git a/spec/search_spec.lua b/spec/search_spec.lua index 1b5d79fa..bb6adf3e 100644 --- a/spec/search_spec.lua +++ b/spec/search_spec.lua @@ -8,7 +8,7 @@ local extra_rocks = { } 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) diff --git a/spec/show_spec.lua b/spec/show_spec.lua index e4937157..380c2441 100644 --- a/spec/show_spec.lua +++ b/spec/show_spec.lua @@ -5,7 +5,7 @@ local testing_paths = test_env.testing_paths 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) diff --git a/spec/sysdetect_spec.lua b/spec/sysdetect_spec.lua index 1e73d5d6..7f9cf1be 100644 --- a/spec/sysdetect_spec.lua +++ b/spec/sysdetect_spec.lua @@ -8,7 +8,7 @@ describe("luarocks.core.sysdetect #unix #unit", function() 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 diff --git a/spec/test_spec.lua b/spec/test_spec.lua index ddb64b0e..220ae632 100644 --- a/spec/test_spec.lua +++ b/spec/test_spec.lua @@ -17,7 +17,7 @@ local extra_rocks = { "/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) diff --git a/spec/tools_spec.lua b/spec/tools_spec.lua index c84dbab3..29e21740 100644 --- a/spec/tools_spec.lua +++ b/spec/tools_spec.lua @@ -8,7 +8,7 @@ local fs = require("luarocks.fs") 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) diff --git a/spec/unpack_spec.lua b/spec/unpack_spec.lua index 489e01e6..9b1e2b9a 100644 --- a/spec/unpack_spec.lua +++ b/spec/unpack_spec.lua @@ -11,7 +11,7 @@ local extra_rocks = { } 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")) diff --git a/spec/upload_spec.lua b/spec/upload_spec.lua index dc073c18..e1215d2c 100644 --- a/spec/upload_spec.lua +++ b/spec/upload_spec.lua @@ -17,15 +17,15 @@ describe("luarocks upload #integration", function() 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() diff --git a/spec/util/mock-server.lua b/spec/util/mock-server.lua index 8e498d57..1b09cd6b 100644 --- a/spec/util/mock-server.lua +++ b/spec/util/mock-server.lua @@ -95,4 +95,4 @@ server:add_resource("/shutdown", { }) -- This loads the restserver.xavante plugin -server:enable("restserver.xavante"):start() \ No newline at end of file +server:enable("restserver.xavante"):start() diff --git a/spec/util/test_env.lua b/spec/util/test_env.lua index 8aebd74e..1585adac 100644 --- a/spec/util/test_env.lua +++ b/spec/util/test_env.lua @@ -55,7 +55,7 @@ local function Q(arg) 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() diff --git a/spec/util_spec.lua b/spec/util_spec.lua index 3970a57c..5aa49b4c 100644 --- a/spec/util_spec.lua +++ b/spec/util_spec.lua @@ -33,7 +33,7 @@ describe("Basic tests #integration", function() 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' diff --git a/spec/which_spec.lua b/spec/which_spec.lua index 4e9bdaf4..d6e07eb7 100644 --- a/spec/which_spec.lua +++ b/spec/which_spec.lua @@ -13,7 +13,7 @@ local extra_rocks = { } 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 diff --git a/spec/write_rockspec_spec.lua b/spec/write_rockspec_spec.lua index 3031cf10..5f9faa6e 100644 --- a/spec/write_rockspec_spec.lua +++ b/spec/write_rockspec_spec.lua @@ -12,18 +12,18 @@ describe("luarocks write_rockspec tests #integration", function() 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\" " -- cgit v1.2.3-55-g6feb