diff options
Diffstat (limited to 'tap/tests')
64 files changed, 1714 insertions, 0 deletions
diff --git a/tap/tests/Makefile.am b/tap/tests/Makefile.am new file mode 100644 index 00000000..481a9672 --- /dev/null +++ b/tap/tests/Makefile.am | |||
@@ -0,0 +1,7 @@ | |||
1 | SUBDIRS= diag | ||
2 | SUBDIRS+= fail | ||
3 | SUBDIRS+= ok | ||
4 | SUBDIRS+= pass | ||
5 | SUBDIRS+= plan | ||
6 | SUBDIRS+= skip | ||
7 | SUBDIRS+= todo | ||
diff --git a/tap/tests/README b/tap/tests/README new file mode 100644 index 00000000..a15fec28 --- /dev/null +++ b/tap/tests/README | |||
@@ -0,0 +1,12 @@ | |||
1 | Most of the tests follow the same pattern. | ||
2 | |||
3 | * test.pl that uses Test::More, and demonstrates whatever functionality | ||
4 | that we're trying to test. This is the reference code. | ||
5 | |||
6 | * test.c, which tests the libtap reimplementation of the same functionality. | ||
7 | |||
8 | * test.t, which compiles the .c program, runs both test scripts, and then | ||
9 | diffs their output to make sure it's identical. | ||
10 | |||
11 | Right now, test.t is identical in every directory. This sucks somewhat. | ||
12 | It should either be a symlink to a common script | ||
diff --git a/tap/tests/diag/Makefile.am b/tap/tests/diag/Makefile.am new file mode 100644 index 00000000..c1ccb751 --- /dev/null +++ b/tap/tests/diag/Makefile.am | |||
@@ -0,0 +1,13 @@ | |||
1 | |||
2 | TESTS = test.t | ||
3 | TESTS_ENVIRONMENT = $(SHELL) | ||
4 | |||
5 | EXTRA_DIST = $(TESTS) test.pl | ||
6 | |||
7 | check_PROGRAMS = test | ||
8 | |||
9 | test_CFLAGS = -g -I../../src | ||
10 | test_LDFLAGS = -L../../src | ||
11 | test_LDADD = -ltap | ||
12 | |||
13 | CLEANFILES = test.o test.c.out test.pl.out | ||
diff --git a/tap/tests/diag/test.c b/tap/tests/diag/test.c new file mode 100644 index 00000000..401db647 --- /dev/null +++ b/tap/tests/diag/test.c | |||
@@ -0,0 +1,46 @@ | |||
1 | /*- | ||
2 | * Copyright (c) 2004 Nik Clayton | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * 1. Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * 2. Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * | ||
14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
24 | * SUCH DAMAGE. | ||
25 | */ | ||
26 | |||
27 | #include <stdio.h> | ||
28 | |||
29 | #include "tap.h" | ||
30 | |||
31 | int | ||
32 | main(int argc, char *argv[]) | ||
33 | { | ||
34 | unsigned int rc = 0; | ||
35 | |||
36 | plan_tests(2); | ||
37 | |||
38 | rc = diag("A diagnostic message"); | ||
39 | diag("Returned: %d", rc); | ||
40 | |||
41 | /* Make sure the failure is passed through */ | ||
42 | ok(1, "test 1") || diag("ok() failed, and shouldn't"); | ||
43 | ok(0, "test 2") || diag("ok() passed, and shouldn't"); | ||
44 | |||
45 | return exit_status(); | ||
46 | } | ||
diff --git a/tap/tests/diag/test.pl b/tap/tests/diag/test.pl new file mode 100644 index 00000000..621dc27d --- /dev/null +++ b/tap/tests/diag/test.pl | |||
@@ -0,0 +1,16 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | use warnings; | ||
4 | use strict; | ||
5 | |||
6 | use Test::More; | ||
7 | |||
8 | my $rc = 0; | ||
9 | |||
10 | plan tests => 2; | ||
11 | |||
12 | $rc = diag("A diagnostic message"); | ||
13 | diag("Returned: $rc"); | ||
14 | |||
15 | ok(1, 'test 1') or diag "ok() failed, and shouldn't"; | ||
16 | ok(0, 'test 2') or diag "ok() passed, and shouldn't"; | ||
diff --git a/tap/tests/diag/test.t b/tap/tests/diag/test.t new file mode 100644 index 00000000..bf0fe8f1 --- /dev/null +++ b/tap/tests/diag/test.t | |||
@@ -0,0 +1,29 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | cd `dirname $0` | ||
4 | |||
5 | echo '1..2' | ||
6 | |||
7 | make 2>&1 > /dev/null | ||
8 | |||
9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
10 | perlstatus=$? | ||
11 | |||
12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
13 | cstatus=$? | ||
14 | |||
15 | diff -u test.pl.out test.c.out | ||
16 | |||
17 | if [ $? -eq 0 ]; then | ||
18 | echo 'ok 1 - output is identical' | ||
19 | else | ||
20 | echo 'not ok 1 - output is identical' | ||
21 | fi | ||
22 | |||
23 | if [ $perlstatus -eq $cstatus ]; then | ||
24 | echo 'ok 2 - status code' | ||
25 | else | ||
26 | echo 'not ok 2 - status code' | ||
27 | echo "# perlstatus = $perlstatus" | ||
28 | echo "# cstatus = $cstatus" | ||
29 | fi | ||
diff --git a/tap/tests/fail/Makefile.am b/tap/tests/fail/Makefile.am new file mode 100644 index 00000000..c1ccb751 --- /dev/null +++ b/tap/tests/fail/Makefile.am | |||
@@ -0,0 +1,13 @@ | |||
1 | |||
2 | TESTS = test.t | ||
3 | TESTS_ENVIRONMENT = $(SHELL) | ||
4 | |||
5 | EXTRA_DIST = $(TESTS) test.pl | ||
6 | |||
7 | check_PROGRAMS = test | ||
8 | |||
9 | test_CFLAGS = -g -I../../src | ||
10 | test_LDFLAGS = -L../../src | ||
11 | test_LDADD = -ltap | ||
12 | |||
13 | CLEANFILES = test.o test.c.out test.pl.out | ||
diff --git a/tap/tests/fail/test.c b/tap/tests/fail/test.c new file mode 100644 index 00000000..621b6c29 --- /dev/null +++ b/tap/tests/fail/test.c | |||
@@ -0,0 +1,46 @@ | |||
1 | /*- | ||
2 | * Copyright (c) 2004 Nik Clayton | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * 1. Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * 2. Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * | ||
14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
24 | * SUCH DAMAGE. | ||
25 | */ | ||
26 | |||
27 | #include <stdio.h> | ||
28 | |||
29 | #include "tap.h" | ||
30 | |||
31 | int | ||
32 | main(int argc, char *argv[]) | ||
33 | { | ||
34 | unsigned int rc = 0; | ||
35 | |||
36 | rc = plan_tests(2); | ||
37 | diag("Returned: %d", rc); | ||
38 | |||
39 | rc = fail("test to fail"); | ||
40 | diag("Returned: %d", rc); | ||
41 | |||
42 | rc = fail("test to fail %s", "with extra string"); | ||
43 | diag("Returned: %d", rc); | ||
44 | |||
45 | return exit_status(); | ||
46 | } | ||
diff --git a/tap/tests/fail/test.pl b/tap/tests/fail/test.pl new file mode 100644 index 00000000..73de1a7b --- /dev/null +++ b/tap/tests/fail/test.pl | |||
@@ -0,0 +1,17 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | use warnings; | ||
4 | use strict; | ||
5 | |||
6 | use Test::More; | ||
7 | |||
8 | my $rc = 0; | ||
9 | |||
10 | $rc = plan tests => 2; | ||
11 | diag("Returned: " . sprintf('%d', $rc)); | ||
12 | |||
13 | $rc = fail('test to fail'); | ||
14 | diag("Returned: $rc"); | ||
15 | |||
16 | $rc = fail('test to fail with extra string'); | ||
17 | diag("Returned: $rc"); | ||
diff --git a/tap/tests/fail/test.t b/tap/tests/fail/test.t new file mode 100644 index 00000000..bf0fe8f1 --- /dev/null +++ b/tap/tests/fail/test.t | |||
@@ -0,0 +1,29 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | cd `dirname $0` | ||
4 | |||
5 | echo '1..2' | ||
6 | |||
7 | make 2>&1 > /dev/null | ||
8 | |||
9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
10 | perlstatus=$? | ||
11 | |||
12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
13 | cstatus=$? | ||
14 | |||
15 | diff -u test.pl.out test.c.out | ||
16 | |||
17 | if [ $? -eq 0 ]; then | ||
18 | echo 'ok 1 - output is identical' | ||
19 | else | ||
20 | echo 'not ok 1 - output is identical' | ||
21 | fi | ||
22 | |||
23 | if [ $perlstatus -eq $cstatus ]; then | ||
24 | echo 'ok 2 - status code' | ||
25 | else | ||
26 | echo 'not ok 2 - status code' | ||
27 | echo "# perlstatus = $perlstatus" | ||
28 | echo "# cstatus = $cstatus" | ||
29 | fi | ||
diff --git a/tap/tests/ok/Makefile.am b/tap/tests/ok/Makefile.am new file mode 100644 index 00000000..c9497480 --- /dev/null +++ b/tap/tests/ok/Makefile.am | |||
@@ -0,0 +1,3 @@ | |||
1 | SUBDIRS = ok | ||
2 | SUBDIRS += ok-hash | ||
3 | SUBDIRS += ok-numeric | ||
diff --git a/tap/tests/ok/ok-hash/Makefile.am b/tap/tests/ok/ok-hash/Makefile.am new file mode 100644 index 00000000..91d880e7 --- /dev/null +++ b/tap/tests/ok/ok-hash/Makefile.am | |||
@@ -0,0 +1,13 @@ | |||
1 | |||
2 | TESTS = test.t | ||
3 | TESTS_ENVIRONMENT = $(SHELL) | ||
4 | |||
5 | EXTRA_DIST = $(TESTS) test.pl | ||
6 | |||
7 | check_PROGRAMS = test | ||
8 | |||
9 | test_CFLAGS = -g -I../../../src | ||
10 | test_LDFLAGS = -L../../../src | ||
11 | test_LDADD = -ltap | ||
12 | |||
13 | CLEANFILES = test.o test.c.out test.pl.out | ||
diff --git a/tap/tests/ok/ok-hash/test.c b/tap/tests/ok/ok-hash/test.c new file mode 100644 index 00000000..16be137a --- /dev/null +++ b/tap/tests/ok/ok-hash/test.c | |||
@@ -0,0 +1,52 @@ | |||
1 | /*- | ||
2 | * Copyright (c) 2004 Nik Clayton | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * 1. Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * 2. Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * | ||
14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
24 | * SUCH DAMAGE. | ||
25 | */ | ||
26 | |||
27 | #include <stdio.h> | ||
28 | |||
29 | #include "tap.h" | ||
30 | |||
31 | int | ||
32 | main(int argc, char *argv[]) | ||
33 | { | ||
34 | unsigned int rc = 0; | ||
35 | |||
36 | rc = plan_tests(4); | ||
37 | diag("Returned: %d", rc); | ||
38 | |||
39 | rc = ok(1, "Test with no hash"); | ||
40 | diag("Returned: %d", rc); | ||
41 | |||
42 | rc = ok(1, "Test with one # hash"); | ||
43 | diag("Returned: %d", rc); | ||
44 | |||
45 | rc = ok(1, "Test with # two # hashes"); | ||
46 | diag("Returned: %d", rc); | ||
47 | |||
48 | rc = ok(1, "Test with ## back to back hashes"); | ||
49 | diag("Returned: %d", rc); | ||
50 | |||
51 | return exit_status(); | ||
52 | } | ||
diff --git a/tap/tests/ok/ok-hash/test.pl b/tap/tests/ok/ok-hash/test.pl new file mode 100644 index 00000000..306ddca0 --- /dev/null +++ b/tap/tests/ok/ok-hash/test.pl | |||
@@ -0,0 +1,24 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | use warnings; | ||
4 | use strict; | ||
5 | |||
6 | use Test::More; | ||
7 | |||
8 | my $rc = 0; | ||
9 | |||
10 | $rc = plan tests => 4; | ||
11 | diag("Returned: " . sprintf("%d", $rc)); | ||
12 | |||
13 | |||
14 | $rc = ok(1, 'Test with no hash'); | ||
15 | diag("Returned: $rc"); | ||
16 | |||
17 | $rc = ok(1, 'Test with one # hash'); | ||
18 | diag("Returned: $rc"); | ||
19 | |||
20 | $rc = ok(1, 'Test with # two # hashes'); | ||
21 | diag("Returned: $rc"); | ||
22 | |||
23 | $rc = ok(1, 'Test with ## back to back hashes'); | ||
24 | diag("Returned: $rc"); | ||
diff --git a/tap/tests/ok/ok-hash/test.t b/tap/tests/ok/ok-hash/test.t new file mode 100644 index 00000000..bf0fe8f1 --- /dev/null +++ b/tap/tests/ok/ok-hash/test.t | |||
@@ -0,0 +1,29 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | cd `dirname $0` | ||
4 | |||
5 | echo '1..2' | ||
6 | |||
7 | make 2>&1 > /dev/null | ||
8 | |||
9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
10 | perlstatus=$? | ||
11 | |||
12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
13 | cstatus=$? | ||
14 | |||
15 | diff -u test.pl.out test.c.out | ||
16 | |||
17 | if [ $? -eq 0 ]; then | ||
18 | echo 'ok 1 - output is identical' | ||
19 | else | ||
20 | echo 'not ok 1 - output is identical' | ||
21 | fi | ||
22 | |||
23 | if [ $perlstatus -eq $cstatus ]; then | ||
24 | echo 'ok 2 - status code' | ||
25 | else | ||
26 | echo 'not ok 2 - status code' | ||
27 | echo "# perlstatus = $perlstatus" | ||
28 | echo "# cstatus = $cstatus" | ||
29 | fi | ||
diff --git a/tap/tests/ok/ok-numeric/Makefile.am b/tap/tests/ok/ok-numeric/Makefile.am new file mode 100644 index 00000000..91d880e7 --- /dev/null +++ b/tap/tests/ok/ok-numeric/Makefile.am | |||
@@ -0,0 +1,13 @@ | |||
1 | |||
2 | TESTS = test.t | ||
3 | TESTS_ENVIRONMENT = $(SHELL) | ||
4 | |||
5 | EXTRA_DIST = $(TESTS) test.pl | ||
6 | |||
7 | check_PROGRAMS = test | ||
8 | |||
9 | test_CFLAGS = -g -I../../../src | ||
10 | test_LDFLAGS = -L../../../src | ||
11 | test_LDADD = -ltap | ||
12 | |||
13 | CLEANFILES = test.o test.c.out test.pl.out | ||
diff --git a/tap/tests/ok/ok-numeric/test.c b/tap/tests/ok/ok-numeric/test.c new file mode 100644 index 00000000..0e33a748 --- /dev/null +++ b/tap/tests/ok/ok-numeric/test.c | |||
@@ -0,0 +1,49 @@ | |||
1 | /*- | ||
2 | * Copyright (c) 2004 Nik Clayton | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * 1. Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * 2. Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * | ||
14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
24 | * SUCH DAMAGE. | ||
25 | */ | ||
26 | |||
27 | #include <stdio.h> | ||
28 | |||
29 | #include "tap.h" | ||
30 | |||
31 | int | ||
32 | main(int argc, char *argv[]) | ||
33 | { | ||
34 | unsigned int rc = 0; | ||
35 | |||
36 | rc = plan_tests(3); | ||
37 | diag("Returned: %d", rc); | ||
38 | |||
39 | rc = ok(1, "First test"); | ||
40 | diag("Returned: %d", rc); | ||
41 | |||
42 | rc = ok(1, "1"); | ||
43 | diag("Returned: %d", rc); | ||
44 | |||
45 | rc = ok(1, "Third test"); | ||
46 | diag("Returned: %d", rc); | ||
47 | |||
48 | return exit_status(); | ||
49 | } | ||
diff --git a/tap/tests/ok/ok-numeric/test.pl b/tap/tests/ok/ok-numeric/test.pl new file mode 100644 index 00000000..86f165f2 --- /dev/null +++ b/tap/tests/ok/ok-numeric/test.pl | |||
@@ -0,0 +1,21 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | use warnings; | ||
4 | use strict; | ||
5 | |||
6 | use Test::More; | ||
7 | |||
8 | my $rc = 0; | ||
9 | |||
10 | $rc = plan tests => 3; | ||
11 | diag("Returned: " . sprintf("%d", $rc)); | ||
12 | |||
13 | |||
14 | $rc = ok(1, 'First test'); | ||
15 | diag("Returned: $rc"); | ||
16 | |||
17 | $rc = ok(1, '1'); | ||
18 | diag("Returned: $rc"); | ||
19 | |||
20 | $rc = ok(1, 'Third test'); | ||
21 | diag("Returned: $rc"); | ||
diff --git a/tap/tests/ok/ok-numeric/test.t b/tap/tests/ok/ok-numeric/test.t new file mode 100644 index 00000000..bf0fe8f1 --- /dev/null +++ b/tap/tests/ok/ok-numeric/test.t | |||
@@ -0,0 +1,29 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | cd `dirname $0` | ||
4 | |||
5 | echo '1..2' | ||
6 | |||
7 | make 2>&1 > /dev/null | ||
8 | |||
9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
10 | perlstatus=$? | ||
11 | |||
12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
13 | cstatus=$? | ||
14 | |||
15 | diff -u test.pl.out test.c.out | ||
16 | |||
17 | if [ $? -eq 0 ]; then | ||
18 | echo 'ok 1 - output is identical' | ||
19 | else | ||
20 | echo 'not ok 1 - output is identical' | ||
21 | fi | ||
22 | |||
23 | if [ $perlstatus -eq $cstatus ]; then | ||
24 | echo 'ok 2 - status code' | ||
25 | else | ||
26 | echo 'not ok 2 - status code' | ||
27 | echo "# perlstatus = $perlstatus" | ||
28 | echo "# cstatus = $cstatus" | ||
29 | fi | ||
diff --git a/tap/tests/ok/ok/Makefile.am b/tap/tests/ok/ok/Makefile.am new file mode 100644 index 00000000..91d880e7 --- /dev/null +++ b/tap/tests/ok/ok/Makefile.am | |||
@@ -0,0 +1,13 @@ | |||
1 | |||
2 | TESTS = test.t | ||
3 | TESTS_ENVIRONMENT = $(SHELL) | ||
4 | |||
5 | EXTRA_DIST = $(TESTS) test.pl | ||
6 | |||
7 | check_PROGRAMS = test | ||
8 | |||
9 | test_CFLAGS = -g -I../../../src | ||
10 | test_LDFLAGS = -L../../../src | ||
11 | test_LDADD = -ltap | ||
12 | |||
13 | CLEANFILES = test.o test.c.out test.pl.out | ||
diff --git a/tap/tests/ok/ok/test.c b/tap/tests/ok/ok/test.c new file mode 100644 index 00000000..ae04f2e4 --- /dev/null +++ b/tap/tests/ok/ok/test.c | |||
@@ -0,0 +1,55 @@ | |||
1 | /*- | ||
2 | * Copyright (c) 2004 Nik Clayton | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * 1. Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * 2. Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * | ||
14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
24 | * SUCH DAMAGE. | ||
25 | */ | ||
26 | |||
27 | #include <stdio.h> | ||
28 | |||
29 | #include "tap.h" | ||
30 | |||
31 | int | ||
32 | main(int argc, char *argv[]) | ||
33 | { | ||
34 | unsigned int rc = 0; | ||
35 | |||
36 | rc = plan_tests(5); | ||
37 | diag("Returned: %d", rc); | ||
38 | |||
39 | rc = ok(1 == 1, "1 equals 1"); | ||
40 | diag("Returned: %d", rc); | ||
41 | |||
42 | rc = ok(1 == 1, "1 equals %d", 1); | ||
43 | diag("Returned: %d", rc); | ||
44 | |||
45 | rc = ok1(1 == 1); | ||
46 | diag("Returned: %d", rc); | ||
47 | |||
48 | rc = ok(1 == 2, "1 equals 2"); | ||
49 | diag("Returned: %d", rc); | ||
50 | |||
51 | rc = ok1(1 == 2); | ||
52 | diag("Returned: %d", rc); | ||
53 | |||
54 | return exit_status(); | ||
55 | } | ||
diff --git a/tap/tests/ok/ok/test.pl b/tap/tests/ok/ok/test.pl new file mode 100644 index 00000000..59f41819 --- /dev/null +++ b/tap/tests/ok/ok/test.pl | |||
@@ -0,0 +1,27 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | use warnings; | ||
4 | use strict; | ||
5 | |||
6 | use Test::More; | ||
7 | |||
8 | my $rc = 0; | ||
9 | |||
10 | $rc = plan tests => 5; | ||
11 | diag("Returned: " . sprintf("%d", $rc)); | ||
12 | |||
13 | |||
14 | $rc = ok(1 == 1, '1 equals 1'); # Test ok() passes when it should | ||
15 | diag("Returned: $rc"); | ||
16 | |||
17 | $rc = ok(1 == 1, '1 equals 1'); # Used for %d testing in test.c | ||
18 | diag("Returned: $rc"); | ||
19 | |||
20 | $rc = ok(1 == 1, '1 == 1'); # Test ok1() passes when it should | ||
21 | diag("Returned: $rc"); | ||
22 | |||
23 | $rc = ok(1 == 2, '1 equals 2'); # Test ok() fails when it should | ||
24 | diag("Returned: $rc"); | ||
25 | |||
26 | $rc = ok(1 == 2, '1 == 2'); # Test ok1() fails when it should | ||
27 | diag("Returned: $rc"); | ||
diff --git a/tap/tests/ok/ok/test.t b/tap/tests/ok/ok/test.t new file mode 100644 index 00000000..bf0fe8f1 --- /dev/null +++ b/tap/tests/ok/ok/test.t | |||
@@ -0,0 +1,29 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | cd `dirname $0` | ||
4 | |||
5 | echo '1..2' | ||
6 | |||
7 | make 2>&1 > /dev/null | ||
8 | |||
9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
10 | perlstatus=$? | ||
11 | |||
12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
13 | cstatus=$? | ||
14 | |||
15 | diff -u test.pl.out test.c.out | ||
16 | |||
17 | if [ $? -eq 0 ]; then | ||
18 | echo 'ok 1 - output is identical' | ||
19 | else | ||
20 | echo 'not ok 1 - output is identical' | ||
21 | fi | ||
22 | |||
23 | if [ $perlstatus -eq $cstatus ]; then | ||
24 | echo 'ok 2 - status code' | ||
25 | else | ||
26 | echo 'not ok 2 - status code' | ||
27 | echo "# perlstatus = $perlstatus" | ||
28 | echo "# cstatus = $cstatus" | ||
29 | fi | ||
diff --git a/tap/tests/pass/Makefile.am b/tap/tests/pass/Makefile.am new file mode 100644 index 00000000..c1ccb751 --- /dev/null +++ b/tap/tests/pass/Makefile.am | |||
@@ -0,0 +1,13 @@ | |||
1 | |||
2 | TESTS = test.t | ||
3 | TESTS_ENVIRONMENT = $(SHELL) | ||
4 | |||
5 | EXTRA_DIST = $(TESTS) test.pl | ||
6 | |||
7 | check_PROGRAMS = test | ||
8 | |||
9 | test_CFLAGS = -g -I../../src | ||
10 | test_LDFLAGS = -L../../src | ||
11 | test_LDADD = -ltap | ||
12 | |||
13 | CLEANFILES = test.o test.c.out test.pl.out | ||
diff --git a/tap/tests/pass/test.c b/tap/tests/pass/test.c new file mode 100644 index 00000000..39d8a7c1 --- /dev/null +++ b/tap/tests/pass/test.c | |||
@@ -0,0 +1,46 @@ | |||
1 | /*- | ||
2 | * Copyright (c) 2004 Nik Clayton | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * 1. Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * 2. Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * | ||
14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
24 | * SUCH DAMAGE. | ||
25 | */ | ||
26 | |||
27 | #include <stdio.h> | ||
28 | |||
29 | #include "tap.h" | ||
30 | |||
31 | int | ||
32 | main(int argc, char *argv[]) | ||
33 | { | ||
34 | unsigned int rc = 0; | ||
35 | |||
36 | rc = plan_tests(2); | ||
37 | diag("Returned: %d", rc); | ||
38 | |||
39 | rc = pass("test to pass"); | ||
40 | diag("Returned: %d", rc); | ||
41 | |||
42 | rc = pass("test to pass %s", "with extra string"); | ||
43 | diag("Returned: %d", rc); | ||
44 | |||
45 | return exit_status(); | ||
46 | } | ||
diff --git a/tap/tests/pass/test.pl b/tap/tests/pass/test.pl new file mode 100644 index 00000000..8abc92e7 --- /dev/null +++ b/tap/tests/pass/test.pl | |||
@@ -0,0 +1,17 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | use warnings; | ||
4 | use strict; | ||
5 | |||
6 | use Test::More; | ||
7 | |||
8 | my $rc = 0; | ||
9 | |||
10 | $rc = plan tests => 2; | ||
11 | diag("Returned: " . sprintf('%d', $rc)); | ||
12 | |||
13 | $rc = pass('test to pass'); | ||
14 | diag("Returned: $rc"); | ||
15 | |||
16 | $rc = pass('test to pass with extra string'); | ||
17 | diag("Returned: $rc"); | ||
diff --git a/tap/tests/pass/test.t b/tap/tests/pass/test.t new file mode 100644 index 00000000..bf0fe8f1 --- /dev/null +++ b/tap/tests/pass/test.t | |||
@@ -0,0 +1,29 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | cd `dirname $0` | ||
4 | |||
5 | echo '1..2' | ||
6 | |||
7 | make 2>&1 > /dev/null | ||
8 | |||
9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
10 | perlstatus=$? | ||
11 | |||
12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
13 | cstatus=$? | ||
14 | |||
15 | diff -u test.pl.out test.c.out | ||
16 | |||
17 | if [ $? -eq 0 ]; then | ||
18 | echo 'ok 1 - output is identical' | ||
19 | else | ||
20 | echo 'not ok 1 - output is identical' | ||
21 | fi | ||
22 | |||
23 | if [ $perlstatus -eq $cstatus ]; then | ||
24 | echo 'ok 2 - status code' | ||
25 | else | ||
26 | echo 'not ok 2 - status code' | ||
27 | echo "# perlstatus = $perlstatus" | ||
28 | echo "# cstatus = $cstatus" | ||
29 | fi | ||
diff --git a/tap/tests/plan/Makefile.am b/tap/tests/plan/Makefile.am new file mode 100644 index 00000000..0724931a --- /dev/null +++ b/tap/tests/plan/Makefile.am | |||
@@ -0,0 +1,7 @@ | |||
1 | SUBDIRS = no-tests | ||
2 | SUBDIRS += no_plan | ||
3 | SUBDIRS += not-enough-tests | ||
4 | SUBDIRS += too-many-plans | ||
5 | SUBDIRS += too-many-tests | ||
6 | SUBDIRS += sane | ||
7 | SUBDIRS += skip_all | ||
diff --git a/tap/tests/plan/no-tests/Makefile.am b/tap/tests/plan/no-tests/Makefile.am new file mode 100644 index 00000000..91d880e7 --- /dev/null +++ b/tap/tests/plan/no-tests/Makefile.am | |||
@@ -0,0 +1,13 @@ | |||
1 | |||
2 | TESTS = test.t | ||
3 | TESTS_ENVIRONMENT = $(SHELL) | ||
4 | |||
5 | EXTRA_DIST = $(TESTS) test.pl | ||
6 | |||
7 | check_PROGRAMS = test | ||
8 | |||
9 | test_CFLAGS = -g -I../../../src | ||
10 | test_LDFLAGS = -L../../../src | ||
11 | test_LDADD = -ltap | ||
12 | |||
13 | CLEANFILES = test.o test.c.out test.pl.out | ||
diff --git a/tap/tests/plan/no-tests/test.c b/tap/tests/plan/no-tests/test.c new file mode 100644 index 00000000..78c5d371 --- /dev/null +++ b/tap/tests/plan/no-tests/test.c | |||
@@ -0,0 +1,43 @@ | |||
1 | /*- | ||
2 | * Copyright (c) 2004 Nik Clayton | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * 1. Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * 2. Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * | ||
14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
24 | * SUCH DAMAGE. | ||
25 | */ | ||
26 | |||
27 | #include <stdio.h> | ||
28 | |||
29 | #include "tap.h" | ||
30 | |||
31 | int | ||
32 | main(int argc, char *argv[]) | ||
33 | { | ||
34 | unsigned int rc = 0; | ||
35 | |||
36 | rc = plan_tests(0); | ||
37 | diag("Returned: %d", rc); | ||
38 | |||
39 | rc = ok(1, NULL); | ||
40 | diag("Returned: %d", rc); | ||
41 | |||
42 | return exit_status(); | ||
43 | } | ||
diff --git a/tap/tests/plan/no-tests/test.pl b/tap/tests/plan/no-tests/test.pl new file mode 100644 index 00000000..93d2b3b8 --- /dev/null +++ b/tap/tests/plan/no-tests/test.pl | |||
@@ -0,0 +1,14 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | use warnings; | ||
4 | use strict; | ||
5 | |||
6 | use Test::More; | ||
7 | |||
8 | my $rc = 0; | ||
9 | |||
10 | $rc = plan tests => 0; | ||
11 | diag("Returned: " . sprintf("%d", $rc)); | ||
12 | |||
13 | $rc = ok(1); | ||
14 | diag("Returned: $rc"); | ||
diff --git a/tap/tests/plan/no-tests/test.t b/tap/tests/plan/no-tests/test.t new file mode 100644 index 00000000..bf0fe8f1 --- /dev/null +++ b/tap/tests/plan/no-tests/test.t | |||
@@ -0,0 +1,29 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | cd `dirname $0` | ||
4 | |||
5 | echo '1..2' | ||
6 | |||
7 | make 2>&1 > /dev/null | ||
8 | |||
9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
10 | perlstatus=$? | ||
11 | |||
12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
13 | cstatus=$? | ||
14 | |||
15 | diff -u test.pl.out test.c.out | ||
16 | |||
17 | if [ $? -eq 0 ]; then | ||
18 | echo 'ok 1 - output is identical' | ||
19 | else | ||
20 | echo 'not ok 1 - output is identical' | ||
21 | fi | ||
22 | |||
23 | if [ $perlstatus -eq $cstatus ]; then | ||
24 | echo 'ok 2 - status code' | ||
25 | else | ||
26 | echo 'not ok 2 - status code' | ||
27 | echo "# perlstatus = $perlstatus" | ||
28 | echo "# cstatus = $cstatus" | ||
29 | fi | ||
diff --git a/tap/tests/plan/no_plan/Makefile.am b/tap/tests/plan/no_plan/Makefile.am new file mode 100644 index 00000000..91d880e7 --- /dev/null +++ b/tap/tests/plan/no_plan/Makefile.am | |||
@@ -0,0 +1,13 @@ | |||
1 | |||
2 | TESTS = test.t | ||
3 | TESTS_ENVIRONMENT = $(SHELL) | ||
4 | |||
5 | EXTRA_DIST = $(TESTS) test.pl | ||
6 | |||
7 | check_PROGRAMS = test | ||
8 | |||
9 | test_CFLAGS = -g -I../../../src | ||
10 | test_LDFLAGS = -L../../../src | ||
11 | test_LDADD = -ltap | ||
12 | |||
13 | CLEANFILES = test.o test.c.out test.pl.out | ||
diff --git a/tap/tests/plan/no_plan/test.c b/tap/tests/plan/no_plan/test.c new file mode 100644 index 00000000..5cffbdc2 --- /dev/null +++ b/tap/tests/plan/no_plan/test.c | |||
@@ -0,0 +1,43 @@ | |||
1 | /*- | ||
2 | * Copyright (c) 2004 Nik Clayton | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * 1. Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * 2. Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * | ||
14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
24 | * SUCH DAMAGE. | ||
25 | */ | ||
26 | |||
27 | #include <stdio.h> | ||
28 | |||
29 | #include "tap.h" | ||
30 | |||
31 | int | ||
32 | main(int argc, char *argv[]) | ||
33 | { | ||
34 | unsigned int rc = 0; | ||
35 | |||
36 | rc = plan_no_plan(); | ||
37 | diag("Returned: %d", rc); | ||
38 | |||
39 | rc = ok(1, NULL); | ||
40 | diag("Returned: %d", rc); | ||
41 | |||
42 | return exit_status(); | ||
43 | } | ||
diff --git a/tap/tests/plan/no_plan/test.pl b/tap/tests/plan/no_plan/test.pl new file mode 100644 index 00000000..19e42b57 --- /dev/null +++ b/tap/tests/plan/no_plan/test.pl | |||
@@ -0,0 +1,14 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | use warnings; | ||
4 | use strict; | ||
5 | |||
6 | my $rc = 0; | ||
7 | |||
8 | use Test::More; | ||
9 | |||
10 | $rc = plan qw(no_plan); | ||
11 | diag("Returned: " . sprintf("%d", $rc)); | ||
12 | |||
13 | $rc = ok(1); | ||
14 | diag("Returned: $rc"); | ||
diff --git a/tap/tests/plan/no_plan/test.t b/tap/tests/plan/no_plan/test.t new file mode 100644 index 00000000..bf0fe8f1 --- /dev/null +++ b/tap/tests/plan/no_plan/test.t | |||
@@ -0,0 +1,29 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | cd `dirname $0` | ||
4 | |||
5 | echo '1..2' | ||
6 | |||
7 | make 2>&1 > /dev/null | ||
8 | |||
9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
10 | perlstatus=$? | ||
11 | |||
12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
13 | cstatus=$? | ||
14 | |||
15 | diff -u test.pl.out test.c.out | ||
16 | |||
17 | if [ $? -eq 0 ]; then | ||
18 | echo 'ok 1 - output is identical' | ||
19 | else | ||
20 | echo 'not ok 1 - output is identical' | ||
21 | fi | ||
22 | |||
23 | if [ $perlstatus -eq $cstatus ]; then | ||
24 | echo 'ok 2 - status code' | ||
25 | else | ||
26 | echo 'not ok 2 - status code' | ||
27 | echo "# perlstatus = $perlstatus" | ||
28 | echo "# cstatus = $cstatus" | ||
29 | fi | ||
diff --git a/tap/tests/plan/not-enough-tests/Makefile.am b/tap/tests/plan/not-enough-tests/Makefile.am new file mode 100644 index 00000000..91d880e7 --- /dev/null +++ b/tap/tests/plan/not-enough-tests/Makefile.am | |||
@@ -0,0 +1,13 @@ | |||
1 | |||
2 | TESTS = test.t | ||
3 | TESTS_ENVIRONMENT = $(SHELL) | ||
4 | |||
5 | EXTRA_DIST = $(TESTS) test.pl | ||
6 | |||
7 | check_PROGRAMS = test | ||
8 | |||
9 | test_CFLAGS = -g -I../../../src | ||
10 | test_LDFLAGS = -L../../../src | ||
11 | test_LDADD = -ltap | ||
12 | |||
13 | CLEANFILES = test.o test.c.out test.pl.out | ||
diff --git a/tap/tests/plan/not-enough-tests/test.c b/tap/tests/plan/not-enough-tests/test.c new file mode 100644 index 00000000..a9ec64f2 --- /dev/null +++ b/tap/tests/plan/not-enough-tests/test.c | |||
@@ -0,0 +1,49 @@ | |||
1 | /*- | ||
2 | * Copyright (c) 2004 Nik Clayton | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * 1. Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * 2. Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * | ||
14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
24 | * SUCH DAMAGE. | ||
25 | */ | ||
26 | |||
27 | #include <stdio.h> | ||
28 | |||
29 | #include "tap.h" | ||
30 | |||
31 | int | ||
32 | main(int argc, char *argv[]) | ||
33 | { | ||
34 | unsigned int rc = 0; | ||
35 | |||
36 | rc = plan_tests(1); | ||
37 | diag("Returned: %d", rc); | ||
38 | |||
39 | rc = ok(1, NULL); | ||
40 | diag("Returned: %d", rc); | ||
41 | |||
42 | rc = ok(1, NULL); | ||
43 | diag("Returned: %d", rc); | ||
44 | |||
45 | rc = ok(1, NULL); | ||
46 | diag("Returned: %d", rc); | ||
47 | |||
48 | return exit_status(); | ||
49 | } | ||
diff --git a/tap/tests/plan/not-enough-tests/test.pl b/tap/tests/plan/not-enough-tests/test.pl new file mode 100644 index 00000000..73787a7c --- /dev/null +++ b/tap/tests/plan/not-enough-tests/test.pl | |||
@@ -0,0 +1,20 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | use warnings; | ||
4 | use strict; | ||
5 | |||
6 | use Test::More; | ||
7 | |||
8 | my $rc = 0; | ||
9 | |||
10 | $rc = plan tests => 1; | ||
11 | diag("Returned: " . sprintf("%d", $rc)); | ||
12 | |||
13 | $rc = ok(1); | ||
14 | diag("Returned: $rc"); | ||
15 | |||
16 | $rc = ok(1); | ||
17 | diag("Returned: $rc"); | ||
18 | |||
19 | $rc = ok(1); | ||
20 | diag("Returned: $rc"); | ||
diff --git a/tap/tests/plan/not-enough-tests/test.t b/tap/tests/plan/not-enough-tests/test.t new file mode 100644 index 00000000..bf0fe8f1 --- /dev/null +++ b/tap/tests/plan/not-enough-tests/test.t | |||
@@ -0,0 +1,29 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | cd `dirname $0` | ||
4 | |||
5 | echo '1..2' | ||
6 | |||
7 | make 2>&1 > /dev/null | ||
8 | |||
9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
10 | perlstatus=$? | ||
11 | |||
12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
13 | cstatus=$? | ||
14 | |||
15 | diff -u test.pl.out test.c.out | ||
16 | |||
17 | if [ $? -eq 0 ]; then | ||
18 | echo 'ok 1 - output is identical' | ||
19 | else | ||
20 | echo 'not ok 1 - output is identical' | ||
21 | fi | ||
22 | |||
23 | if [ $perlstatus -eq $cstatus ]; then | ||
24 | echo 'ok 2 - status code' | ||
25 | else | ||
26 | echo 'not ok 2 - status code' | ||
27 | echo "# perlstatus = $perlstatus" | ||
28 | echo "# cstatus = $cstatus" | ||
29 | fi | ||
diff --git a/tap/tests/plan/sane/Makefile.am b/tap/tests/plan/sane/Makefile.am new file mode 100644 index 00000000..91d880e7 --- /dev/null +++ b/tap/tests/plan/sane/Makefile.am | |||
@@ -0,0 +1,13 @@ | |||
1 | |||
2 | TESTS = test.t | ||
3 | TESTS_ENVIRONMENT = $(SHELL) | ||
4 | |||
5 | EXTRA_DIST = $(TESTS) test.pl | ||
6 | |||
7 | check_PROGRAMS = test | ||
8 | |||
9 | test_CFLAGS = -g -I../../../src | ||
10 | test_LDFLAGS = -L../../../src | ||
11 | test_LDADD = -ltap | ||
12 | |||
13 | CLEANFILES = test.o test.c.out test.pl.out | ||
diff --git a/tap/tests/plan/sane/test.c b/tap/tests/plan/sane/test.c new file mode 100644 index 00000000..0843d3af --- /dev/null +++ b/tap/tests/plan/sane/test.c | |||
@@ -0,0 +1,43 @@ | |||
1 | /*- | ||
2 | * Copyright (c) 2004 Nik Clayton | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * 1. Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * 2. Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * | ||
14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
24 | * SUCH DAMAGE. | ||
25 | */ | ||
26 | |||
27 | #include <stdio.h> | ||
28 | |||
29 | #include "tap.h" | ||
30 | |||
31 | int | ||
32 | main(int argc, char *argv[]) | ||
33 | { | ||
34 | unsigned int rc = 0; | ||
35 | |||
36 | rc = plan_tests(1); | ||
37 | diag("Returned: %d", rc); | ||
38 | |||
39 | rc = ok(1, NULL); | ||
40 | diag("Returned: %d", rc); | ||
41 | |||
42 | return exit_status(); | ||
43 | } | ||
diff --git a/tap/tests/plan/sane/test.pl b/tap/tests/plan/sane/test.pl new file mode 100644 index 00000000..35c4ef2f --- /dev/null +++ b/tap/tests/plan/sane/test.pl | |||
@@ -0,0 +1,14 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | use warnings; | ||
4 | use strict; | ||
5 | |||
6 | use Test::More; | ||
7 | |||
8 | my $rc = 0; | ||
9 | |||
10 | $rc = plan tests => 1; | ||
11 | diag("Returned: " . sprintf("%d", $rc)); | ||
12 | |||
13 | $rc = ok(1); | ||
14 | diag("Returned: $rc"); | ||
diff --git a/tap/tests/plan/sane/test.t b/tap/tests/plan/sane/test.t new file mode 100644 index 00000000..bf0fe8f1 --- /dev/null +++ b/tap/tests/plan/sane/test.t | |||
@@ -0,0 +1,29 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | cd `dirname $0` | ||
4 | |||
5 | echo '1..2' | ||
6 | |||
7 | make 2>&1 > /dev/null | ||
8 | |||
9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
10 | perlstatus=$? | ||
11 | |||
12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
13 | cstatus=$? | ||
14 | |||
15 | diff -u test.pl.out test.c.out | ||
16 | |||
17 | if [ $? -eq 0 ]; then | ||
18 | echo 'ok 1 - output is identical' | ||
19 | else | ||
20 | echo 'not ok 1 - output is identical' | ||
21 | fi | ||
22 | |||
23 | if [ $perlstatus -eq $cstatus ]; then | ||
24 | echo 'ok 2 - status code' | ||
25 | else | ||
26 | echo 'not ok 2 - status code' | ||
27 | echo "# perlstatus = $perlstatus" | ||
28 | echo "# cstatus = $cstatus" | ||
29 | fi | ||
diff --git a/tap/tests/plan/skip_all/Makefile.am b/tap/tests/plan/skip_all/Makefile.am new file mode 100644 index 00000000..91d880e7 --- /dev/null +++ b/tap/tests/plan/skip_all/Makefile.am | |||
@@ -0,0 +1,13 @@ | |||
1 | |||
2 | TESTS = test.t | ||
3 | TESTS_ENVIRONMENT = $(SHELL) | ||
4 | |||
5 | EXTRA_DIST = $(TESTS) test.pl | ||
6 | |||
7 | check_PROGRAMS = test | ||
8 | |||
9 | test_CFLAGS = -g -I../../../src | ||
10 | test_LDFLAGS = -L../../../src | ||
11 | test_LDADD = -ltap | ||
12 | |||
13 | CLEANFILES = test.o test.c.out test.pl.out | ||
diff --git a/tap/tests/plan/skip_all/test.c b/tap/tests/plan/skip_all/test.c new file mode 100644 index 00000000..31722da9 --- /dev/null +++ b/tap/tests/plan/skip_all/test.c | |||
@@ -0,0 +1,38 @@ | |||
1 | /*- | ||
2 | * Copyright (c) 2004 Nik Clayton | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * 1. Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * 2. Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * | ||
14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
24 | * SUCH DAMAGE. | ||
25 | */ | ||
26 | |||
27 | #include "tap.h" | ||
28 | |||
29 | int | ||
30 | main(int argc, char *argv[]) | ||
31 | { | ||
32 | unsigned int rc = 0; | ||
33 | |||
34 | rc = plan_skip_all("No good reason"); | ||
35 | diag("Returned: %d", rc); | ||
36 | |||
37 | return exit_status(); | ||
38 | } | ||
diff --git a/tap/tests/plan/skip_all/test.pl b/tap/tests/plan/skip_all/test.pl new file mode 100644 index 00000000..32555724 --- /dev/null +++ b/tap/tests/plan/skip_all/test.pl | |||
@@ -0,0 +1,11 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | use warnings; | ||
4 | use strict; | ||
5 | |||
6 | use Test::More; | ||
7 | |||
8 | my $rc = 0; | ||
9 | |||
10 | $rc = plan skip_all => "No good reason"; | ||
11 | diag("Returned: " . sprintf("%d", $rc)); | ||
diff --git a/tap/tests/plan/skip_all/test.t b/tap/tests/plan/skip_all/test.t new file mode 100644 index 00000000..bf0fe8f1 --- /dev/null +++ b/tap/tests/plan/skip_all/test.t | |||
@@ -0,0 +1,29 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | cd `dirname $0` | ||
4 | |||
5 | echo '1..2' | ||
6 | |||
7 | make 2>&1 > /dev/null | ||
8 | |||
9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
10 | perlstatus=$? | ||
11 | |||
12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
13 | cstatus=$? | ||
14 | |||
15 | diff -u test.pl.out test.c.out | ||
16 | |||
17 | if [ $? -eq 0 ]; then | ||
18 | echo 'ok 1 - output is identical' | ||
19 | else | ||
20 | echo 'not ok 1 - output is identical' | ||
21 | fi | ||
22 | |||
23 | if [ $perlstatus -eq $cstatus ]; then | ||
24 | echo 'ok 2 - status code' | ||
25 | else | ||
26 | echo 'not ok 2 - status code' | ||
27 | echo "# perlstatus = $perlstatus" | ||
28 | echo "# cstatus = $cstatus" | ||
29 | fi | ||
diff --git a/tap/tests/plan/too-many-plans/Makefile.am b/tap/tests/plan/too-many-plans/Makefile.am new file mode 100644 index 00000000..91d880e7 --- /dev/null +++ b/tap/tests/plan/too-many-plans/Makefile.am | |||
@@ -0,0 +1,13 @@ | |||
1 | |||
2 | TESTS = test.t | ||
3 | TESTS_ENVIRONMENT = $(SHELL) | ||
4 | |||
5 | EXTRA_DIST = $(TESTS) test.pl | ||
6 | |||
7 | check_PROGRAMS = test | ||
8 | |||
9 | test_CFLAGS = -g -I../../../src | ||
10 | test_LDFLAGS = -L../../../src | ||
11 | test_LDADD = -ltap | ||
12 | |||
13 | CLEANFILES = test.o test.c.out test.pl.out | ||
diff --git a/tap/tests/plan/too-many-plans/test.c b/tap/tests/plan/too-many-plans/test.c new file mode 100644 index 00000000..b189cb72 --- /dev/null +++ b/tap/tests/plan/too-many-plans/test.c | |||
@@ -0,0 +1,49 @@ | |||
1 | /*- | ||
2 | * Copyright (c) 2004 Nik Clayton | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * 1. Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * 2. Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * | ||
14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
24 | * SUCH DAMAGE. | ||
25 | */ | ||
26 | |||
27 | #include <stdio.h> | ||
28 | |||
29 | #include "tap.h" | ||
30 | |||
31 | int | ||
32 | main(int argc, char *argv[]) | ||
33 | { | ||
34 | unsigned int rc = 0; | ||
35 | |||
36 | rc = plan_tests(1); | ||
37 | diag("Returned: %d", rc); | ||
38 | |||
39 | rc = ok(1, NULL); | ||
40 | diag("Returned: %d", rc); | ||
41 | |||
42 | rc = plan_tests(1); | ||
43 | diag("Returned: %d", rc); | ||
44 | |||
45 | rc = ok(0, NULL); | ||
46 | diag("Returned: %d", rc); | ||
47 | |||
48 | return exit_status(); | ||
49 | } | ||
diff --git a/tap/tests/plan/too-many-plans/test.pl b/tap/tests/plan/too-many-plans/test.pl new file mode 100644 index 00000000..893e5fc0 --- /dev/null +++ b/tap/tests/plan/too-many-plans/test.pl | |||
@@ -0,0 +1,20 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | use warnings; | ||
4 | use strict; | ||
5 | |||
6 | use Test::More; | ||
7 | |||
8 | my $rc = 0; | ||
9 | |||
10 | $rc = plan tests => 1; | ||
11 | diag("Returned: " . sprintf("%d", $rc)); | ||
12 | |||
13 | $rc = ok(1); | ||
14 | diag("Returned: $rc"); | ||
15 | |||
16 | $rc = plan tests => 1; | ||
17 | diag("Returned: $rc"); | ||
18 | |||
19 | $rc = ok(0); | ||
20 | diag("Returned: $rc"); | ||
diff --git a/tap/tests/plan/too-many-plans/test.t b/tap/tests/plan/too-many-plans/test.t new file mode 100644 index 00000000..cd2acf74 --- /dev/null +++ b/tap/tests/plan/too-many-plans/test.t | |||
@@ -0,0 +1,29 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | cd `dirname $0` | ||
4 | |||
5 | echo '1..2' | ||
6 | |||
7 | make 2>&1 > /dev/null | ||
8 | |||
9 | perl ./test.pl 2>&1 | sed -e 's/twice!.*$/twice!/' > test.pl.out | ||
10 | perlstatus=$? | ||
11 | |||
12 | ./test 2>&1 | sed -e 's/twice!.*$/twice!/' > test.c.out | ||
13 | cstatus=$? | ||
14 | |||
15 | diff -u test.pl.out test.c.out | ||
16 | |||
17 | if [ $? -eq 0 ]; then | ||
18 | echo 'ok 1 - output is identical' | ||
19 | else | ||
20 | echo 'not ok 1 - output is identical' | ||
21 | fi | ||
22 | |||
23 | if [ $perlstatus -eq $cstatus ]; then | ||
24 | echo 'ok 2 - status code' | ||
25 | else | ||
26 | echo 'not ok 2 - status code' | ||
27 | echo "# perlstatus = $perlstatus" | ||
28 | echo "# cstatus = $cstatus" | ||
29 | fi | ||
diff --git a/tap/tests/plan/too-many-tests/Makefile.am b/tap/tests/plan/too-many-tests/Makefile.am new file mode 100644 index 00000000..91d880e7 --- /dev/null +++ b/tap/tests/plan/too-many-tests/Makefile.am | |||
@@ -0,0 +1,13 @@ | |||
1 | |||
2 | TESTS = test.t | ||
3 | TESTS_ENVIRONMENT = $(SHELL) | ||
4 | |||
5 | EXTRA_DIST = $(TESTS) test.pl | ||
6 | |||
7 | check_PROGRAMS = test | ||
8 | |||
9 | test_CFLAGS = -g -I../../../src | ||
10 | test_LDFLAGS = -L../../../src | ||
11 | test_LDADD = -ltap | ||
12 | |||
13 | CLEANFILES = test.o test.c.out test.pl.out | ||
diff --git a/tap/tests/plan/too-many-tests/test.c b/tap/tests/plan/too-many-tests/test.c new file mode 100644 index 00000000..0f724104 --- /dev/null +++ b/tap/tests/plan/too-many-tests/test.c | |||
@@ -0,0 +1,46 @@ | |||
1 | /*- | ||
2 | * Copyright (c) 2004 Nik Clayton | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * 1. Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * 2. Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * | ||
14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
24 | * SUCH DAMAGE. | ||
25 | */ | ||
26 | |||
27 | #include <stdio.h> | ||
28 | |||
29 | #include "tap.h" | ||
30 | |||
31 | int | ||
32 | main(int argc, char *argv[]) | ||
33 | { | ||
34 | unsigned int rc = 0; | ||
35 | |||
36 | rc = plan_tests(5); | ||
37 | diag("Returned: %d", rc); | ||
38 | |||
39 | rc = ok(1, NULL); | ||
40 | diag("Returned: %d", rc); | ||
41 | |||
42 | rc = ok(0, NULL); | ||
43 | diag("Returned: %d", rc); | ||
44 | |||
45 | return exit_status(); | ||
46 | } | ||
diff --git a/tap/tests/plan/too-many-tests/test.pl b/tap/tests/plan/too-many-tests/test.pl new file mode 100644 index 00000000..0a1666ba --- /dev/null +++ b/tap/tests/plan/too-many-tests/test.pl | |||
@@ -0,0 +1,17 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | use warnings; | ||
4 | use strict; | ||
5 | |||
6 | use Test::More; | ||
7 | |||
8 | my $rc = 0; | ||
9 | |||
10 | $rc = plan tests => 5; | ||
11 | diag("Returned: " . sprintf("%d", $rc)); | ||
12 | |||
13 | $rc = ok(1); | ||
14 | diag("Returned: $rc"); | ||
15 | |||
16 | $rc = ok(0); | ||
17 | diag("Returned: $rc"); | ||
diff --git a/tap/tests/plan/too-many-tests/test.t b/tap/tests/plan/too-many-tests/test.t new file mode 100644 index 00000000..bf0fe8f1 --- /dev/null +++ b/tap/tests/plan/too-many-tests/test.t | |||
@@ -0,0 +1,29 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | cd `dirname $0` | ||
4 | |||
5 | echo '1..2' | ||
6 | |||
7 | make 2>&1 > /dev/null | ||
8 | |||
9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
10 | perlstatus=$? | ||
11 | |||
12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
13 | cstatus=$? | ||
14 | |||
15 | diff -u test.pl.out test.c.out | ||
16 | |||
17 | if [ $? -eq 0 ]; then | ||
18 | echo 'ok 1 - output is identical' | ||
19 | else | ||
20 | echo 'not ok 1 - output is identical' | ||
21 | fi | ||
22 | |||
23 | if [ $perlstatus -eq $cstatus ]; then | ||
24 | echo 'ok 2 - status code' | ||
25 | else | ||
26 | echo 'not ok 2 - status code' | ||
27 | echo "# perlstatus = $perlstatus" | ||
28 | echo "# cstatus = $cstatus" | ||
29 | fi | ||
diff --git a/tap/tests/skip/Makefile.am b/tap/tests/skip/Makefile.am new file mode 100644 index 00000000..c1ccb751 --- /dev/null +++ b/tap/tests/skip/Makefile.am | |||
@@ -0,0 +1,13 @@ | |||
1 | |||
2 | TESTS = test.t | ||
3 | TESTS_ENVIRONMENT = $(SHELL) | ||
4 | |||
5 | EXTRA_DIST = $(TESTS) test.pl | ||
6 | |||
7 | check_PROGRAMS = test | ||
8 | |||
9 | test_CFLAGS = -g -I../../src | ||
10 | test_LDFLAGS = -L../../src | ||
11 | test_LDADD = -ltap | ||
12 | |||
13 | CLEANFILES = test.o test.c.out test.pl.out | ||
diff --git a/tap/tests/skip/test.c b/tap/tests/skip/test.c new file mode 100644 index 00000000..d8f3eafd --- /dev/null +++ b/tap/tests/skip/test.c | |||
@@ -0,0 +1,69 @@ | |||
1 | /*- | ||
2 | * Copyright (c) 2004 Nik Clayton | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * 1. Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * 2. Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * | ||
14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
24 | * SUCH DAMAGE. | ||
25 | */ | ||
26 | |||
27 | #include <stdio.h> | ||
28 | |||
29 | #include "tap.h" | ||
30 | |||
31 | int | ||
32 | main(int argc, char *argv[]) | ||
33 | { | ||
34 | unsigned int rc = 0; | ||
35 | unsigned int side_effect = 0; | ||
36 | |||
37 | rc = plan_tests(4); | ||
38 | diag("Returned: %d", rc); | ||
39 | |||
40 | rc = ok(1 == 1, "1 equals 1"); /* Should always work */ | ||
41 | diag("Returned: %d", rc); | ||
42 | |||
43 | do { | ||
44 | if(1) { | ||
45 | rc = skip(1, "Testing skipping"); | ||
46 | continue; | ||
47 | } | ||
48 | |||
49 | side_effect++; | ||
50 | |||
51 | ok(side_effect == 1, "side_effect checked out"); | ||
52 | |||
53 | } while(0); | ||
54 | |||
55 | diag("Returned: %d", rc); | ||
56 | |||
57 | skip_start(1 == 1, 1, "Testing skipping #2"); | ||
58 | |||
59 | side_effect++; | ||
60 | rc = ok(side_effect == 1, "side_effect checked out"); | ||
61 | diag("Returned: %d", rc); | ||
62 | |||
63 | skip_end; | ||
64 | |||
65 | rc = ok(side_effect == 0, "side_effect is %d", side_effect); | ||
66 | diag("Returned: %d", rc); | ||
67 | |||
68 | return exit_status(); | ||
69 | } | ||
diff --git a/tap/tests/skip/test.pl b/tap/tests/skip/test.pl new file mode 100644 index 00000000..dc294717 --- /dev/null +++ b/tap/tests/skip/test.pl | |||
@@ -0,0 +1,40 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | use warnings; | ||
4 | use strict; | ||
5 | |||
6 | use Test::More; | ||
7 | |||
8 | my $rc = 0; | ||
9 | |||
10 | $rc = plan tests => 4; | ||
11 | diag("Returned: " . sprintf("%d", $rc)); | ||
12 | |||
13 | my $side_effect = 0; # Check whether skipping has side effects | ||
14 | |||
15 | $rc = ok(1 == 1, '1 equals 1'); # Test ok() passes when it should | ||
16 | diag("Returned: $rc"); | ||
17 | |||
18 | # Start skipping | ||
19 | SKIP: { | ||
20 | $rc = skip "Testing skipping", 1; | ||
21 | |||
22 | $side_effect++; | ||
23 | |||
24 | $rc = ok($side_effect == 1, '$side_effect checked out'); | ||
25 | } | ||
26 | |||
27 | diag("Returned: $rc"); | ||
28 | |||
29 | SKIP: { | ||
30 | $rc = skip "Testing skipping #2", 1; | ||
31 | diag("Returned: $rc"); | ||
32 | |||
33 | $side_effect++; | ||
34 | |||
35 | $rc = ok($side_effect == 1, '$side_effect checked out'); | ||
36 | diag("Returned: $rc"); | ||
37 | } | ||
38 | |||
39 | $rc = ok($side_effect == 0, "side_effect is $side_effect"); | ||
40 | diag("Returned: $rc"); | ||
diff --git a/tap/tests/skip/test.t b/tap/tests/skip/test.t new file mode 100644 index 00000000..bf0fe8f1 --- /dev/null +++ b/tap/tests/skip/test.t | |||
@@ -0,0 +1,29 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | cd `dirname $0` | ||
4 | |||
5 | echo '1..2' | ||
6 | |||
7 | make 2>&1 > /dev/null | ||
8 | |||
9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
10 | perlstatus=$? | ||
11 | |||
12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
13 | cstatus=$? | ||
14 | |||
15 | diff -u test.pl.out test.c.out | ||
16 | |||
17 | if [ $? -eq 0 ]; then | ||
18 | echo 'ok 1 - output is identical' | ||
19 | else | ||
20 | echo 'not ok 1 - output is identical' | ||
21 | fi | ||
22 | |||
23 | if [ $perlstatus -eq $cstatus ]; then | ||
24 | echo 'ok 2 - status code' | ||
25 | else | ||
26 | echo 'not ok 2 - status code' | ||
27 | echo "# perlstatus = $perlstatus" | ||
28 | echo "# cstatus = $cstatus" | ||
29 | fi | ||
diff --git a/tap/tests/todo/Makefile.am b/tap/tests/todo/Makefile.am new file mode 100644 index 00000000..c1ccb751 --- /dev/null +++ b/tap/tests/todo/Makefile.am | |||
@@ -0,0 +1,13 @@ | |||
1 | |||
2 | TESTS = test.t | ||
3 | TESTS_ENVIRONMENT = $(SHELL) | ||
4 | |||
5 | EXTRA_DIST = $(TESTS) test.pl | ||
6 | |||
7 | check_PROGRAMS = test | ||
8 | |||
9 | test_CFLAGS = -g -I../../src | ||
10 | test_LDFLAGS = -L../../src | ||
11 | test_LDADD = -ltap | ||
12 | |||
13 | CLEANFILES = test.o test.c.out test.pl.out | ||
diff --git a/tap/tests/todo/test.c b/tap/tests/todo/test.c new file mode 100644 index 00000000..ac6339a7 --- /dev/null +++ b/tap/tests/todo/test.c | |||
@@ -0,0 +1,68 @@ | |||
1 | /*- | ||
2 | * Copyright (c) 2004 Nik Clayton | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * 1. Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * 2. Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * | ||
14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
24 | * SUCH DAMAGE. | ||
25 | */ | ||
26 | |||
27 | #include <stdio.h> | ||
28 | |||
29 | #include "tap.h" | ||
30 | |||
31 | int | ||
32 | main(int argc, char *argv[]) | ||
33 | { | ||
34 | unsigned int rc = 0; | ||
35 | unsigned int side_effect = 0; | ||
36 | |||
37 | rc = plan_tests(5); | ||
38 | diag("Returned: %d", rc); | ||
39 | |||
40 | rc = ok(1 == 1, "1 equals 1"); /* Should always work */ | ||
41 | diag("Returned: %d", rc); | ||
42 | |||
43 | todo_start("For testing purposes"); | ||
44 | |||
45 | side_effect++; | ||
46 | |||
47 | /* This test should fail */ | ||
48 | rc = ok(side_effect == 0, "side_effect checked out"); | ||
49 | diag("Returned: %d", rc); | ||
50 | |||
51 | /* This test should unexpectedly succeed */ | ||
52 | rc = ok(side_effect == 1, "side_effect checked out"); | ||
53 | diag("Returned: %d", rc); | ||
54 | |||
55 | todo_end(); | ||
56 | |||
57 | todo_start("Testing printf() %s in todo_start()", "expansion"); | ||
58 | |||
59 | rc = ok(0, "dummy test"); | ||
60 | diag("Returned: %d", rc); | ||
61 | |||
62 | todo_end(); | ||
63 | |||
64 | rc = ok(side_effect == 1, "side_effect is %d", side_effect); | ||
65 | diag("Returned: %d", rc); | ||
66 | |||
67 | return exit_status(); | ||
68 | } | ||
diff --git a/tap/tests/todo/test.pl b/tap/tests/todo/test.pl new file mode 100644 index 00000000..2621e12f --- /dev/null +++ b/tap/tests/todo/test.pl | |||
@@ -0,0 +1,41 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | use warnings; | ||
4 | use strict; | ||
5 | |||
6 | use Test::More; | ||
7 | |||
8 | my $rc = 0; | ||
9 | |||
10 | $rc = plan tests => 5; | ||
11 | diag("Returned: " . sprintf("%d", $rc)); | ||
12 | |||
13 | my $side_effect = 0; # Check whether TODO has side effects | ||
14 | |||
15 | $rc = ok(1 == 1, '1 equals 1'); # Test ok() passes when it should | ||
16 | diag("Returned: $rc"); | ||
17 | |||
18 | # Start TODO tests | ||
19 | TODO: { | ||
20 | local $TODO = 'For testing purposes'; | ||
21 | |||
22 | $side_effect++; | ||
23 | |||
24 | # This test should fail | ||
25 | $rc = ok($side_effect == 0, 'side_effect checked out'); | ||
26 | diag("Returned: $rc"); | ||
27 | |||
28 | # This test should unexpectedly succeed | ||
29 | $rc = ok($side_effect == 1, 'side_effect checked out'); | ||
30 | diag("Returned: $rc"); | ||
31 | } | ||
32 | |||
33 | TODO: { | ||
34 | local $TODO = 'Testing printf() expansion in todo_start()'; | ||
35 | |||
36 | $rc = ok(0, 'dummy test'); | ||
37 | diag("Returned: $rc"); | ||
38 | } | ||
39 | |||
40 | $rc = ok($side_effect == 1, "side_effect is $side_effect"); | ||
41 | diag("Returned: $rc"); | ||
diff --git a/tap/tests/todo/test.t b/tap/tests/todo/test.t new file mode 100644 index 00000000..7dbb17b6 --- /dev/null +++ b/tap/tests/todo/test.t | |||
@@ -0,0 +1,29 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | cd `dirname $0` | ||
4 | |||
5 | echo '1..2' | ||
6 | |||
7 | make 2>&1 > /dev/null | ||
8 | |||
9 | perl ./test.pl 2>&1 | sed -e 's/# Failed (TODO) test \(.*\)/# Failed (TODO) test ()/' > test.pl.out | ||
10 | perlstatus=$? | ||
11 | |||
12 | ./test 2>&1 | sed -e 's/# Failed (TODO) test \(.*\)/# Failed (TODO) test ()/' > test.c.out | ||
13 | cstatus=$? | ||
14 | |||
15 | diff -u test.pl.out test.c.out | ||
16 | |||
17 | if [ $? -eq 0 ]; then | ||
18 | echo 'ok 1 - output is identical' | ||
19 | else | ||
20 | echo 'not ok 1 - output is identical' | ||
21 | fi | ||
22 | |||
23 | if [ $perlstatus -eq $cstatus ]; then | ||
24 | echo 'ok 2 - status code' | ||
25 | else | ||
26 | echo 'not ok 2 - status code' | ||
27 | echo "# perlstatus = $perlstatus" | ||
28 | echo "# cstatus = $cstatus" | ||
29 | fi | ||