Skip to content

Commit faf9b5e

Browse files
committed
test: set non-zero exit code when a test fails
After this change `make check` command will give a non-zero exit code when one of test cases fails. Also renamed 'f' to 'fiber' for readability.
1 parent ba872f1 commit faf9b5e

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

test/mysql.test.lua

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package.cpath = "../?.so;../?.dylib;./?.so;./?.dylib"
66
local mysql = require('mysql')
77
local json = require('json')
88
local tap = require('tap')
9-
local f = require('fiber')
9+
local fiber = require('fiber')
1010

1111
local host, port, user, password, db = string.match(os.getenv('MYSQL') or '',
1212
"([^:]*):([^:]*):([^:]*):([^:]*):([^:]*)")
@@ -94,14 +94,14 @@ end
9494
function test_conn_concurrent(t, p)
9595
t:plan(1)
9696
local c = p:get()
97-
local q = f.channel(2)
98-
local t1 = f.time()
99-
f.create(test_conn_fiber1, c, q)
100-
f.create(test_conn_fiber2, c, q)
97+
local q = fiber.channel(2)
98+
local t1 = fiber.time()
99+
fiber.create(test_conn_fiber1, c, q)
100+
fiber.create(test_conn_fiber2, c, q)
101101
q:get()
102102
q:get()
103103
p:put(c)
104-
t:ok(f.time() - t1 >= 0.95, 'concurrent connections')
104+
t:ok(fiber.time() - t1 >= 0.95, 'concurrent connections')
105105
end
106106

107107

@@ -116,12 +116,16 @@ function test_mysql_int64(t, p)
116116
p:put(conn)
117117
end
118118

119-
tap.test('connection old api', test_old_api, conn)
119+
local test = tap.test('mysql connector')
120+
test:plan(5)
121+
122+
test:test('connection old api', test_old_api, conn)
120123
local pool_conn = p:get()
121-
tap.test('connection old api via pool', test_old_api, pool_conn)
124+
test:test('connection old api via pool', test_old_api, pool_conn)
122125
p:put(pool_conn)
123-
tap.test('test collection connections', test_gc, p)
124-
tap.test('connection concurrent', test_conn_concurrent, p)
125-
tap.test('int64', test_mysql_int64, p)
126+
test:test('garbage collection', test_gc, p)
127+
test:test('concurrent connections', test_conn_concurrent, p)
128+
test:test('int64', test_mysql_int64, p)
126129
p:close()
127130

131+
os.exit(test:check() and 0 or 1)

0 commit comments

Comments
 (0)