From 1dcdaa77c0a52ad02f49bc7fdde2fd7dee956ddf Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 7 May 2018 11:22:07 -0300 Subject: Tests: test the "busted" backend of `luarocks test` with a local fixture --- spec/fixtures/a_repo/busted_project-0.1-1.rockspec | 19 +++++++++++++++++++ spec/fixtures/a_repo/busted_project-0.1-1.src.rock | Bin 0 -> 937 bytes spec/fixtures/a_repo/manifest | 10 ++++++++++ spec/fixtures/a_repo/manifest-5.1 | 10 ++++++++++ spec/fixtures/a_repo/manifest-5.1.zip | Bin 0 -> 350 bytes spec/fixtures/a_repo/manifest-5.2 | 10 ++++++++++ spec/fixtures/a_repo/manifest-5.2.zip | Bin 0 -> 350 bytes spec/fixtures/a_repo/manifest-5.3 | 10 ++++++++++ spec/fixtures/a_repo/manifest-5.3.zip | Bin 0 -> 350 bytes spec/fixtures/busted_project-0.1-1.rockspec | 19 +++++++++++++++++++ spec/fixtures/busted_project-0.1.tar.gz | Bin 0 -> 345 bytes spec/test_spec.lua | 13 +++++++------ spec/util/mock-server.lua | 2 +- spec/util/test_env.lua | 6 ++---- 14 files changed, 88 insertions(+), 11 deletions(-) create mode 100644 spec/fixtures/a_repo/busted_project-0.1-1.rockspec create mode 100644 spec/fixtures/a_repo/busted_project-0.1-1.src.rock create mode 100644 spec/fixtures/a_repo/manifest-5.1.zip create mode 100644 spec/fixtures/a_repo/manifest-5.2.zip create mode 100644 spec/fixtures/a_repo/manifest-5.3.zip create mode 100644 spec/fixtures/busted_project-0.1-1.rockspec create mode 100644 spec/fixtures/busted_project-0.1.tar.gz (limited to 'spec') diff --git a/spec/fixtures/a_repo/busted_project-0.1-1.rockspec b/spec/fixtures/a_repo/busted_project-0.1-1.rockspec new file mode 100644 index 00000000..54ed28a5 --- /dev/null +++ b/spec/fixtures/a_repo/busted_project-0.1-1.rockspec @@ -0,0 +1,19 @@ +rockspec_format = "3.0" +package = "busted_project" +version = "0.1-1" +source = { + url = "http://localhost:8080/file/busted_project-0.1.tar.gz", + dir = "busted_project", +} +description = { + summary = "A project that uses Busted tests", +} +build = { + type = "builtin", + modules = { + sum = "sum.lua", + } +} +test = { + type = "busted", +} diff --git a/spec/fixtures/a_repo/busted_project-0.1-1.src.rock b/spec/fixtures/a_repo/busted_project-0.1-1.src.rock new file mode 100644 index 00000000..db924117 Binary files /dev/null and b/spec/fixtures/a_repo/busted_project-0.1-1.src.rock differ diff --git a/spec/fixtures/a_repo/manifest b/spec/fixtures/a_repo/manifest index 1a5f8d55..3b01b427 100644 --- a/spec/fixtures/a_repo/manifest +++ b/spec/fixtures/a_repo/manifest @@ -21,6 +21,16 @@ repository = { } } }, + busted_project = { + ["0.1-1"] = { + { + arch = "src" + }, + { + arch = "rockspec" + } + } + }, has_another_namespaced_dep = { ["1.0-1"] = { { diff --git a/spec/fixtures/a_repo/manifest-5.1 b/spec/fixtures/a_repo/manifest-5.1 index 1a5f8d55..3b01b427 100644 --- a/spec/fixtures/a_repo/manifest-5.1 +++ b/spec/fixtures/a_repo/manifest-5.1 @@ -21,6 +21,16 @@ repository = { } } }, + busted_project = { + ["0.1-1"] = { + { + arch = "src" + }, + { + arch = "rockspec" + } + } + }, has_another_namespaced_dep = { ["1.0-1"] = { { diff --git a/spec/fixtures/a_repo/manifest-5.1.zip b/spec/fixtures/a_repo/manifest-5.1.zip new file mode 100644 index 00000000..7b53aeb0 Binary files /dev/null and b/spec/fixtures/a_repo/manifest-5.1.zip differ diff --git a/spec/fixtures/a_repo/manifest-5.2 b/spec/fixtures/a_repo/manifest-5.2 index 1a5f8d55..3b01b427 100644 --- a/spec/fixtures/a_repo/manifest-5.2 +++ b/spec/fixtures/a_repo/manifest-5.2 @@ -21,6 +21,16 @@ repository = { } } }, + busted_project = { + ["0.1-1"] = { + { + arch = "src" + }, + { + arch = "rockspec" + } + } + }, has_another_namespaced_dep = { ["1.0-1"] = { { diff --git a/spec/fixtures/a_repo/manifest-5.2.zip b/spec/fixtures/a_repo/manifest-5.2.zip new file mode 100644 index 00000000..d2eddc40 Binary files /dev/null and b/spec/fixtures/a_repo/manifest-5.2.zip differ diff --git a/spec/fixtures/a_repo/manifest-5.3 b/spec/fixtures/a_repo/manifest-5.3 index 1a5f8d55..3b01b427 100644 --- a/spec/fixtures/a_repo/manifest-5.3 +++ b/spec/fixtures/a_repo/manifest-5.3 @@ -21,6 +21,16 @@ repository = { } } }, + busted_project = { + ["0.1-1"] = { + { + arch = "src" + }, + { + arch = "rockspec" + } + } + }, has_another_namespaced_dep = { ["1.0-1"] = { { diff --git a/spec/fixtures/a_repo/manifest-5.3.zip b/spec/fixtures/a_repo/manifest-5.3.zip new file mode 100644 index 00000000..686fe232 Binary files /dev/null and b/spec/fixtures/a_repo/manifest-5.3.zip differ diff --git a/spec/fixtures/busted_project-0.1-1.rockspec b/spec/fixtures/busted_project-0.1-1.rockspec new file mode 100644 index 00000000..54ed28a5 --- /dev/null +++ b/spec/fixtures/busted_project-0.1-1.rockspec @@ -0,0 +1,19 @@ +rockspec_format = "3.0" +package = "busted_project" +version = "0.1-1" +source = { + url = "http://localhost:8080/file/busted_project-0.1.tar.gz", + dir = "busted_project", +} +description = { + summary = "A project that uses Busted tests", +} +build = { + type = "builtin", + modules = { + sum = "sum.lua", + } +} +test = { + type = "busted", +} diff --git a/spec/fixtures/busted_project-0.1.tar.gz b/spec/fixtures/busted_project-0.1.tar.gz new file mode 100644 index 00000000..bd4e055b Binary files /dev/null and b/spec/fixtures/busted_project-0.1.tar.gz differ diff --git a/spec/test_spec.lua b/spec/test_spec.lua index f0ec25ce..a2e1989d 100644 --- a/spec/test_spec.lua +++ b/spec/test_spec.lua @@ -39,16 +39,17 @@ describe("luarocks test #blackbox #b_test", function() finally(function() -- delete downloaded and unpacked files lfs.chdir(testing_paths.testrun_dir) - test_env.remove_dir("luassert-1.7.10-0") - os.remove("luassert-1.7.10-0.rockspec") + 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 --rockspec luassert 1.7.10-0")) - assert.is_true(run.luarocks_bool("unpack luassert-1.7.10-0.rockspec")) - lfs.chdir("luassert-1.7.10-0/luassert-1.7.10/") + 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")) + lfs.chdir("busted_project-0.1-1/busted_project") assert.is_true(run.luarocks_bool("make")) - local output = run.luarocks("test --test-type=busted luassert-1.7.10-0.rockspec") + local output = run.luarocks("test") + print(output) -- Assert that busted ran, whether successfully or not assert.match("%d+ success.* / %d+ failure.* / %d+ error.* / %d+ pending", output) end) diff --git a/spec/util/mock-server.lua b/spec/util/mock-server.lua index 9b510d3b..ae41b964 100644 --- a/spec/util/mock-server.lua +++ b/spec/util/mock-server.lua @@ -70,7 +70,7 @@ server:add_resource("/file/{name:[^/]+}", { path = "/", produces = "text/plain", handler = function(query, name) - local basedir = arg[1] or "." + local basedir = arg[1] or "./spec/fixtures" local fd = io.open(basedir .. "/" .. name, "r") if not fd then return restserver.response():status(404) diff --git a/spec/util/test_env.lua b/spec/util/test_env.lua index 7b5b66b9..f55fb53a 100644 --- a/spec/util/test_env.lua +++ b/spec/util/test_env.lua @@ -506,6 +506,7 @@ local function create_paths(luaversion_full) end testing_paths.fixtures_dir = base_dir .. "/spec/fixtures" + testing_paths.fixtures_repo_dir = base_dir .. "/spec/fixtures/a_repo" testing_paths.util_dir = base_dir .. "/spec/util" testing_paths.testrun_dir = base_dir .. "/testrun" testing_paths.src_dir = base_dir .. "/src" @@ -763,12 +764,9 @@ end function test_env.mock_server_init() local testing_paths = test_env.testing_paths assert(test_env.need_rock("restserver-xavante")) - local pwd = lfs.currentdir() - lfs.chdir(testing_paths.fixtures_dir) - local final_command = test_env.execute_helper(testing_paths.lua .. " " .. testing_paths.util_dir .. "/mock-server.lua &", true, test_env.env_variables) + local final_command = test_env.execute_helper(testing_paths.lua .. " " .. testing_paths.util_dir .. "/mock-server.lua " .. testing_paths.fixtures_dir .. " &", true, test_env.env_variables) os.execute(final_command) os.execute("sleep 1") - lfs.chdir(pwd) end function test_env.mock_server_done() -- cgit v1.2.3-55-g6feb