use strict;
use IO::Pty;
+# Optional prefix of wvtest protocol lines
+my $prefix_re = '\([0-9]+\) (?:# )?';
+
# always flush
$| = 1;
my $allstart = time();
my ($start, $stop);
-my $tests_executed = 0;
-my $tests_failed = 0;
+my $assertions_executed = 0;
+my $assertions_failed = 0;
my $waits_for_child = 0;
my $kill_ok = 0;
my $ignore_exit_patterns = 0;
-my $expected_test_count = 0;
-my $expected_test_base = 0;
+my $expected_assertion_count = 0;
+my $expected_assertion_base = 0;
sub matches_exit_pattern($)
{
}
}
-sub check_number_of_tests()
+sub check_number_of_assertions()
{
- if ($expected_test_count) {
- my $executed = $tests_executed - $expected_test_base;
+ if ($expected_assertion_count) {
+ my $executed = $assertions_executed - $expected_assertion_base;
my $result;
- if ($executed == $expected_test_count) {
+ if ($executed == $expected_assertion_count) {
$result = "ok";
} else {
$result = "FAILED";
- $tests_failed++;
- print "Expected $expected_test_count tests, executed $executed tests.\n"
+ $assertions_failed++;
+ print "Expected $expected_assertion_count tests, executed $executed tests.\n"
}
- print "! $0: tests_expected == tests_executed $result\n";
+ print "! $0: tests_expected == assertions_executed $result\n";
}
}
chomp;
s/\r//g;
- if (/^(\([0-9]+\) (# )?)?!\s*(.*?)\s+(\S+)\s*$/) {
- $tests_executed++;
- $tests_failed++ if ($4 ne "ok");
+ if (/^($prefix_re?)?!\s*(.*?)\s+(\S+)\s*$/) {
+ $assertions_executed++;
+ $assertions_failed++ if ($3 ne "ok");
}
elsif (/wvtest: timeout (\d+)\s*$/) {
$timeout=$1;
}
elsif (/sc: wait for child/) { $waits_for_child = 1; }
elsif (/wvtest: ignore exit patterns/) { $ignore_exit_patterns = 1; }
- elsif (/wvtest: expect ([0-9]+) tests/) {
- check_number_of_tests();
- $expected_test_count = $1;
- $expected_test_base = $tests_executed;
+ elsif (/wvtest: expect ([0-9]+) (tests|assertions)/) {
+ check_number_of_assertions();
+ $expected_assertion_count = $1;
+ $expected_assertion_base = $assertions_executed;
}
elsif (matches_exit_pattern($_))
{
}
if (!$ENV{WVTEST_EXIT_PATTERN}) {
- printf "! $0: \$tests_executed > 0 %s\n", ($tests_executed > 0) ? "ok" : "FAILED";
+ printf "! $0: \$assertions_executed > 0 %s\n", ($assertions_executed > 0) ? "ok" : "FAILED";
}
-check_number_of_tests();
+check_number_of_assertions();
-if ($tests_failed > 0) { $ret = 1; }
-if ($ret == 0 && $tests_executed == 0) { $ret = 1; }
+if ($assertions_failed > 0) { $ret = 1; }
+if ($ret == 0 && $assertions_executed == 0) { $ret = 1; }
exit $ret;