diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2011-12-08 15:59:51 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2011-12-08 16:36:07 +0100 |
commit | 038f4b2671c15eb0f87d5277d7c9f04f931f8525 (patch) | |
tree | 5eec4ced979a60dbb923a6450e8076c228e4a012 /scripts | |
parent | 9739b8df6227c70f12bc14a5dd6ca0d9ee6f3d17 (diff) |
Add test2tasks.pl script for converting test logs to task files.
Change-Id: Ia3bdd9c620c469ab87dfcb270617c4bc865ed209
Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/test2tasks.pl | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/scripts/test2tasks.pl b/scripts/test2tasks.pl new file mode 100755 index 0000000000..abaf6ae77a --- /dev/null +++ b/scripts/test2tasks.pl @@ -0,0 +1,58 @@ +#!/usr/bin/perl -w + +=head1 NAME + +test2tasks.pl - Convert QTest logs into Qt Creator task files. + +=head1 SYNOPSIS + + test2tasks.pl < logfile > taskfile + +The script needs to be run in the working directory from which the test log was +obtained as it attempts to perform a mapping from the source file base names of +the test log to relative path names by searching the files. + +=cut + +use strict; + +use File::Find; + +# -- Build a hash from source file base name to relative paths. + +my %fileHash; + +sub handleFile +{ + my $file = $_; + return unless index($file, '.cpp') != -1 && -f $file; +# './file' -> 'file' + $fileHash{$file} = substr($File::Find::name, 0, 1) eq '.' ? substr($File::Find::name, 2) : $File::Find::name; +} + +find({ wanted => \& handleFile}, '.'); + +# --- Find file locations and format them with the cause of the error +# from the above lines as task entry. + +my $lastLine = ''; +while (my $line = <STDIN> ) { + chomp($line); + # --- Continuation line? + if (substr($line, 0, 1) eq ' ') { + $lastLine .= $line; + next; + } + # --- extract file name based matching '[..\].\tst_lancelot.cpp(258) : failure location' + if ($line =~ /^([^(]+)\((\d+)\) : failure location$/) { + my $slashPos = rindex($1, '/'); + $slashPos = rindex($1, "\\") if $slashPos < 0; + my $fileName = $slashPos > 0 ? substr($1, $slashPos + 1) : $1; + my $line = $2; + my $fullFileName = $fileHash{$fileName}; + $fullFileName = $fileName unless defined $fullFileName; + my $type = index($lastLine, 'FAIL') == 0 ? 'err' : 'unknown'; + print $fullFileName, "\t", $line, "\t", $type, "\t", $lastLine,"\n"; + } + $lastLine = $line; +} |