Skip to content

Commit d63d6a8

Browse files
committed
Unindent subtest diag header
In order to make it clearer where a subest starts. This contrasts with how Test::More does it, but is easier to read for errors and aligns with how some other TAP frameworks like node tap do it. The format change will have no impact on how TAP-parsing tools like `pg_prove` interpret test output, but could break diff-based tooling such as `pg_regress`. That change is demonstrated in the expected files modified in this commit.
1 parent 335e318 commit d63d6a8

17 files changed

+129
-124
lines changed

Changes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ Revision history for pgTAP
99
the analysis.
1010
* Fixed a pluralization error reporting xUnit test failures to report "failed 1
1111
test" instead of "failed 1 tests".
12+
* Removed the indentation for diagnostic comments at the start of subtests to
13+
make it easier to see where they start and end. This changes the output
14+
format, which will not affect tests run by `pg_prove`, but will break tests
15+
that depend on diffing files, as `pg_regress` does. Thanks to Matt DeLuco for
16+
highlighting the visual confusion of the indented diagnostic (#264).
1217

1318
1.2.0 2021-12-05T18:08:13Z
1419
--------------------------

doc/pgtap.mmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8411,11 +8411,11 @@ The output, assuming a single startup test, two subtests, and a single
84118411
shutdown test, will look something like this:
84128412

84138413
ok 1 - Startup test
8414-
# Subtest: public.test_this()
8414+
# Subtest: public.test_this()
84158415
ok 1 - simple pass
84168416
ok 2 - another simple pass
84178417
ok 2 - public.test_this()
8418-
# Subtest: public.test_that()
8418+
# Subtest: public.test_that()
84198419
ok 1 - that simple
84208420
ok 2 - that simple 2
84218421
ok 3 - public.test_that()

sql/pgtap--1.2.0--1.2.1.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ BEGIN
2929
FOR i IN 1..COALESCE(array_upper(tests, 1), 0) LOOP
3030

3131
-- What subtest are we running?
32-
RETURN NEXT ' ' || diag_test_name('Subtest: ' || tests[i]);
32+
RETURN NEXT diag_test_name('Subtest: ' || tests[i]);
3333

3434
-- Reset the results.
3535
tok := TRUE;

sql/pgtap.sql.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6567,7 +6567,7 @@ BEGIN
65676567
FOR i IN 1..COALESCE(array_upper(tests, 1), 0) LOOP
65686568

65696569
-- What subtest are we running?
6570-
RETURN NEXT ' ' || diag_test_name('Subtest: ' || tests[i]);
6570+
RETURN NEXT diag_test_name('Subtest: ' || tests[i]);
65716571

65726572
-- Reset the results.
65736573
tok := TRUE;

test/expected/runjusttests.out

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
\unset ECHO
2-
# Subtest: whatever."test ident"()
2+
# Subtest: whatever."test ident"()
33
ok 1 - ident
44
ok 2 - ident 2
55
1..2
66
ok 1 - whatever."test ident"
7-
# Subtest: whatever.testnada()
7+
# Subtest: whatever.testnada()
88
1..0
99
# No tests run!
1010
not ok 2 - whatever.testnada
1111
# Failed test 2: "whatever.testnada"
12-
# Subtest: whatever.testplpgsql()
12+
# Subtest: whatever.testplpgsql()
1313
ok 1 - plpgsql simple
1414
ok 2 - plpgsql simple 2
1515
ok 3 - Should be a 1 in the test table
1616
1..3
1717
ok 3 - whatever.testplpgsql
18-
# Subtest: whatever.testplpgsqldie()
18+
# Subtest: whatever.testplpgsqldie()
1919
# Test died: P0001: This test should die, but not halt execution.
2020
# Note that in some cases we get what appears to be a duplicate context message, but that is due to Postgres itself.
2121
# DETAIL: DETAIL
@@ -32,20 +32,20 @@ ok 3 - whatever.testplpgsql
3232
# SQL function "runtests" statement 1
3333
not ok 4 - whatever.testplpgsqldie
3434
# Failed test 4: "whatever.testplpgsqldie"
35-
# Subtest: whatever.testthis()
35+
# Subtest: whatever.testthis()
3636
ok 1 - simple pass
3737
ok 2 - another simple pass
3838
1..2
3939
ok 5 - whatever.testthis
40-
# Subtest: whatever.testy()
40+
# Subtest: whatever.testy()
4141
ok 1 - pass
4242
not ok 2 - this test intentionally fails
4343
# Failed test 2: "this test intentionally fails"
4444
1..2
4545
# Looks like you failed 1 test of 2
4646
not ok 6 - whatever.testy
4747
# Failed test 6: "whatever.testy"
48-
# Subtest: whatever.testz()
48+
# Subtest: whatever.testz()
4949
ok 1 - Late test should find nothing in the test table
5050
1..1
5151
ok 7 - whatever.testz

test/expected/runjusttests_1.out

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
\unset ECHO
2-
# Subtest: whatever."test ident"()
2+
# Subtest: whatever."test ident"()
33
ok 1 - ident
44
ok 2 - ident 2
55
1..2
66
ok 1 - whatever."test ident"
7-
# Subtest: whatever.testnada()
7+
# Subtest: whatever.testnada()
88
1..0
99
# No tests run!
1010
not ok 2 - whatever.testnada
1111
# Failed test 2: "whatever.testnada"
12-
# Subtest: whatever.testplpgsql()
12+
# Subtest: whatever.testplpgsql()
1313
ok 1 - plpgsql simple
1414
ok 2 - plpgsql simple 2
1515
ok 3 - Should be a 1 in the test table
1616
1..3
1717
ok 3 - whatever.testplpgsql
18-
# Subtest: whatever.testplpgsqldie()
18+
# Subtest: whatever.testplpgsqldie()
1919
# Test died: P0001: This test should die, but not halt execution.
2020
# Note that in some cases we get what appears to be a duplicate context message, but that is due to Postgres itself.
2121
# DETAIL: DETAIL
@@ -32,20 +32,20 @@ ok 3 - whatever.testplpgsql
3232
# SQL function "runtests" statement 1
3333
not ok 4 - whatever.testplpgsqldie
3434
# Failed test 4: "whatever.testplpgsqldie"
35-
# Subtest: whatever.testthis()
35+
# Subtest: whatever.testthis()
3636
ok 1 - simple pass
3737
ok 2 - another simple pass
3838
1..2
3939
ok 5 - whatever.testthis
40-
# Subtest: whatever.testy()
40+
# Subtest: whatever.testy()
4141
ok 1 - pass
4242
not ok 2 - this test intentionally fails
4343
# Failed test 2: "this test intentionally fails"
4444
1..2
4545
# Looks like you failed 1 test of 2
4646
not ok 6 - whatever.testy
4747
# Failed test 6: "whatever.testy"
48-
# Subtest: whatever.testz()
48+
# Subtest: whatever.testz()
4949
ok 1 - Late test should find nothing in the test table
5050
1..1
5151
ok 7 - whatever.testz

test/expected/runjusttests_2.out

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
\unset ECHO
2-
# Subtest: whatever."test ident"()
2+
# Subtest: whatever."test ident"()
33
ok 1 - ident
44
ok 2 - ident 2
55
1..2
66
ok 1 - whatever."test ident"
7-
# Subtest: whatever.testnada()
7+
# Subtest: whatever.testnada()
88
1..0
99
# No tests run!
1010
not ok 2 - whatever.testnada
1111
# Failed test 2: "whatever.testnada"
12-
# Subtest: whatever.testplpgsql()
12+
# Subtest: whatever.testplpgsql()
1313
ok 1 - plpgsql simple
1414
ok 2 - plpgsql simple 2
1515
ok 3 - Should be a 1 in the test table
1616
1..3
1717
ok 3 - whatever.testplpgsql
18-
# Subtest: whatever.testplpgsqldie()
18+
# Subtest: whatever.testplpgsqldie()
1919
# Test died: P0001: This test should die, but not halt execution.
2020
# Note that in some cases we get what appears to be a duplicate context message, but that is due to Postgres itself.
2121
# DETAIL: DETAIL
@@ -27,20 +27,20 @@ ok 3 - whatever.testplpgsql
2727
# SQL function "runtests" statement 1
2828
not ok 4 - whatever.testplpgsqldie
2929
# Failed test 4: "whatever.testplpgsqldie"
30-
# Subtest: whatever.testthis()
30+
# Subtest: whatever.testthis()
3131
ok 1 - simple pass
3232
ok 2 - another simple pass
3333
1..2
3434
ok 5 - whatever.testthis
35-
# Subtest: whatever.testy()
35+
# Subtest: whatever.testy()
3636
ok 1 - pass
3737
not ok 2 - this test intentionally fails
3838
# Failed test 2: "this test intentionally fails"
3939
1..2
4040
# Looks like you failed 1 test of 2
4141
not ok 6 - whatever.testy
4242
# Failed test 6: "whatever.testy"
43-
# Subtest: whatever.testz()
43+
# Subtest: whatever.testz()
4444
ok 1 - Late test should find nothing in the test table
4545
1..1
4646
ok 7 - whatever.testz

test/expected/runjusttests_3.out

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
\unset ECHO
2-
# Subtest: whatever."test ident"()
2+
# Subtest: whatever."test ident"()
33
ok 1 - ident
44
ok 2 - ident 2
55
1..2
66
ok 1 - whatever."test ident"
7-
# Subtest: whatever.testnada()
7+
# Subtest: whatever.testnada()
88
1..0
99
# No tests run!
1010
not ok 2 - whatever.testnada
1111
# Failed test 2: "whatever.testnada"
12-
# Subtest: whatever.testplpgsql()
12+
# Subtest: whatever.testplpgsql()
1313
ok 1 - plpgsql simple
1414
ok 2 - plpgsql simple 2
1515
ok 3 - Should be a 1 in the test table
1616
1..3
1717
ok 3 - whatever.testplpgsql
18-
# Subtest: whatever.testplpgsqldie()
18+
# Subtest: whatever.testplpgsqldie()
1919
# Test died: P0001: This test should die, but not halt execution.
2020
# Note that in some cases we get what appears to be a duplicate context message, but that is due to Postgres itself.
2121
# DETAIL: DETAIL
@@ -27,20 +27,20 @@ ok 3 - whatever.testplpgsql
2727
# SQL function "runtests" statement 1
2828
not ok 4 - whatever.testplpgsqldie
2929
# Failed test 4: "whatever.testplpgsqldie"
30-
# Subtest: whatever.testthis()
30+
# Subtest: whatever.testthis()
3131
ok 1 - simple pass
3232
ok 2 - another simple pass
3333
1..2
3434
ok 5 - whatever.testthis
35-
# Subtest: whatever.testy()
35+
# Subtest: whatever.testy()
3636
ok 1 - pass
3737
not ok 2 - this test intentionally fails
3838
# Failed test 2: "this test intentionally fails"
3939
1..2
4040
# Looks like you failed 1 test of 2
4141
not ok 6 - whatever.testy
4242
# Failed test 6: "whatever.testy"
43-
# Subtest: whatever.testz()
43+
# Subtest: whatever.testz()
4444
ok 1 - Late test should find nothing in the test table
4545
1..1
4646
ok 7 - whatever.testz

test/expected/runjusttests_4.out

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
\unset ECHO
2-
# Subtest: whatever."test ident"()
2+
# Subtest: whatever."test ident"()
33
ok 1 - ident
44
ok 2 - ident 2
55
1..2
66
ok 1 - whatever."test ident"
7-
# Subtest: whatever.testnada()
7+
# Subtest: whatever.testnada()
88
1..0
99
# No tests run!
1010
not ok 2 - whatever.testnada
1111
# Failed test 2: "whatever.testnada"
12-
# Subtest: whatever.testplpgsql()
12+
# Subtest: whatever.testplpgsql()
1313
ok 1 - plpgsql simple
1414
ok 2 - plpgsql simple 2
1515
ok 3 - Should be a 1 in the test table
1616
1..3
1717
ok 3 - whatever.testplpgsql
18-
# Subtest: whatever.testplpgsqldie()
18+
# Subtest: whatever.testplpgsqldie()
1919
# Test died: P0001: This test should die, but not halt execution.
2020
# Note that in some cases we get what appears to be a duplicate context message, but that is due to Postgres itself.
2121
not ok 4 - whatever.testplpgsqldie
2222
# Failed test 4: "whatever.testplpgsqldie"
23-
# Subtest: whatever.testthis()
23+
# Subtest: whatever.testthis()
2424
ok 1 - simple pass
2525
ok 2 - another simple pass
2626
1..2
2727
ok 5 - whatever.testthis
28-
# Subtest: whatever.testy()
28+
# Subtest: whatever.testy()
2929
ok 1 - pass
3030
not ok 2 - this test intentionally fails
3131
# Failed test 2: "this test intentionally fails"
3232
1..2
3333
# Looks like you failed 1 test of 2
3434
not ok 6 - whatever.testy
3535
# Failed test 6: "whatever.testy"
36-
# Subtest: whatever.testz()
36+
# Subtest: whatever.testz()
3737
ok 1 - Late test should find nothing in the test table
3838
1..1
3939
ok 7 - whatever.testz

test/expected/runjusttests_5.out

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
\unset ECHO
2-
# Subtest: whatever."test ident"()
2+
# Subtest: whatever."test ident"()
33
ok 1 - ident
44
ok 2 - ident 2
55
1..2
66
ok 1 - whatever."test ident"
7-
# Subtest: whatever.testnada()
7+
# Subtest: whatever.testnada()
88
1..0
99
# No tests run!
1010
not ok 2 - whatever.testnada
1111
# Failed test 2: "whatever.testnada"
12-
# Subtest: whatever.testplpgsql()
12+
# Subtest: whatever.testplpgsql()
1313
ok 1 - plpgsql simple
1414
ok 2 - plpgsql simple 2
1515
ok 3 - Should be a 1 in the test table
1616
1..3
1717
ok 3 - whatever.testplpgsql
18-
# Subtest: whatever.testplpgsqldie()
18+
# Subtest: whatever.testplpgsqldie()
1919
# Test died: P0001: This test should die, but not halt execution.
2020
# Note that in some cases we get what appears to be a duplicate context message, but that is due to Postgres itself.
2121
# DETAIL: DETAIL
@@ -33,20 +33,20 @@ ok 3 - whatever.testplpgsql
3333
# SQL function "runtests" statement 1
3434
not ok 4 - whatever.testplpgsqldie
3535
# Failed test 4: "whatever.testplpgsqldie"
36-
# Subtest: whatever.testthis()
36+
# Subtest: whatever.testthis()
3737
ok 1 - simple pass
3838
ok 2 - another simple pass
3939
1..2
4040
ok 5 - whatever.testthis
41-
# Subtest: whatever.testy()
41+
# Subtest: whatever.testy()
4242
ok 1 - pass
4343
not ok 2 - this test intentionally fails
4444
# Failed test 2: "this test intentionally fails"
4545
1..2
4646
# Looks like you failed 1 test of 2
4747
not ok 6 - whatever.testy
4848
# Failed test 6: "whatever.testy"
49-
# Subtest: whatever.testz()
49+
# Subtest: whatever.testz()
5050
ok 1 - Late test should find nothing in the test table
5151
1..1
5252
ok 7 - whatever.testz

0 commit comments

Comments
 (0)