Skip to content

Commit

Permalink
[test] library/pg.t: handle plan for the 3 error cases
Browse files Browse the repository at this point in the history
Some smokers run 43, some 40 tests.
Use no_plan and handle the earlier exits properly.
3 error cases: no libpg.so, service stopped, no nci thunks.
  • Loading branch information
Reini Urban committed Jul 21, 2014
1 parent 614a298 commit 1f3b66f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
+ Updated documentation for StringHandle.readall and FileHandle.readall, which
reads just the rest of the buffer if tell > 0. [GH #1084]
- Tests
+ Improve test plan for t/library/pg.t
- Community

2014-07-15 release 6.6.0
Expand Down
29 changes: 19 additions & 10 deletions t/library/pg.t
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ table, which should be created by your sysadmin.
if $I1 == 1 goto have_enough_nci

test.'skip_all'('Extra NCI thunks not available')
test.'finish'()
exit 0

have_enough_nci:
test.'plan'(N_TESTS)
test.'plan'('no_plan')
push_eh no_pg

# TODO: fix when exception handling works again
Expand All @@ -51,24 +52,31 @@ table, which should be created by your sysadmin.
have_lib:
load_bytecode 'postgres.pir'
pop_eh
test.'ok'(1, 'load_bytecode')
load_bytecode 'Pg.pir'
test.'ok'(1, 'load_bytecode Pg')

.local pmc cl, con, res
cl = new 'Pg'
test.'ok'(1, 'Pg class exists')

con = cl.'connectdb'('') # assume table = user is present
$I0 = isa con, ['Pg'; 'Conn']
test.'ok'($I0, 'con isa Pg;Conn')
$I0 = istrue con
$I1 = istrue con

if $I0 goto have_connected
test.'skip'( 39, 'no Pg connection; skipping remaining tests' )
.return()
if $I1 goto have_connected
test.'plan'(5)
test.'ok'(1, 'load_bytecode postgres')
test.'ok'(1, 'load_bytecode Pg')
test.'ok'(1, 'Pg class exists')
test.'ok'($I0, 'con isa Pg;Conn')
test.'skip'(1, 'no Pg connection; skipping remaining tests')
test.'finish'()
exit 0

have_connected:
test.'ok'(1, 'load_bytecode postgres')
test.'ok'(1, 'load_bytecode Pg')
test.'ok'(1, 'Pg class exists')
test.'ok'($I0, 'con isa Pg;Conn')

test.'ok'($I0, 'con is true after connect')
$I0 = con.'status'()
$I1 = iseq $I0, CONNECTION_OK
Expand Down Expand Up @@ -242,7 +250,8 @@ no_pg:
.local string msg
.get_results(ex)
msg = ex
test.'skip'(N_TESTS)
test.'plan'(1)
test.'skip'(1, 'loadlib pg failed')
test.'finish'()
.end

Expand Down

0 comments on commit 1f3b66f

Please sign in to comment.