aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2018-03-30 15:21:05 -0300
committerHisham Muhammad <hisham@gobolinux.org>2018-03-30 19:52:17 -0300
commit43adf5df7465c39a9f6fc735654aabac991cabb5 (patch)
tree2b8a4e93bc2334a5f546cba9dcad4cb99332576e
parentad4b4b29a7af9c8df859781dab51ef38a9a9895d (diff)
downloadluarocks-43adf5df7465c39a9f6fc735654aabac991cabb5.tar.gz
luarocks-43adf5df7465c39a9f6fc735654aabac991cabb5.tar.bz2
luarocks-43adf5df7465c39a9f6fc735654aabac991cabb5.zip
Tests: make sure tests run from testrun/
-rw-r--r--spec/deps_spec.lua4
-rw-r--r--spec/make_spec.lua27
-rw-r--r--spec/new_version_spec.lua12
-rw-r--r--spec/pack_spec.lua6
-rw-r--r--spec/util/mock-server.lua2
-rw-r--r--spec/util/test_env.lua14
-rw-r--r--spec/util_spec.lua6
7 files changed, 43 insertions, 28 deletions
diff --git a/spec/deps_spec.lua b/spec/deps_spec.lua
index 76ee68a7..67c1335f 100644
--- a/spec/deps_spec.lua
+++ b/spec/deps_spec.lua
@@ -85,7 +85,7 @@ describe("LuaRocks deps tests #blackbox #b_deps", function()
85 lfs.chdir("lxsh-0.8.6-2/lxsh-0.8.6-1/") 85 lfs.chdir("lxsh-0.8.6-2/lxsh-0.8.6-1/")
86 assert.is_true(run.luarocks_bool("make --tree=" .. testing_paths.testing_tree .. " --deps-mode=order")) 86 assert.is_true(run.luarocks_bool("make --tree=" .. testing_paths.testing_tree .. " --deps-mode=order"))
87 87
88 lfs.chdir(testing_paths.luarocks_dir) 88 lfs.chdir(testing_paths.testrun_dir)
89 test_env.remove_dir("lxsh-0.8.6-2") 89 test_env.remove_dir("lxsh-0.8.6-2")
90 assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) 90 assert.is_true(os.remove("lxsh-0.8.6-2.src.rock"))
91 91
@@ -102,7 +102,7 @@ describe("LuaRocks deps tests #blackbox #b_deps", function()
102 lfs.chdir("lxsh-0.8.6-2/lxsh-0.8.6-1/") 102 lfs.chdir("lxsh-0.8.6-2/lxsh-0.8.6-1/")
103 assert.is_true(run.luarocks_bool("make --tree=" .. testing_paths.testing_sys_tree .. " --deps-mode=order")) 103 assert.is_true(run.luarocks_bool("make --tree=" .. testing_paths.testing_sys_tree .. " --deps-mode=order"))
104 104
105 lfs.chdir(testing_paths.luarocks_dir) 105 lfs.chdir(testing_paths.testrun_dir)
106 test_env.remove_dir("lxsh-0.8.6-2") 106 test_env.remove_dir("lxsh-0.8.6-2")
107 assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) 107 assert.is_true(os.remove("lxsh-0.8.6-2.src.rock"))
108 108
diff --git a/spec/make_spec.lua b/spec/make_spec.lua
index 88b35b22..bb219b68 100644
--- a/spec/make_spec.lua
+++ b/spec/make_spec.lua
@@ -21,12 +21,23 @@ describe("LuaRocks make tests #blackbox #b_make", function()
21 end) 21 end)
22 22
23 it("LuaRocks make with no flags/arguments", function() 23 it("LuaRocks make with no flags/arguments", function()
24 lfs.chdir("test") 24 finally(function()
25 lfs.chdir(testing_paths.testrun_dir)
26 test_env.remove_dir("empty")
27 end)
28 assert(lfs.mkdir("empty"))
29 assert(lfs.chdir("empty"))
25 assert.is_false(run.luarocks_bool("make")) 30 assert.is_false(run.luarocks_bool("make"))
26 lfs.chdir(testing_paths.luarocks_dir)
27 end) 31 end)
28 32
29 it("LuaRocks make with rockspec", function() 33 it("LuaRocks make with rockspec", function()
34 finally(function()
35 -- delete downloaded and unpacked files
36 lfs.chdir(testing_paths.testrun_dir)
37 test_env.remove_dir("luasocket-3.0rc1-2")
38 os.remove("luasocket-3.0rc1-2.src.rock")
39 end)
40
30 -- make luasocket 41 -- make luasocket
31 assert.is_true(run.luarocks_bool("download --source luasocket 3.0rc1-2")) 42 assert.is_true(run.luarocks_bool("download --source luasocket 3.0rc1-2"))
32 assert.is_true(run.luarocks_bool("unpack luasocket-3.0rc1-2.src.rock")) 43 assert.is_true(run.luarocks_bool("unpack luasocket-3.0rc1-2.src.rock"))
@@ -36,11 +47,6 @@ describe("LuaRocks make tests #blackbox #b_make", function()
36 -- test it 47 -- test it
37 assert.is_true(run.luarocks_bool("show luasocket")) 48 assert.is_true(run.luarocks_bool("show luasocket"))
38 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasocket/3.0rc1-2/luasocket-3.0rc1-2.rockspec")) 49 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasocket/3.0rc1-2/luasocket-3.0rc1-2.rockspec"))
39
40 -- delete downloaded and unpacked files
41 lfs.chdir(testing_paths.luarocks_dir)
42 test_env.remove_dir("luasocket-3.0rc1-2")
43 assert.is_true(os.remove("luasocket-3.0rc1-2.src.rock"))
44 end) 50 end)
45 51
46 describe("LuaRocks making rockspecs (using lxsh)", function() 52 describe("LuaRocks making rockspecs (using lxsh)", function()
@@ -53,7 +59,7 @@ describe("LuaRocks make tests #blackbox #b_make", function()
53 59
54 -- delete downloaded and unpacked files 60 -- delete downloaded and unpacked files
55 after_each(function() 61 after_each(function()
56 assert.is_true(lfs.chdir(testing_paths.luarocks_dir)) 62 assert(lfs.chdir(testing_paths.testrun_dir))
57 test_env.remove_dir("lxsh-0.8.6-2") 63 test_env.remove_dir("lxsh-0.8.6-2")
58 assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) 64 assert.is_true(os.remove("lxsh-0.8.6-2.src.rock"))
59 end) 65 end)
@@ -67,12 +73,15 @@ describe("LuaRocks make tests #blackbox #b_make", function()
67 end) 73 end)
68 74
69 it("LuaRocks make unnamed rockspec", function() 75 it("LuaRocks make unnamed rockspec", function()
76 finally(function()
77 os.remove("rockspec")
78 end)
79
70 test_env.copy("lxsh-0.8.6-2.rockspec", "rockspec") 80 test_env.copy("lxsh-0.8.6-2.rockspec", "rockspec")
71 assert.is_true(run.luarocks_bool("make")) 81 assert.is_true(run.luarocks_bool("make"))
72 82
73 assert.is_true(run.luarocks_bool("show lxsh")) 83 assert.is_true(run.luarocks_bool("show lxsh"))
74 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) 84 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec"))
75 os.remove("rockspec")
76 end) 85 end)
77 86
78 it("LuaRocks make ambiguous rockspec", function() 87 it("LuaRocks make ambiguous rockspec", function()
diff --git a/spec/new_version_spec.lua b/spec/new_version_spec.lua
index 65f60dd6..6d9d6860 100644
--- a/spec/new_version_spec.lua
+++ b/spec/new_version_spec.lua
@@ -6,21 +6,25 @@ local testing_paths = test_env.testing_paths
6test_env.unload_luarocks() 6test_env.unload_luarocks()
7 7
8local extra_rocks = test_env.mock_server_extra_rocks({ 8local extra_rocks = test_env.mock_server_extra_rocks({
9 "/abelhas-1.0-1.rockspec", 9 "/abelhas-1.1-1.rockspec",
10 "/lpeg-0.12-1.rockspec" 10 "/lpeg-0.12-1.rockspec"
11}) 11})
12 12
13describe("LuaRocks new_version tests #blackbox #b_new_version", function() 13describe("LuaRocks new_version tests #blackbox #b_new_version", function()
14 14
15 before_each(function() 15 setup(function()
16 test_env.setup_specs(extra_rocks) 16 test_env.setup_specs(extra_rocks)
17 end) 17 end)
18 18
19 describe("basic tests", function() 19 describe("basic tests", function()
20 it("with no flags/arguments", function() 20 it("with no flags/arguments", function()
21 lfs.chdir("test") 21 finally(function()
22 lfs.chdir(testing_paths.testrun_dir)
23 test_env.remove_dir("empty")
24 end)
25 assert(lfs.mkdir("empty"))
26 assert(lfs.chdir("empty"))
22 assert.is_false(run.luarocks_bool("new_version")) 27 assert.is_false(run.luarocks_bool("new_version"))
23 lfs.chdir(testing_paths.luarocks_dir)
24 end) 28 end)
25 29
26 it("with invalid", function() 30 it("with invalid", function()
diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua
index 966195c5..86b4e2b2 100644
--- a/spec/pack_spec.lua
+++ b/spec/pack_spec.lua
@@ -26,7 +26,7 @@ describe("LuaRocks pack tests #blackbox #b_pack", function()
26 26
27 it("LuaRocks pack basic", function() 27 it("LuaRocks pack basic", function()
28 assert.is_true(run.luarocks_bool("pack luacov")) 28 assert.is_true(run.luarocks_bool("pack luacov"))
29 assert.is_true(test_env.remove_files(lfs.currentdir(), "luacov-")) 29 assert.is_true(test_env.remove_files(lfs.currentdir(), "luacov%-"))
30 end) 30 end)
31 31
32 it("LuaRocks pack invalid rockspec", function() 32 it("LuaRocks pack invalid rockspec", function()
@@ -47,14 +47,14 @@ describe("LuaRocks pack tests #blackbox #b_pack", function()
47 assert.is_true(run.luarocks_bool("install say 1.0")) 47 assert.is_true(run.luarocks_bool("install say 1.0"))
48 assert.is_true(run.luarocks_bool("pack say")) 48 assert.is_true(run.luarocks_bool("pack say"))
49 assert.is_truthy(lfs.attributes("say-1.2-1.all.rock")) 49 assert.is_truthy(lfs.attributes("say-1.2-1.all.rock"))
50 assert.is_true(test_env.remove_files(lfs.currentdir(), "say-")) 50 assert.is_true(test_env.remove_files(lfs.currentdir(), "say%-"))
51 end) 51 end)
52 52
53 it("LuaRocks pack src", function() 53 it("LuaRocks pack src", function()
54 assert.is_true(run.luarocks_bool("install luasec " .. test_env.OPENSSL_DIRS)) 54 assert.is_true(run.luarocks_bool("install luasec " .. test_env.OPENSSL_DIRS))
55 assert.is_true(run.luarocks_bool("download --rockspec luasocket 3.0rc1-2")) 55 assert.is_true(run.luarocks_bool("download --rockspec luasocket 3.0rc1-2"))
56 assert.is_true(run.luarocks_bool("pack luasocket-3.0rc1-2.rockspec")) 56 assert.is_true(run.luarocks_bool("pack luasocket-3.0rc1-2.rockspec"))
57 assert.is_true(test_env.remove_files(lfs.currentdir(), "luasocket-")) 57 assert.is_true(test_env.remove_files(lfs.currentdir(), "luasocket%-"))
58 end) 58 end)
59end) 59end)
60 60
diff --git a/spec/util/mock-server.lua b/spec/util/mock-server.lua
index 244aceae..77d32927 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 fd = io.open("spec/fixtures/"..name, "r") 73 local fd = io.open("../spec/fixtures/"..name, "r")
74 if not fd then 74 if not fd then
75 return restserver.response():status(404) 75 return restserver.response():status(404)
76 end 76 end
diff --git a/spec/util/test_env.lua b/spec/util/test_env.lua
index ce2b1728..2232de87 100644
--- a/spec/util/test_env.lua
+++ b/spec/util/test_env.lua
@@ -494,16 +494,16 @@ local function create_paths(luaversion_full)
494 testing_paths.luarocks_tmp = "/tmp/luarocks_testing" 494 testing_paths.luarocks_tmp = "/tmp/luarocks_testing"
495 end 495 end
496 496
497 testing_paths.luarocks_dir = lfs.currentdir() 497 local base_dir = lfs.currentdir()
498 498
499 if test_env.TEST_TARGET_OS == "windows" then 499 if test_env.TEST_TARGET_OS == "windows" then
500 testing_paths.luarocks_dir = testing_paths.luarocks_dir:gsub("\\","/") 500 base_dir = base_dir:gsub("\\","/")
501 end 501 end
502 502
503 testing_paths.fixtures_dir = testing_paths.luarocks_dir .. "/spec/fixtures" 503 testing_paths.fixtures_dir = base_dir .. "/spec/fixtures"
504 testing_paths.util_dir = testing_paths.luarocks_dir .. "/spec/util" 504 testing_paths.util_dir = base_dir .. "/spec/util"
505 testing_paths.testrun_dir = testing_paths.luarocks_dir .. "/testrun" 505 testing_paths.testrun_dir = base_dir .. "/testrun"
506 testing_paths.src_dir = testing_paths.luarocks_dir .. "/src" 506 testing_paths.src_dir = base_dir .. "/src"
507 testing_paths.testing_lrprefix = testing_paths.testrun_dir .. "/testing_lrprefix-" .. luaversion_full 507 testing_paths.testing_lrprefix = testing_paths.testrun_dir .. "/testing_lrprefix-" .. luaversion_full
508 testing_paths.testing_tree = testing_paths.testrun_dir .. "/testing-" .. luaversion_full 508 testing_paths.testing_tree = testing_paths.testrun_dir .. "/testing-" .. luaversion_full
509 testing_paths.testing_tree_copy = testing_paths.testrun_dir .. "/testing_copy-" .. luaversion_full 509 testing_paths.testing_tree_copy = testing_paths.testrun_dir .. "/testing_copy-" .. luaversion_full
@@ -566,6 +566,8 @@ function test_env.setup_specs(extra_rocks)
566 if test_env.RESET_ENV then 566 if test_env.RESET_ENV then
567 reset_environment(test_env.testing_paths, test_env.md5sums, test_env.env_variables) 567 reset_environment(test_env.testing_paths, test_env.md5sums, test_env.env_variables)
568 end 568 end
569
570 lfs.chdir(test_env.testing_paths.testrun_dir)
569end 571end
570 572
571--- Test if required rock is installed and if not, install it. 573--- Test if required rock is installed and if not, install it.
diff --git a/spec/util_spec.lua b/spec/util_spec.lua
index 3aa8fbf5..209dae6f 100644
--- a/spec/util_spec.lua
+++ b/spec/util_spec.lua
@@ -53,9 +53,9 @@ describe("Basic tests #blackbox #b_util", function()
53 it("LuaRocks only server=testing", function() 53 it("LuaRocks only server=testing", function()
54 assert.is.truthy(run.luarocks("--only-server=testing")) 54 assert.is.truthy(run.luarocks("--only-server=testing"))
55 end) 55 end)
56 56
57 it("LuaRocks test site config", function() 57 it("#only LuaRocks test site config", function()
58 local scname = "src/luarocks/core/site_config_"..test_env.lua_version:gsub("%.", "_")..".lua" 58 local scname = testing_paths.src_dir .. "/luarocks/core/site_config_"..test_env.lua_version:gsub("%.", "_")..".lua"
59 59
60 assert.is.truthy(os.rename(scname, scname..".tmp")) 60 assert.is.truthy(os.rename(scname, scname..".tmp"))
61 assert.is.falsy(lfs.attributes(scname)) 61 assert.is.falsy(lfs.attributes(scname))