diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2018-05-07 11:22:07 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-05-07 19:27:37 -0300 |
commit | 1dcdaa77c0a52ad02f49bc7fdde2fd7dee956ddf (patch) | |
tree | 30a6e8dbabc0e36b3a9ff25dfde2fa60327ae402 | |
parent | 5bff41c6b4adac49c0456f125c9f208b0a429d86 (diff) | |
download | luarocks-1dcdaa77c0a52ad02f49bc7fdde2fd7dee956ddf.tar.gz luarocks-1dcdaa77c0a52ad02f49bc7fdde2fd7dee956ddf.tar.bz2 luarocks-1dcdaa77c0a52ad02f49bc7fdde2fd7dee956ddf.zip |
Tests: test the "busted" backend of `luarocks test` with a local fixture
-rw-r--r-- | spec/fixtures/a_repo/busted_project-0.1-1.rockspec | 19 | ||||
-rw-r--r-- | spec/fixtures/a_repo/busted_project-0.1-1.src.rock | bin | 0 -> 937 bytes | |||
-rw-r--r-- | spec/fixtures/a_repo/manifest | 10 | ||||
-rw-r--r-- | spec/fixtures/a_repo/manifest-5.1 | 10 | ||||
-rw-r--r-- | spec/fixtures/a_repo/manifest-5.1.zip | bin | 0 -> 350 bytes | |||
-rw-r--r-- | spec/fixtures/a_repo/manifest-5.2 | 10 | ||||
-rw-r--r-- | spec/fixtures/a_repo/manifest-5.2.zip | bin | 0 -> 350 bytes | |||
-rw-r--r-- | spec/fixtures/a_repo/manifest-5.3 | 10 | ||||
-rw-r--r-- | spec/fixtures/a_repo/manifest-5.3.zip | bin | 0 -> 350 bytes | |||
-rw-r--r-- | spec/fixtures/busted_project-0.1-1.rockspec | 19 | ||||
-rw-r--r-- | spec/fixtures/busted_project-0.1.tar.gz | bin | 0 -> 345 bytes | |||
-rw-r--r-- | spec/test_spec.lua | 13 | ||||
-rw-r--r-- | spec/util/mock-server.lua | 2 | ||||
-rw-r--r-- | spec/util/test_env.lua | 6 |
14 files changed, 88 insertions, 11 deletions
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 @@ | |||
1 | rockspec_format = "3.0" | ||
2 | package = "busted_project" | ||
3 | version = "0.1-1" | ||
4 | source = { | ||
5 | url = "http://localhost:8080/file/busted_project-0.1.tar.gz", | ||
6 | dir = "busted_project", | ||
7 | } | ||
8 | description = { | ||
9 | summary = "A project that uses Busted tests", | ||
10 | } | ||
11 | build = { | ||
12 | type = "builtin", | ||
13 | modules = { | ||
14 | sum = "sum.lua", | ||
15 | } | ||
16 | } | ||
17 | test = { | ||
18 | type = "busted", | ||
19 | } | ||
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 --- /dev/null +++ b/spec/fixtures/a_repo/busted_project-0.1-1.src.rock | |||
Binary files 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 = { | |||
21 | } | 21 | } |
22 | } | 22 | } |
23 | }, | 23 | }, |
24 | busted_project = { | ||
25 | ["0.1-1"] = { | ||
26 | { | ||
27 | arch = "src" | ||
28 | }, | ||
29 | { | ||
30 | arch = "rockspec" | ||
31 | } | ||
32 | } | ||
33 | }, | ||
24 | has_another_namespaced_dep = { | 34 | has_another_namespaced_dep = { |
25 | ["1.0-1"] = { | 35 | ["1.0-1"] = { |
26 | { | 36 | { |
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 = { | |||
21 | } | 21 | } |
22 | } | 22 | } |
23 | }, | 23 | }, |
24 | busted_project = { | ||
25 | ["0.1-1"] = { | ||
26 | { | ||
27 | arch = "src" | ||
28 | }, | ||
29 | { | ||
30 | arch = "rockspec" | ||
31 | } | ||
32 | } | ||
33 | }, | ||
24 | has_another_namespaced_dep = { | 34 | has_another_namespaced_dep = { |
25 | ["1.0-1"] = { | 35 | ["1.0-1"] = { |
26 | { | 36 | { |
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 --- /dev/null +++ b/spec/fixtures/a_repo/manifest-5.1.zip | |||
Binary files 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 = { | |||
21 | } | 21 | } |
22 | } | 22 | } |
23 | }, | 23 | }, |
24 | busted_project = { | ||
25 | ["0.1-1"] = { | ||
26 | { | ||
27 | arch = "src" | ||
28 | }, | ||
29 | { | ||
30 | arch = "rockspec" | ||
31 | } | ||
32 | } | ||
33 | }, | ||
24 | has_another_namespaced_dep = { | 34 | has_another_namespaced_dep = { |
25 | ["1.0-1"] = { | 35 | ["1.0-1"] = { |
26 | { | 36 | { |
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 --- /dev/null +++ b/spec/fixtures/a_repo/manifest-5.2.zip | |||
Binary files 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 = { | |||
21 | } | 21 | } |
22 | } | 22 | } |
23 | }, | 23 | }, |
24 | busted_project = { | ||
25 | ["0.1-1"] = { | ||
26 | { | ||
27 | arch = "src" | ||
28 | }, | ||
29 | { | ||
30 | arch = "rockspec" | ||
31 | } | ||
32 | } | ||
33 | }, | ||
24 | has_another_namespaced_dep = { | 34 | has_another_namespaced_dep = { |
25 | ["1.0-1"] = { | 35 | ["1.0-1"] = { |
26 | { | 36 | { |
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 --- /dev/null +++ b/spec/fixtures/a_repo/manifest-5.3.zip | |||
Binary files 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 @@ | |||
1 | rockspec_format = "3.0" | ||
2 | package = "busted_project" | ||
3 | version = "0.1-1" | ||
4 | source = { | ||
5 | url = "http://localhost:8080/file/busted_project-0.1.tar.gz", | ||
6 | dir = "busted_project", | ||
7 | } | ||
8 | description = { | ||
9 | summary = "A project that uses Busted tests", | ||
10 | } | ||
11 | build = { | ||
12 | type = "builtin", | ||
13 | modules = { | ||
14 | sum = "sum.lua", | ||
15 | } | ||
16 | } | ||
17 | test = { | ||
18 | type = "busted", | ||
19 | } | ||
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 --- /dev/null +++ b/spec/fixtures/busted_project-0.1.tar.gz | |||
Binary files 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() | |||
39 | finally(function() | 39 | finally(function() |
40 | -- delete downloaded and unpacked files | 40 | -- delete downloaded and unpacked files |
41 | lfs.chdir(testing_paths.testrun_dir) | 41 | lfs.chdir(testing_paths.testrun_dir) |
42 | test_env.remove_dir("luassert-1.7.10-0") | 42 | test_env.remove_dir("busted_project-0.1-1") |
43 | os.remove("luassert-1.7.10-0.rockspec") | 43 | os.remove("busted_project-0.1-1.src.rock") |
44 | end) | 44 | end) |
45 | 45 | ||
46 | -- make luassert | 46 | -- make luassert |
47 | assert.is_true(run.luarocks_bool("download --rockspec luassert 1.7.10-0")) | 47 | assert.is_true(run.luarocks_bool("download --server="..testing_paths.fixtures_repo_dir.." busted_project 0.1-1")) |
48 | assert.is_true(run.luarocks_bool("unpack luassert-1.7.10-0.rockspec")) | 48 | assert.is_true(run.luarocks_bool("unpack busted_project-0.1-1.src.rock")) |
49 | lfs.chdir("luassert-1.7.10-0/luassert-1.7.10/") | 49 | lfs.chdir("busted_project-0.1-1/busted_project") |
50 | assert.is_true(run.luarocks_bool("make")) | 50 | assert.is_true(run.luarocks_bool("make")) |
51 | local output = run.luarocks("test --test-type=busted luassert-1.7.10-0.rockspec") | 51 | local output = run.luarocks("test") |
52 | print(output) | ||
52 | -- Assert that busted ran, whether successfully or not | 53 | -- Assert that busted ran, whether successfully or not |
53 | assert.match("%d+ success.* / %d+ failure.* / %d+ error.* / %d+ pending", output) | 54 | assert.match("%d+ success.* / %d+ failure.* / %d+ error.* / %d+ pending", output) |
54 | end) | 55 | 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:[^/]+}", { | |||
70 | path = "/", | 70 | path = "/", |
71 | produces = "text/plain", | 71 | produces = "text/plain", |
72 | handler = function(query, name) | 72 | handler = function(query, name) |
73 | local basedir = arg[1] or "." | 73 | local basedir = arg[1] or "./spec/fixtures" |
74 | local fd = io.open(basedir .. "/" .. name, "r") | 74 | local fd = io.open(basedir .. "/" .. name, "r") |
75 | if not fd then | 75 | if not fd then |
76 | return restserver.response():status(404) | 76 | 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) | |||
506 | end | 506 | end |
507 | 507 | ||
508 | testing_paths.fixtures_dir = base_dir .. "/spec/fixtures" | 508 | testing_paths.fixtures_dir = base_dir .. "/spec/fixtures" |
509 | testing_paths.fixtures_repo_dir = base_dir .. "/spec/fixtures/a_repo" | ||
509 | testing_paths.util_dir = base_dir .. "/spec/util" | 510 | testing_paths.util_dir = base_dir .. "/spec/util" |
510 | testing_paths.testrun_dir = base_dir .. "/testrun" | 511 | testing_paths.testrun_dir = base_dir .. "/testrun" |
511 | testing_paths.src_dir = base_dir .. "/src" | 512 | testing_paths.src_dir = base_dir .. "/src" |
@@ -763,12 +764,9 @@ end | |||
763 | function test_env.mock_server_init() | 764 | function test_env.mock_server_init() |
764 | local testing_paths = test_env.testing_paths | 765 | local testing_paths = test_env.testing_paths |
765 | assert(test_env.need_rock("restserver-xavante")) | 766 | assert(test_env.need_rock("restserver-xavante")) |
766 | local pwd = lfs.currentdir() | 767 | 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) |
767 | lfs.chdir(testing_paths.fixtures_dir) | ||
768 | local final_command = test_env.execute_helper(testing_paths.lua .. " " .. testing_paths.util_dir .. "/mock-server.lua &", true, test_env.env_variables) | ||
769 | os.execute(final_command) | 768 | os.execute(final_command) |
770 | os.execute("sleep 1") | 769 | os.execute("sleep 1") |
771 | lfs.chdir(pwd) | ||
772 | end | 770 | end |
773 | 771 | ||
774 | function test_env.mock_server_done() | 772 | function test_env.mock_server_done() |