diff options
author | Hisham <hisham@gobolinux.org> | 2016-09-08 14:04:40 -0300 |
---|---|---|
committer | Hisham <hisham@gobolinux.org> | 2016-09-08 14:04:40 -0300 |
commit | f91fc9a6ef9ef488c709894a29ce63db2bc1e399 (patch) | |
tree | 3b9dbbe28ad79f2d1115b2048f3cbf9738303373 | |
parent | c6d48427430b6b96f88b249dee1533fb5e6ff681 (diff) | |
download | luarocks-f91fc9a6ef9ef488c709894a29ce63db2bc1e399.tar.gz luarocks-f91fc9a6ef9ef488c709894a29ce63db2bc1e399.tar.bz2 luarocks-f91fc9a6ef9ef488c709894a29ce63db2bc1e399.zip |
Tests: luarocks_bool commands log their outputs on failure.
-rw-r--r-- | spec/build_spec.lua | 8 | ||||
-rw-r--r-- | spec/help_spec.lua | 4 | ||||
-rw-r--r-- | spec/install_spec.lua | 12 | ||||
-rw-r--r-- | spec/make_spec.lua | 8 | ||||
-rw-r--r-- | spec/pack_spec.lua | 4 | ||||
-rw-r--r-- | spec/search_spec.lua | 2 | ||||
-rw-r--r-- | test/test_environment.lua | 22 |
7 files changed, 38 insertions, 22 deletions
diff --git a/spec/build_spec.lua b/spec/build_spec.lua index 8f08f0a0..2ff7cbe6 100644 --- a/spec/build_spec.lua +++ b/spec/build_spec.lua | |||
@@ -92,7 +92,7 @@ describe("LuaRocks build tests #blackbox #b_build", function() | |||
92 | 92 | ||
93 | describe("LuaRocks build - basic builds", function() | 93 | describe("LuaRocks build - basic builds", function() |
94 | it("LuaRocks build luadoc", function() | 94 | it("LuaRocks build luadoc", function() |
95 | assert.is_true(run.luarocks_bool(test_env.quiet("build luadoc"))) | 95 | assert.is_true(run.luarocks_bool("build luadoc")) |
96 | end) | 96 | end) |
97 | 97 | ||
98 | it("LuaRocks build luacov diff version", function() | 98 | it("LuaRocks build luacov diff version", function() |
@@ -114,7 +114,7 @@ describe("LuaRocks build tests #blackbox #b_build", function() | |||
114 | if test_env.TEST_TARGET_OS == "windows" then | 114 | if test_env.TEST_TARGET_OS == "windows" then |
115 | assert.is_false(run.luarocks_bool("build lpty")) --Error: This rockspec for lpty does not support win32, windows platforms | 115 | assert.is_false(run.luarocks_bool("build lpty")) --Error: This rockspec for lpty does not support win32, windows platforms |
116 | else | 116 | else |
117 | assert.is_true(run.luarocks_bool(test_env.quiet("build lpty"))) | 117 | assert.is_true(run.luarocks_bool("build lpty")) |
118 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpty/1.0.1-1/lpty-1.0.1-1.rockspec")) | 118 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpty/1.0.1-1/lpty-1.0.1-1.rockspec")) |
119 | end | 119 | end |
120 | end) | 120 | end) |
@@ -146,7 +146,7 @@ describe("LuaRocks build tests #blackbox #b_build", function() | |||
146 | end | 146 | end |
147 | 147 | ||
148 | it("LuaRocks build luasec only deps", function() | 148 | it("LuaRocks build luasec only deps", function() |
149 | assert.is_true(run.luarocks_bool(test_env.quiet("build luasec " .. test_env.OPENSSL_DIRS .. " --only-deps"))) | 149 | assert.is_true(run.luarocks_bool("build luasec " .. test_env.OPENSSL_DIRS .. " --only-deps")) |
150 | assert.is_false(run.luarocks_bool("show luasec")) | 150 | assert.is_false(run.luarocks_bool("show luasec")) |
151 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec/0.6-1/luasec-0.6-1.rockspec")) | 151 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec/0.6-1/luasec-0.6-1.rockspec")) |
152 | end) | 152 | end) |
@@ -181,7 +181,7 @@ describe("LuaRocks build tests #blackbox #b_build", function() | |||
181 | 181 | ||
182 | it("LuaRocks build with https", function() | 182 | it("LuaRocks build with https", function() |
183 | assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) | 183 | assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) |
184 | assert.is_true(run.luarocks_bool(test_env.quiet("install luasec " .. test_env.OPENSSL_DIRS))) | 184 | assert.is_true(run.luarocks_bool("install luasec " .. test_env.OPENSSL_DIRS)) |
185 | 185 | ||
186 | assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec")) | 186 | assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec")) |
187 | assert.is.truthy(run.luarocks("show validate-args")) | 187 | assert.is.truthy(run.luarocks("show validate-args")) |
diff --git a/spec/help_spec.lua b/spec/help_spec.lua index 88aa5030..71b1b9f6 100644 --- a/spec/help_spec.lua +++ b/spec/help_spec.lua | |||
@@ -10,7 +10,7 @@ describe("LuaRocks help tests #blackbox #b_help", function() | |||
10 | end) | 10 | end) |
11 | 11 | ||
12 | it("LuaRocks help with no flags/arguments", function() | 12 | it("LuaRocks help with no flags/arguments", function() |
13 | assert.is_true(run.luarocks_bool(test_env.quiet("help"))) | 13 | assert.is_true(run.luarocks_bool("help")) |
14 | end) | 14 | end) |
15 | 15 | ||
16 | it("LuaRocks help invalid argument", function() | 16 | it("LuaRocks help invalid argument", function() |
@@ -18,7 +18,7 @@ describe("LuaRocks help tests #blackbox #b_help", function() | |||
18 | end) | 18 | end) |
19 | 19 | ||
20 | it("LuaRocks help config", function() | 20 | it("LuaRocks help config", function() |
21 | assert.is_true(run.luarocks_bool(test_env.quiet("help config"))) | 21 | assert.is_true(run.luarocks_bool("help config")) |
22 | end) | 22 | end) |
23 | 23 | ||
24 | it("LuaRocks-admin help with no flags/arguments", function() | 24 | it("LuaRocks-admin help with no flags/arguments", function() |
diff --git a/spec/install_spec.lua b/spec/install_spec.lua index e5b9e2cc..8857e4bd 100644 --- a/spec/install_spec.lua +++ b/spec/install_spec.lua | |||
@@ -66,15 +66,15 @@ describe("LuaRocks install tests #blackbox #b_install", function() | |||
66 | end) | 66 | end) |
67 | 67 | ||
68 | it("LuaRocks install luasec and show luasocket (dependency)", function() | 68 | it("LuaRocks install luasec and show luasocket (dependency)", function() |
69 | assert.is_true(run.luarocks_bool(test_env.quiet("install luasec " .. test_env.OPENSSL_DIRS))) | 69 | assert.is_true(run.luarocks_bool("install luasec " .. test_env.OPENSSL_DIRS)) |
70 | assert.is_true(run.luarocks_bool("show luasocket")) | 70 | assert.is_true(run.luarocks_bool("show luasocket")) |
71 | end) | 71 | end) |
72 | end) | 72 | end) |
73 | 73 | ||
74 | describe("LuaRocks install - more complex tests", function() | 74 | describe("LuaRocks install - more complex tests", function() |
75 | it('LuaRocks install luasec with skipping dependency checks', function() | 75 | it('LuaRocks install luasec with skipping dependency checks', function() |
76 | assert.is_true(run.luarocks_bool(test_env.quiet("install luasec " .. test_env.OPENSSL_DIRS .. " --nodeps"))) | 76 | assert.is_true(run.luarocks_bool("install luasec " .. test_env.OPENSSL_DIRS .. " --nodeps")) |
77 | assert.is_true(run.luarocks_bool(test_env.quiet("show luasec"))) | 77 | assert.is_true(run.luarocks_bool("show luasec")) |
78 | if env_variables.TYPE_TEST_ENV == "minimal" then | 78 | if env_variables.TYPE_TEST_ENV == "minimal" then |
79 | assert.is_false(run.luarocks_bool(test_env.quiet("show luasocket"))) | 79 | assert.is_false(run.luarocks_bool(test_env.quiet("show luasocket"))) |
80 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) | 80 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) |
@@ -83,21 +83,21 @@ describe("LuaRocks install tests #blackbox #b_install", function() | |||
83 | end) | 83 | end) |
84 | 84 | ||
85 | it("LuaRocks install only-deps of luasocket packed rock", function() | 85 | it("LuaRocks install only-deps of luasocket packed rock", function() |
86 | assert.is_true(run.luarocks_bool(test_env.quiet("build --pack-binary-rock luasocket 3.0rc1-2"))) | 86 | assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket 3.0rc1-2")) |
87 | local output = run.luarocks("install --only-deps " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock") | 87 | local output = run.luarocks("install --only-deps " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock") |
88 | assert.are.same(output, "Successfully installed dependencies for luasocket 3.0rc1-2") | 88 | assert.are.same(output, "Successfully installed dependencies for luasocket 3.0rc1-2") |
89 | assert.is_true(os.remove("luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) | 89 | assert.is_true(os.remove("luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) |
90 | end) | 90 | end) |
91 | 91 | ||
92 | it("LuaRocks install reinstall", function() | 92 | it("LuaRocks install reinstall", function() |
93 | assert.is_true(run.luarocks_bool(test_env.quiet("build --pack-binary-rock luasocket 3.0rc1-2"))) | 93 | assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket 3.0rc1-2")) |
94 | assert.is_true(run.luarocks_bool("install " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) | 94 | assert.is_true(run.luarocks_bool("install " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) |
95 | assert.is_true(run.luarocks_bool("install --deps-mode=none " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) | 95 | assert.is_true(run.luarocks_bool("install --deps-mode=none " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) |
96 | assert.is_true(os.remove("luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) | 96 | assert.is_true(os.remove("luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) |
97 | end) | 97 | end) |
98 | 98 | ||
99 | it("LuaRocks install binary rock of cprint", function() | 99 | it("LuaRocks install binary rock of cprint", function() |
100 | assert.is_true(run.luarocks_bool(test_env.quiet("build --pack-binary-rock cprint"))) | 100 | assert.is_true(run.luarocks_bool("build --pack-binary-rock cprint")) |
101 | assert.is_true(run.luarocks_bool("install cprint-0.1-2." .. test_env.platform .. ".rock")) | 101 | assert.is_true(run.luarocks_bool("install cprint-0.1-2." .. test_env.platform .. ".rock")) |
102 | assert.is_true(os.remove("cprint-0.1-2." .. test_env.platform .. ".rock")) | 102 | assert.is_true(os.remove("cprint-0.1-2." .. test_env.platform .. ".rock")) |
103 | end) | 103 | end) |
diff --git a/spec/make_spec.lua b/spec/make_spec.lua index 624badff..ae79a29c 100644 --- a/spec/make_spec.lua +++ b/spec/make_spec.lua | |||
@@ -30,10 +30,10 @@ describe("LuaRocks make tests #blackbox #b_make", function() | |||
30 | assert.is_true(run.luarocks_bool("download --source luasocket 3.0rc1-2")) | 30 | assert.is_true(run.luarocks_bool("download --source luasocket 3.0rc1-2")) |
31 | assert.is_true(run.luarocks_bool("unpack luasocket-3.0rc1-2.src.rock")) | 31 | assert.is_true(run.luarocks_bool("unpack luasocket-3.0rc1-2.src.rock")) |
32 | lfs.chdir("luasocket-3.0rc1-2/luasocket-3.0-rc1/") | 32 | lfs.chdir("luasocket-3.0rc1-2/luasocket-3.0-rc1/") |
33 | assert.is_true(run.luarocks_bool(test_env.quiet("make luasocket-3.0rc1-2.rockspec"))) | 33 | assert.is_true(run.luarocks_bool("make luasocket-3.0rc1-2.rockspec")) |
34 | 34 | ||
35 | -- test it | 35 | -- test it |
36 | assert.is_true(run.luarocks_bool(test_env.quiet("show luasocket"))) | 36 | assert.is_true(run.luarocks_bool("show luasocket")) |
37 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket/3.0rc1-2/luasocket-3.0rc1-2.rockspec")) | 37 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket/3.0rc1-2/luasocket-3.0rc1-2.rockspec")) |
38 | 38 | ||
39 | -- delete downloaded and unpacked files | 39 | -- delete downloaded and unpacked files |
@@ -69,7 +69,7 @@ describe("LuaRocks make tests #blackbox #b_make", function() | |||
69 | test_env.copy("lxsh-0.8.6-2.rockspec", "rockspec") | 69 | test_env.copy("lxsh-0.8.6-2.rockspec", "rockspec") |
70 | assert.is_true(run.luarocks_bool("make")) | 70 | assert.is_true(run.luarocks_bool("make")) |
71 | 71 | ||
72 | assert.is_true(run.luarocks_bool(test_env.quiet("show lxsh"))) | 72 | assert.is_true(run.luarocks_bool("show lxsh")) |
73 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) | 73 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
74 | os.remove("rockspec") | 74 | os.remove("rockspec") |
75 | end) | 75 | end) |
@@ -94,7 +94,7 @@ describe("LuaRocks make tests #blackbox #b_make", function() | |||
94 | end) | 94 | end) |
95 | 95 | ||
96 | it("LuaRocks make pack binary rock", function() | 96 | it("LuaRocks make pack binary rock", function() |
97 | assert.is_true(run.luarocks_bool(test_env.quiet("make --deps-mode=none --pack-binary-rock"))) | 97 | assert.is_true(run.luarocks_bool("make --deps-mode=none --pack-binary-rock")) |
98 | assert.is.truthy(lfs.attributes("lxsh-0.8.6-2.all.rock")) | 98 | assert.is.truthy(lfs.attributes("lxsh-0.8.6-2.all.rock")) |
99 | end) | 99 | end) |
100 | end) | 100 | end) |
diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua index 3191e80c..3c9ed9fd 100644 --- a/spec/pack_spec.lua +++ b/spec/pack_spec.lua | |||
@@ -25,7 +25,7 @@ describe("LuaRocks pack tests #blackbox #b_pack", function() | |||
25 | end) | 25 | end) |
26 | 26 | ||
27 | it("LuaRocks pack basic", function() | 27 | it("LuaRocks pack basic", function() |
28 | assert.is_true(run.luarocks_bool(test_env.quiet("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 | ||
@@ -49,7 +49,7 @@ describe("LuaRocks pack tests #blackbox #b_pack", function() | |||
49 | end) | 49 | end) |
50 | 50 | ||
51 | it("LuaRocks pack src", function() | 51 | it("LuaRocks pack src", function() |
52 | assert.is_true(run.luarocks_bool(test_env.quiet("install luasec " .. test_env.OPENSSL_DIRS))) | 52 | assert.is_true(run.luarocks_bool("install luasec " .. test_env.OPENSSL_DIRS)) |
53 | assert.is_true(run.luarocks_bool("download --rockspec luasocket 3.0rc1-2")) | 53 | assert.is_true(run.luarocks_bool("download --rockspec luasocket 3.0rc1-2")) |
54 | assert.is_true(run.luarocks_bool("pack luasocket-3.0rc1-2.rockspec")) | 54 | assert.is_true(run.luarocks_bool("pack luasocket-3.0rc1-2.rockspec")) |
55 | assert.is_true(test_env.remove_files(lfs.currentdir(), "luasocket-")) | 55 | assert.is_true(test_env.remove_files(lfs.currentdir(), "luasocket-")) |
diff --git a/spec/search_spec.lua b/spec/search_spec.lua index f75bc3c1..04f84eeb 100644 --- a/spec/search_spec.lua +++ b/spec/search_spec.lua | |||
@@ -30,6 +30,6 @@ describe("LuaRocks search tests #blackbox #b_search", function() | |||
30 | end) | 30 | end) |
31 | 31 | ||
32 | it("LuaRocks search with flag all", function() | 32 | it("LuaRocks search with flag all", function() |
33 | assert.is_true(run.luarocks_bool(test_env.quiet("search --all"))) | 33 | assert.is_true(run.luarocks_bool("search --all")) |
34 | end) | 34 | end) |
35 | end) | 35 | end) |
diff --git a/test/test_environment.lua b/test/test_environment.lua index 00213d31..8239795d 100644 --- a/test/test_environment.lua +++ b/test/test_environment.lua | |||
@@ -119,13 +119,29 @@ function test_env.execute_helper(command, print_command, env_variables) | |||
119 | end | 119 | end |
120 | 120 | ||
121 | --- Execute command and returns true/false | 121 | --- Execute command and returns true/false |
122 | -- In Lua5.1 os.execute returns numeric value, but in Lua5.2+ returns boolean | ||
123 | -- @return true/false boolean: status of the command execution | 122 | -- @return true/false boolean: status of the command execution |
124 | local function execute_bool(command, print_command, env_variables) | 123 | local function execute_bool(command, print_command, env_variables) |
125 | command = test_env.execute_helper(command, print_command, env_variables) | 124 | command = test_env.execute_helper(command, print_command, env_variables) |
126 | 125 | ||
127 | local ok = os.execute(command) | 126 | local redirect_filename |
128 | return ok == true or ok == 0 | 127 | local redirect = "" |
128 | if print_command ~= nil then | ||
129 | redirect_filename = test_env.testing_paths.luarocks_tmp.."/output.txt" | ||
130 | redirect = " > "..redirect_filename | ||
131 | end | ||
132 | local ok = os.execute(command .. redirect) | ||
133 | ok = (ok == true or ok == 0) -- normalize Lua 5.1 output to boolean | ||
134 | if redirect ~= "" then | ||
135 | if not ok then | ||
136 | local fd = io.open(redirect_filename, "r") | ||
137 | if fd then | ||
138 | print(fd:read("*a")) | ||
139 | fd:close() | ||
140 | end | ||
141 | end | ||
142 | os.remove(redirect_filename) | ||
143 | end | ||
144 | return ok | ||
129 | end | 145 | end |
130 | 146 | ||
131 | --- Execute command and returns output of command | 147 | --- Execute command and returns output of command |