Now, it should be easy to change it at one place.
my @log2print = ();
my $skipped = 0;
foreach (@log) {
- if (/^(\([0-9]+\) (# )?)?!\s*(.*?)\s+(\S+)\s*$/) {
- my ($prefix, $name, $result) = ($1, $3, $4);
+ if (/^($prefix_re)?!\s*(.*?)\s+(\S+)\s*$/) {
+ my ($prefix, $name, $result) = ($1, $2, $3);
push @log2print, resultline($prefix, $name, $result);
if ($result ne "ok") {
print "wvformat: skipped $skipped lines\n" if $skipped;
chomp;
s/\r//g;
- if (/^(\([0-9]+\) )?\s*Testing "(.*)" in (.*):\s*$/)
+ if (/^($prefix_re)?\s*Testing "(.*)" in (.*):\s*$/)
{
print_test_summary() unless $startup;
$startup = 0;
print highlight($_), "\n";
}
}
- elsif (/^(\([0-9]+\) (# )?)?!\s*(.*?)\s+(\S+)\s*$/)
+ elsif (/^($prefix_re)?!\s*(.*?)\s+(\S+)\s*$/)
{
- my ($prefix, $name, $result) = ($1, $3, $4);
+ my ($prefix, $name, $result) = ($1, $2, $3);
if ($startup) {
$file = "";
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;
import time
import numpy as np
+re_prefix = "\([0-9]+\) (?:# )?"
+re_date = re.compile('^Date: (.*)')
+re_testing = re.compile('^('+re_prefix+')?\s*Testing "(.*)" in (.*):\s*$')
+re_commit = re.compile('.*(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}).*, commit: (.*)')
+re_commithash = re.compile('([0-9a-f]{7})(-dirty)? \(')
+re_assertion = re.compile('^('+re_prefix+')?!\s*(.*?)\s+(\S+)\s*$')
+re_perf = re.compile('^('+re_prefix+')?!\s*(.*?)\s+PERF:\s*(.*?)\s+(\S+)\s*$')
+re_perfaxis = re.compile('axis="([^"]+)"')
+
class Axis:
def __init__(self, name=None, units=None):
self.name = name
graphs = Graphs()
commits = {}
-re_date = re.compile('^Date: (.*)')
-re_testing = re.compile('^(\([0-9]+\) (# )?)?\s*Testing "(.*)" in (.*):\s*$')
-re_commit = re.compile('.*(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}).*, commit: (.*)')
-re_commithash = re.compile('([0-9a-f]{7})(-dirty)? \(')
-re_check = re.compile('^(\([0-9]+\) (# )?)?!\s*(.*?)\s+(\S+)\s*$')
-re_perf = re.compile('^(\([0-9]+\) (# )?)?!\s*(.*?)\s+PERF:\s*(.*?)\s+(\S+)\s*$')
-re_perfaxis = re.compile('axis="([^"]+)"')
-
date = time.localtime(time.time())
for line in sys.stdin.readlines():
match = re_testing.match(line)
if match:
- what = match.group(3)
- where = match.group(4)
+ what = match.group(2)
+ where = match.group(3)
match = re_commit.match(what)
if match:
match = re_perf.match(line)
if match:
- perfstr = match.group(4)
+ perfstr = match.group(3)
perf = perfstr.split()
col = perf[0]
try:
if '=' in units: units = None
except:
units = None
- if match.group(5) != "ok":
+ if match.group(4) != "ok":
val=None
graph.addValue(date, col, val, units)
import numpy as np
import cgi
+re_prefix = "\([0-9]+\) (?:# )?"
re_date = re.compile('^Date: (.*)')
-re_testing = re.compile('^(\([0-9]+\) (# )?)?\s*Testing "(.*)" in (.*):\s*$')
+re_testing = re.compile('^('+re_prefix+')?\s*Testing "(.*)" in (.*):\s*$')
re_commit = re.compile('.*(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}).*, commit: (.*)')
re_commithash = re.compile('([0-9a-f]{7})(-dirty)? \(')
-re_check = re.compile('^(\([0-9]+\) (# )?)?!\s*(.*?)\s+(\S+)\s*$')
-re_perf = re.compile('^(\([0-9]+\) (# )?)?!\s*(.*?)\s+PERF:\s*(.*?)\s+(\S+)\s*$')
+re_assertion = re.compile('^('+re_prefix+')?!\s*(.*?)\s+(\S+)\s*$')
+re_perf = re.compile('^('+re_prefix+')?!\s*(.*?)\s+PERF:\s*(.*?)\s+(\S+)\s*$')
re_perfaxis = re.compile('axis="([^"]+)"')
date = time.localtime(time.time())
def add_line(self, line):
self.output.append(line)
- match = re_check.match(line)
+ match = re_assertion.match(line)
if match:
self.check_count += 1
- result = match.group(4)
+ result = match.group(3)
if result != "ok":
self.status = result
self.failures += 1
<table class='output'>
""" % (date_and_commit, self.num, cgi.escape(self.title())))
for line in self.output:
- match = re_check.match(line)
+ match = re_assertion.match(line)
if match:
- result = match.group(4)
+ result = match.group(3)
if result == "ok":
status_class = "ok"
else:
match = re_testing.match(line)
if match:
- what = match.group(3)
- where = match.group(4)
+ what = match.group(2)
+ where = match.group(3)
test = Test(what, where)
tests.append(test)
chomp;
s/\r//g;
- if (/^(\([0-9]+\) (# )?)?!\s*(.*?)\s+(\S+)\s*$/) {
+ if (/^($prefix_re)?!\s*(.*?)\s+(\S+)\s*$/) {
my $line = $_;
do {
print substr($line, 0, $columns) . "\n";