Skip to content

Commit 27a7b41

Browse files
mmelentiev-mailprintercu
authored andcommitted
Fix exit code when tests failed
1 parent 99cd0d1 commit 27a7b41

File tree

6 files changed

+50
-1
lines changed

6 files changed

+50
-1
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# 0.1.1
2+
3+
- Fix exit code on failure.
4+
5+
# 0.1.0
6+
7+
- Initial implementation.

bin/luatest

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env tarantool
22

33
local runner = require('luatest').runner
4-
os.exit(runner:run() and 0 or 1)
4+
os.exit(runner:run())

test/fixtures/error.lua

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
local t = require('luatest')
2+
local g = t.group('pass')
3+
4+
g.test_1 = function()
5+
t.assertEquals(1, 1)
6+
end
7+
8+
g.test_2 = function()
9+
error('custom-error')
10+
end

test/fixtures/fail.lua

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
local t = require('luatest')
2+
local g = t.group('pass')
3+
4+
g.test_1 = function()
5+
t.assertEquals(1, 1)
6+
end
7+
8+
g.test_2 = function()
9+
t.assertEquals(1, 0)
10+
end

test/fixtures/pass.lua

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
local t = require('luatest')
2+
local g = t.group('pass')
3+
4+
g.test_1 = function()
5+
t.assertEquals(1, 1)
6+
end

test/runner_test.lua

+16
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,19 @@ g.test_run_error = function()
2626

2727
t.assertEquals(result, 1)
2828
end
29+
30+
local function run_file(file)
31+
return os.execute('bin/luatest test/fixtures/' .. file)
32+
end
33+
34+
g.test_executable_pass = function()
35+
t.assertEquals(run_file('pass.lua'), 0)
36+
end
37+
38+
g.test_executable_fail = function()
39+
t.assertEquals(run_file('fail.lua'), 256) -- luajit multiplies result by 256
40+
end
41+
42+
g.test_executable_error = function()
43+
t.assertEquals(run_file('error.lua'), 256) -- luajit multiplies result by 256
44+
end

0 commit comments

Comments
 (0)