| 1 |
#!/usr/bin/perl -w |
| 2 |
# |
| 3 |
# improve - Run Rasqal test suites |
| 4 |
# |
| 5 |
# USAGE: improve [options] [DIRECTORY [TESTSUITE]] |
| 6 |
# |
| 7 |
# Copyright (C) 2009, David Beckett http://www.dajobe.org/ |
| 8 |
# |
| 9 |
# This package is Free Software and part of Redland http://librdf.org/ |
| 10 |
# |
| 11 |
# It is licensed under the following three licenses as alternatives: |
| 12 |
# 1. GNU Lesser General Public License (LGPL) V2.1 or any newer version |
| 13 |
# 2. GNU General Public License (GPL) V2 or any newer version |
| 14 |
# 3. Apache License, V2.0 or any newer version |
| 15 |
# |
| 16 |
# You may not use this file except in compliance with at least one of |
| 17 |
# the above three licenses. |
| 18 |
# |
| 19 |
# See LICENSE.html or LICENSE.txt at the top of this package for the |
| 20 |
# complete terms and further detail along with the license texts for |
| 21 |
# the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively. |
| 22 |
# |
| 23 |
# REQUIRES: |
| 24 |
# GNU 'make' in the PATH (or where envariable MAKE is) |
| 25 |
# |
| 26 |
|
| 27 |
|
| 28 |
use strict; |
| 29 |
use File::Basename; |
| 30 |
use Getopt::Long; |
| 31 |
use Pod::Usage; |
| 32 |
use Cwd qw(abs_path getcwd); |
| 33 |
|
| 34 |
sub get_utils_dir() { |
| 35 |
my $dir = getcwd; |
| 36 |
while($dir ne '' && ! -d "$dir/utils") { |
| 37 |
$dir =~ s{/[^/]+$}{}; |
| 38 |
} |
| 39 |
if($dir eq '') { |
| 40 |
die "$0: Could not find 'utils' dir in parent directories\n"; |
| 41 |
} |
| 42 |
$dir . "/utils"; |
| 43 |
} |
| 44 |
|
| 45 |
our $UTILS_DIR = get_utils_dir(); |
| 46 |
our $TO_NTRIPLES = $ENV{TO_NTRIPLES} || $UTILS_DIR. '/to-ntriples'; |
| 47 |
|
| 48 |
our $MAKE=$ENV{MAKE} || 'make'; |
| 49 |
our $INDENT=' '; |
| 50 |
our $mf='http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#'; |
| 51 |
our $rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'; |
| 52 |
our $rdfs='http://www.w3.org/2000/01/rdf-schema#'; |
| 53 |
our $t='http://ns.librdf.org/2009/test-manifest#'; |
| 54 |
|
| 55 |
our $linewrap=78; |
| 56 |
|
| 57 |
our $banner_width=$linewrap-10; |
| 58 |
|
| 59 |
our $program=basename $0; |
| 60 |
our $debug=0; |
| 61 |
|
| 62 |
our(@counters)=qw( passed failed skipped xfailed uxpassed ); |
| 63 |
|
| 64 |
|
| 65 |
sub get_testsuites($) { |
| 66 |
my $dir=shift; |
| 67 |
|
| 68 |
my $cmd="cd $dir && $MAKE >/dev/null 2>&1"; |
| 69 |
print STDERR "$program: Running $cmd\n" |
| 70 |
if $debug > 1; |
| 71 |
system $cmd; |
| 72 |
|
| 73 |
$cmd="cd $dir && $MAKE get-testsuites-list 2>/dev/null | grep -v 'ing directory' | tail -1"; |
| 74 |
print STDERR "$program: Running $cmd\n" |
| 75 |
if $debug > 1; |
| 76 |
my $raw=`$cmd`; |
| 77 |
return split(/\s+/,$raw); |
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
sub decode_literal ($) { |
| 82 |
my $lit=shift; |
| 83 |
$lit =~ s/^\"(.*)\"$/$1/; |
| 84 |
$lit =~ s/\\"/"/g; |
| 85 |
return $lit; |
| 86 |
} |
| 87 |
|
| 88 |
|
| 89 |
sub read_plan($$) { |
| 90 |
my($testsuite, $plan_file)=@_; |
| 91 |
|
| 92 |
my $dir = $testsuite->{dir}; |
| 93 |
|
| 94 |
my(%triples); |
| 95 |
my $manifest_node; |
| 96 |
my $entries_node; |
| 97 |
|
| 98 |
my $to_ntriples_error='to_ntriples.err'; |
| 99 |
my $cmd="$TO_NTRIPLES $plan_file 2> $to_ntriples_error"; |
| 100 |
print STDERR "$program: Running pipe from $cmd\n" |
| 101 |
if $debug > 1; |
| 102 |
open(MF, "$cmd |") |
| 103 |
or die "Cannot open pipe from '$cmd' - $!\n"; |
| 104 |
while(<MF>) { |
| 105 |
chomp; |
| 106 |
s/\s+\.$//; |
| 107 |
my($s,$p,$o)=split(/ /,$_,3); |
| 108 |
die "no p in '$_'\n" unless defined $p; |
| 109 |
die "no o in '$_'\n" unless defined $o; |
| 110 |
push(@{$triples{$s}->{$p}}, $o); |
| 111 |
$manifest_node=$s if $p eq "<${rdf}type>" && $o eq "<${mf}Manifest>"; |
| 112 |
$entries_node=$o if $p eq "<${mf}entries>"; |
| 113 |
} |
| 114 |
close(MF); |
| 115 |
if(!-z $to_ntriples_error) { |
| 116 |
my $status = {status => 'fail', details => `cat $to_ntriples_error` }; |
| 117 |
unlink $to_ntriples_error; |
| 118 |
return $status; |
| 119 |
} |
| 120 |
unlink $to_ntriples_error; |
| 121 |
|
| 122 |
|
| 123 |
warn "Manifest node is '$manifest_node'\n" |
| 124 |
if $debug > 1; |
| 125 |
if($manifest_node) { |
| 126 |
my $desc=$triples{$manifest_node}->{"<${rdfs}comment>"}->[0]; |
| 127 |
if($desc) { |
| 128 |
$testsuite->{desc}=decode_literal($desc); |
| 129 |
} |
| 130 |
my $path=$triples{$manifest_node}->{"<${t}path>"}->[0]; |
| 131 |
if($path) { |
| 132 |
$testsuite->{path}=decode_literal($path); |
| 133 |
} |
| 134 |
} |
| 135 |
|
| 136 |
warn "Entries node is '$entries_node'\n" |
| 137 |
if $debug > 1; |
| 138 |
|
| 139 |
my $list_node=$entries_node; |
| 140 |
|
| 141 |
my(@tests); |
| 142 |
while($list_node) { |
| 143 |
warn "List node is '$list_node'\n" |
| 144 |
if $debug > 2; |
| 145 |
|
| 146 |
my $entry_node=$triples{$list_node}->{"<${rdf}first>"}->[0]; |
| 147 |
warn "Entry node is '$entry_node'\n" |
| 148 |
if $debug > 2; |
| 149 |
|
| 150 |
my $name=$triples{$entry_node}->{"<${mf}name>"}->[0] | ''; |
| 151 |
$name = decode_literal($name); |
| 152 |
warn "Entry name=$name\n" |
| 153 |
if $debug > 1; |
| 154 |
|
| 155 |
my $comment=$triples{$entry_node}->{"<${rdfs}comment>"}->[0] || ''; |
| 156 |
$comment = decode_literal($comment); |
| 157 |
warn "Entry comment=$comment\n" |
| 158 |
if $debug > 1; |
| 159 |
|
| 160 |
my $action=$triples{$entry_node}->{"<${mf}action>"}->[0] || ''; |
| 161 |
$action = decode_literal($action); |
| 162 |
warn "Entry action $action\n" |
| 163 |
if $debug > 1; |
| 164 |
|
| 165 |
my $entry_type=$triples{$entry_node}->{"<${rdf}type>"}->[0] || ''; |
| 166 |
warn "Entry type is ".($entry_type ? $entry_type : "NONE")."\n" |
| 167 |
if $debug > 1; |
| 168 |
|
| 169 |
my $expect='pass'; |
| 170 |
my $execute=1; |
| 171 |
|
| 172 |
$expect='fail' if |
| 173 |
$entry_type eq "<${t}NegativeTest>" || |
| 174 |
$entry_type eq "<${t}XFailTest>"; |
| 175 |
|
| 176 |
my $test_uri=$entry_node; $test_uri =~ s/^<(.+)>$/$1/; |
| 177 |
warn "Test uri $test_uri\n" |
| 178 |
if $debug > 1; |
| 179 |
|
| 180 |
push(@tests, {name => $name, |
| 181 |
comment => $comment, |
| 182 |
dir => $dir, |
| 183 |
expect => $expect, |
| 184 |
test_uri => $test_uri, |
| 185 |
action => $action |
| 186 |
} ); |
| 187 |
|
| 188 |
next_list_node: |
| 189 |
$list_node=$triples{$list_node}->{"<${rdf}rest>"}->[0]; |
| 190 |
last if $list_node eq "<${rdf}nil>"; |
| 191 |
} |
| 192 |
|
| 193 |
$testsuite->{tests}=\@tests; |
| 194 |
|
| 195 |
return {status => 'pass', details => ''}; |
| 196 |
} |
| 197 |
|
| 198 |
|
| 199 |
sub run_test($$) { |
| 200 |
my($testsuite,$test)=@_; |
| 201 |
my $name=$test->{name}; |
| 202 |
my $action=$test->{action}; |
| 203 |
|
| 204 |
$test->{status}= 'fail'; |
| 205 |
$test->{detail}= ''; |
| 206 |
$test->{log}= ''; |
| 207 |
|
| 208 |
my $path=$testsuite->{path} ? "PATH=$testsuite->{path} " : ""; |
| 209 |
|
| 210 |
print STDERR "$program: Running test $name: $path$action\n" |
| 211 |
if $debug > 1; |
| 212 |
|
| 213 |
my $sname=$name; $sname =~ s/\W/-/g; |
| 214 |
my $log="$sname.log"; |
| 215 |
system "$action > '$log' 2>&1"; |
| 216 |
my $rc=$?; |
| 217 |
my $status='fail'; |
| 218 |
|
| 219 |
if($rc == -1) { |
| 220 |
# exec() failed |
| 221 |
$test->{detail}="failed to execute $action: $!"; |
| 222 |
$status='fail'; |
| 223 |
} elsif($rc & 127) { |
| 224 |
# exec()ed but died on a signal |
| 225 |
my($signal,$coredump_p); |
| 226 |
($signal,$coredump_p)=(($rc & 127), ($rc & 128)); |
| 227 |
$test->{detail}=sprintf("$path$action died with signal $signal, %s coredump". $coredump_p ? 'with' : 'without'); |
| 228 |
open(LOG, '<', $log); |
| 229 |
$test->{log}=join('', <LOG>); |
| 230 |
close(LOG); |
| 231 |
$status='fail'; |
| 232 |
if($signal == 2) { # SIGINT |
| 233 |
$testsuite->{abort}=1; |
| 234 |
} |
| 235 |
} elsif($rc) { |
| 236 |
# exec()ed and exited with non-0 |
| 237 |
$rc >>= 8; |
| 238 |
$test->{detail}="$path$action exited with code $rc"; |
| 239 |
if(open(LOG, '<', $log)) { |
| 240 |
$test->{log}=join('', <LOG>); |
| 241 |
close(LOG); |
| 242 |
} else { |
| 243 |
$test->{log}=''; |
| 244 |
} |
| 245 |
$status='fail'; |
| 246 |
} else { |
| 247 |
# exec()ed and exit 0 |
| 248 |
$status='pass'; |
| 249 |
} |
| 250 |
unlink $log; |
| 251 |
|
| 252 |
if($test->{expect} eq 'fail') { |
| 253 |
if($status eq 'fail') { |
| 254 |
$status='xfail' ; |
| 255 |
$test->{detail}="Test failed as expected" |
| 256 |
} else { |
| 257 |
$status='uxpass'; |
| 258 |
$test->{detail}="Test passed but expected to fail" |
| 259 |
} |
| 260 |
} |
| 261 |
|
| 262 |
$test->{status}=$status; |
| 263 |
|
| 264 |
return $status; |
| 265 |
} |
| 266 |
|
| 267 |
|
| 268 |
sub prepare_testsuite($) { |
| 269 |
my($testsuite)=@_; |
| 270 |
my $dir = $testsuite->{dir}; |
| 271 |
my $name = $testsuite->{name}; |
| 272 |
|
| 273 |
my $plan_file=$name."-plan.ttl"; |
| 274 |
$testsuite->{plan}=$plan_file; |
| 275 |
unlink $plan_file; |
| 276 |
if(!-r $plan_file) { |
| 277 |
system("$MAKE >/dev/null 2>&1"); |
| 278 |
my $cmd="$MAKE get-testsuite-$name 2>/dev/null | grep -v 'ing directory' | sed -n -e '/\@prefix/,\$p' > $plan_file"; |
| 279 |
print STDERR "$program: Running $cmd\n" |
| 280 |
if $debug > 1; |
| 281 |
system $cmd; |
| 282 |
my $rc=$?; |
| 283 |
return { status => 'fail', |
| 284 |
details => "Running '$cmd' failed with status $rc" |
| 285 |
} |
| 286 |
if $rc; |
| 287 |
} |
| 288 |
return { status => 'fail', |
| 289 |
details => "No testsuite plan file $plan_file could be created in $dir" |
| 290 |
} |
| 291 |
unless -r $plan_file && !-z $plan_file; |
| 292 |
|
| 293 |
my $result=read_plan($testsuite, $plan_file); |
| 294 |
|
| 295 |
if($testsuite->{path}) { |
| 296 |
$ENV{PATH}=$testsuite->{path}; |
| 297 |
} |
| 298 |
return $result; |
| 299 |
} |
| 300 |
|
| 301 |
|
| 302 |
sub run_testsuite($$$) { |
| 303 |
my($testsuite, $indent, $verbose)=@_; |
| 304 |
my $dir = $testsuite->{dir}; |
| 305 |
my $name = $testsuite->{name}; |
| 306 |
|
| 307 |
my(@tests)=@{$testsuite->{tests}}; |
| 308 |
|
| 309 |
my $desc=$testsuite->{desc} || $name; |
| 310 |
print $indent."Running testsuite $name: $desc\n"; |
| 311 |
|
| 312 |
my $ntests=scalar @tests; |
| 313 |
|
| 314 |
my(@passed); |
| 315 |
my(@failed); |
| 316 |
my(@xfailed); # Expected failure |
| 317 |
my(@skipped); |
| 318 |
my(@uxpassed); # Unexpected pass |
| 319 |
|
| 320 |
my $expected_failures_count = 0; |
| 321 |
print $indent unless $verbose; |
| 322 |
|
| 323 |
my $result=0; |
| 324 |
my $column=length($indent); |
| 325 |
for my $test (@tests) { |
| 326 |
$test->{testsuite}=$name; |
| 327 |
if($testsuite->{dryrun}) { |
| 328 |
$test->{status} = 'skip'; |
| 329 |
$test->{detail} = ''; |
| 330 |
} else { |
| 331 |
run_test($testsuite,$test); |
| 332 |
} |
| 333 |
|
| 334 |
$expected_failures_count++ if $test->{expect} eq 'fail'; |
| 335 |
|
| 336 |
my $rc=$test->{status}; |
| 337 |
|
| 338 |
if($rc eq 'fail') { |
| 339 |
print "F" unless $verbose; |
| 340 |
push(@failed, $test); |
| 341 |
} elsif($rc eq 'xfail') { |
| 342 |
print "*" unless $verbose; |
| 343 |
push(@xfailed, $test); |
| 344 |
} elsif($rc eq 'uxpass') { |
| 345 |
print "!" unless $verbose; |
| 346 |
push(@uxpassed, $test); |
| 347 |
} elsif($rc eq 'skip') { |
| 348 |
print "-" unless $verbose; |
| 349 |
push(@skipped, $test); |
| 350 |
} else { |
| 351 |
print "." unless $verbose; |
| 352 |
push(@passed, $test); |
| 353 |
} |
| 354 |
$column++; |
| 355 |
if(!$verbose && $column > $linewrap) { |
| 356 |
print "\n$indent"; |
| 357 |
$column=$indent; |
| 358 |
} |
| 359 |
|
| 360 |
if($verbose) { |
| 361 |
my $rcv = $rc; $rcv = uc $rc if $rc ne 'pass'; |
| 362 |
my $i = $indent . $INDENT; |
| 363 |
printf "${i}$test->{name}: $rcv%s\n", |
| 364 |
(length($test->{detail}) ? " - ".$test->{detail} : ''); |
| 365 |
if($verbose > 1) { |
| 366 |
if($rc eq 'fail' && $test->{log}) { |
| 367 |
my(@lines)=split(/\n/, $test->{log}); |
| 368 |
print $i." ".join("\n${i} ", @lines)."\n"; |
| 369 |
} |
| 370 |
} |
| 371 |
} |
| 372 |
|
| 373 |
if($testsuite->{abort}) { |
| 374 |
print "aborted"; |
| 375 |
last; |
| 376 |
} |
| 377 |
} |
| 378 |
print "\n" unless $verbose; |
| 379 |
|
| 380 |
my $plan_file= $testsuite->{plan}; |
| 381 |
unlink $plan_file; |
| 382 |
|
| 383 |
my $status = ((scalar(@xfailed) == $expected_failures_count) && !@failed) ? |
| 384 |
'pass' : 'fail'; |
| 385 |
|
| 386 |
return { |
| 387 |
passed => \@passed, |
| 388 |
failed => \@failed, |
| 389 |
xfailed => \@xfailed, |
| 390 |
skipped => \@skipped, |
| 391 |
uxpassed => \@uxpassed, |
| 392 |
status => $status |
| 393 |
}; |
| 394 |
} |
| 395 |
|
| 396 |
|
| 397 |
sub format_testsuite_result($$$;$) { |
| 398 |
my($fh,$result,$indent,$verbose)=@_; |
| 399 |
$verbose ||= 0; |
| 400 |
|
| 401 |
if(ref($result->{failed})) { |
| 402 |
my(@failed)=@{$result->{failed}}; |
| 403 |
if(@failed) { |
| 404 |
print $fh $indent."Failed tests:\n"; |
| 405 |
for my $ftest (@failed) { |
| 406 |
my $i=$indent.$INDENT; |
| 407 |
print $i . "=" x $banner_width . "\n" if $verbose; |
| 408 |
printf $i . "$ftest->{name}%s\n", |
| 409 |
($verbose ? " in suite $ftest->{testsuite} in $ftest->{dir}" : ""); |
| 410 |
|
| 411 |
print $i . $ftest->{detail} . "\n" if $verbose && $ftest->{detail}; |
| 412 |
if($ftest->{log} && $verbose) { |
| 413 |
my $i2=$i.$INDENT; |
| 414 |
my(@lines)=split(/\n/, $ftest->{log}); |
| 415 |
@lines = splice(@lines, -15) if scalar(@lines) > 15; |
| 416 |
print $i2.join("\n${i2}", "...", @lines)."\n"; |
| 417 |
} |
| 418 |
print $i . "=" x $banner_width . "\n" if $verbose; |
| 419 |
} |
| 420 |
} |
| 421 |
} |
| 422 |
|
| 423 |
if(ref($result->{uxpassed})) { |
| 424 |
my(@uxpassed)=@{$result->{uxpassed}}; |
| 425 |
print $fh $indent."Unexpected passed tests:\n" . $indent . $INDENT . |
| 426 |
join("\n".$indent.$INDENT, |
| 427 |
map { $_->{name}. ($debug ? " (".$_->{test_uri}.")" : "") } |
| 428 |
@uxpassed) . |
| 429 |
"\n" |
| 430 |
if @uxpassed; |
| 431 |
} |
| 432 |
|
| 433 |
print $fh $indent; |
| 434 |
for my $counter (@counters) { |
| 435 |
my $count=0; |
| 436 |
if(defined($result->{$counter}) && ref($result->{$counter})) { |
| 437 |
$count = scalar(@{$result->{$counter}}); |
| 438 |
} |
| 439 |
print $fh ucfirst($counter).": ".$count." "; |
| 440 |
} |
| 441 |
print $fh "\n"; |
| 442 |
|
| 443 |
} |
| 444 |
|
| 445 |
|
| 446 |
sub run_testsuites_in_dir($$$$$) { |
| 447 |
my($dir,$ts,$indent,$verbose,$dryrun)=@_; |
| 448 |
my(@testsuites)=@{$ts}; |
| 449 |
|
| 450 |
chdir($dir) or die "$program: Directory $dir not found\n"; |
| 451 |
|
| 452 |
my(@known_testsuites)=get_testsuites('.'); |
| 453 |
if(!@known_testsuites) { |
| 454 |
warn "$program: Could not find any testsuites in $dir\n"; |
| 455 |
return { status => 'fail', details => 'No testsuites found'}; |
| 456 |
} |
| 457 |
|
| 458 |
my(%is_known_testsuite)=map { $_ => 1} @known_testsuites; |
| 459 |
|
| 460 |
if(!@testsuites) { |
| 461 |
@testsuites = @known_testsuites; |
| 462 |
} else { |
| 463 |
my(@t)=grep($is_known_testsuite{$_}, @testsuites); |
| 464 |
if(!@t) { |
| 465 |
return { status => 'skip', |
| 466 |
details => 'No known testsuites given in: @testsuites'}; |
| 467 |
} |
| 468 |
@testsuites=@t; |
| 469 |
} |
| 470 |
|
| 471 |
print "$indent$program: Running testsuites @testsuites in $dir\n"; |
| 472 |
$indent.=$INDENT; |
| 473 |
|
| 474 |
my $total_result = { }; |
| 475 |
my $total_status='pass'; |
| 476 |
|
| 477 |
for my $testsuite_name (@testsuites) { |
| 478 |
my $testsuite = {dir => $dir, |
| 479 |
name => $testsuite_name |
| 480 |
}; |
| 481 |
|
| 482 |
my $result = prepare_testsuite($testsuite); |
| 483 |
if($result->{status} eq 'fail') { |
| 484 |
my $details=$result->{details}; |
| 485 |
print "$indent$program: Suite $testsuite->{name} failed preparation - $details\n"; |
| 486 |
$total_status='fail'; |
| 487 |
next; |
| 488 |
} |
| 489 |
|
| 490 |
$result=run_testsuite($testsuite, $indent, $verbose); |
| 491 |
|
| 492 |
format_testsuite_result(*STDOUT, $result, $indent.$INDENT, $verbose); |
| 493 |
|
| 494 |
for my $counter (@counters) { |
| 495 |
push(@{$total_result->{$counter}}, @{$result->{$counter}}); |
| 496 |
} |
| 497 |
|
| 498 |
$total_status='fail' if $result->{status} eq 'fail'; |
| 499 |
|
| 500 |
print "\n" if @testsuites > 1; |
| 501 |
} |
| 502 |
|
| 503 |
$total_result->{status} = $total_status; |
| 504 |
|
| 505 |
printf $indent."Testsuites summary%s:\n", ($verbose ? " for dir $dir" : ''); |
| 506 |
format_testsuite_result(*STDOUT, $total_result, $indent.$INDENT, $verbose); |
| 507 |
|
| 508 |
printf $indent."Result status: $total_status\n" if $verbose; |
| 509 |
|
| 510 |
return $total_result; |
| 511 |
} |
| 512 |
|
| 513 |
###################################################################### |
| 514 |
|
| 515 |
$debug=1 if defined $ENV{'RASQAL_DEBUG'}; |
| 516 |
|
| 517 |
my $dryrun=0; |
| 518 |
my $usage=0; |
| 519 |
my $verbose=0; |
| 520 |
my $recursive=0; |
| 521 |
|
| 522 |
# Argument handling |
| 523 |
GetOptions( |
| 524 |
'debug|d+' => \$debug, # incremental |
| 525 |
'dryrun|n' => \$dryrun, |
| 526 |
'recursive|r' => \$recursive, |
| 527 |
'verbose|v+' => \$verbose, # incremental |
| 528 |
'help|h|?' => \$usage |
| 529 |
) || pod2usage(2); |
| 530 |
|
| 531 |
pod2usage(-verbose => 2) if $usage; |
| 532 |
pod2usage("$program: Too many arguments.\n") if (@ARGV > 2); |
| 533 |
|
| 534 |
my($dir,@testsuites)=@ARGV; |
| 535 |
|
| 536 |
$dir ||= '.'; |
| 537 |
|
| 538 |
$verbose++ if $debug; |
| 539 |
|
| 540 |
$dir = abs_path($dir); |
| 541 |
|
| 542 |
my(@dirs); |
| 543 |
if($recursive) { |
| 544 |
my $cmd="find . -type d -print | grep -v \.svn"; |
| 545 |
warn "$program: Recursive scan for testsuites\n" |
| 546 |
if $verbose; |
| 547 |
open(PIPE, "$cmd|") or die "$program: Cannot open pipe from '$cmd' - $!\n"; |
| 548 |
while(<PIPE>) { |
| 549 |
chomp; |
| 550 |
my $dir=abs_path($_); |
| 551 |
my(@testsuites)=get_testsuites($dir); |
| 552 |
if(@testsuites) { |
| 553 |
warn " $_: @testsuites\n" |
| 554 |
if $verbose; |
| 555 |
push(@dirs, $dir) |
| 556 |
} |
| 557 |
} |
| 558 |
close(PIPE); |
| 559 |
} else { |
| 560 |
push(@dirs, abs_path($dir)); |
| 561 |
} |
| 562 |
|
| 563 |
|
| 564 |
warn "$program: Running testsuites in dirs: @dirs\n" |
| 565 |
if $debug; |
| 566 |
|
| 567 |
my $total_result = { }; |
| 568 |
|
| 569 |
my $rc = 0; |
| 570 |
for my $dir (@dirs) { |
| 571 |
my $result = run_testsuites_in_dir($dir, \@testsuites, '', $verbose, $dryrun); |
| 572 |
|
| 573 |
for my $counter (@counters) { |
| 574 |
my $r = $result->{$counter}; |
| 575 |
push(@{$total_result->{$counter}}, @$r) |
| 576 |
if $r; |
| 577 |
} |
| 578 |
|
| 579 |
$rc=1 if $result->{status} eq 'fail'; |
| 580 |
} |
| 581 |
|
| 582 |
if($recursive) { |
| 583 |
print "\nTotal of all Testsuites\n"; |
| 584 |
format_testsuite_result(*STDOUT, $total_result, $INDENT, 1); |
| 585 |
} |
| 586 |
|
| 587 |
exit $rc; |
| 588 |
|
| 589 |
|
| 590 |
__END__ |
| 591 |
|
| 592 |
=head1 NAME |
| 593 |
|
| 594 |
improve - run Rasqal testsuites |
| 595 |
|
| 596 |
=head1 SYNOPSIS |
| 597 |
|
| 598 |
improve [options] [DIR [TESTSUITES]] |
| 599 |
|
| 600 |
=head1 OPTIONS |
| 601 |
|
| 602 |
=over 8 |
| 603 |
|
| 604 |
=item B<-d>, B<--debug> |
| 605 |
|
| 606 |
Enable extra debugging output. |
| 607 |
|
| 608 |
=item B<-n>, B<--dryrun> |
| 609 |
|
| 610 |
Do not run tests. |
| 611 |
|
| 612 |
=item B<-r>, B<--recursive> |
| 613 |
|
| 614 |
Run all testsuites below the given I<DIR> |
| 615 |
|
| 616 |
=item B<-h>, B<--help> |
| 617 |
|
| 618 |
Give help summary. |
| 619 |
|
| 620 |
=item B<-v>, B<--verbose> |
| 621 |
|
| 622 |
Enable extra verbosity when running tests. |
| 623 |
|
| 624 |
=back |
| 625 |
|
| 626 |
=head1 DESCRIPTION |
| 627 |
|
| 628 |
Run Rasqal testsuites from a Turtle manifest in the I<DIR>. If |
| 629 |
I<TESTSUITES> are not given, provides a list of known testsuites in |
| 630 |
I<DIR>. I<DIR> defaults to '.' if not given. |
| 631 |
|
| 632 |
=cut |