diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2011-12-22 11:29:04 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2011-12-22 11:31:25 +0100 |
commit | 4c54a05f893b7435c7331b2cf0094935a9dcbdc8 (patch) | |
tree | c1975131e2ae6a3c47a0441066b9fe752f64f632 | |
parent | 79db165dcb7c6999ccc9241910b7f762f358188a (diff) |
test2tasks.pl: Add useful options for submodule testing.
Make it possible to use absolute file names or prefix them for
creating Qt 5 testing summary logs.
Change-Id: I3d4a5fa24a9a7652fb4f8087e4b6e2a6ae6fdfe7
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
-rwxr-xr-x | scripts/test2tasks.pl | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/scripts/test2tasks.pl b/scripts/test2tasks.pl index 437e2889b0..a37cc974b1 100755 --- a/scripts/test2tasks.pl +++ b/scripts/test2tasks.pl @@ -6,7 +6,15 @@ test2tasks.pl - Convert QTest logs into Qt Creator task files. =head1 SYNOPSIS - test2tasks.pl < logfile > taskfile + test2tasks.pl [OPTIONS] < logfile > taskfile + +Options: + + -a Use absolute file paths + + -r <some_path> Prefix all file names by <some_path> (Used for + creating a summarized log of a submodule repository) + 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 @@ -17,17 +25,40 @@ the test log to relative path names by searching the files. use strict; use File::Find; +use Getopt::Long; +use File::Spec; +use Cwd; + +my $optAbsolute = 0; +my $optRelativeTo; # -- Build a hash from source file base name to relative paths. my %fileHash; +my $workingDirectory = getcwd(); 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; + my $name = substr($File::Find::name, 0, 1) eq '.' ? + substr($File::Find::name, 2) : $File::Find::name; + my $fullName = $name; + if (defined $optRelativeTo) { + $fullName = File::Spec->catfile($optRelativeTo, $File::Find::name); + } else { + $fullName = File::Spec->catfile($workingDirectory, $File::Find::name) if ($optAbsolute); + } + $fullName =~ s|\\|/|g; # The task pane wants forward slashes on Windows, also. + $fileHash{$file} = $fullName; +} + +# Main +if (!GetOptions("absolute" => \$optAbsolute, + "relative=s" => \$optRelativeTo)) { + print "Invalid option\n"; + exit (0); } find({ wanted => \& handleFile}, '.'); @@ -71,4 +102,4 @@ while (my $line = <STDIN> ) { $lastLine = $line; } -print STDERR 'Done, FAIL: ',$failCount, ', FATAL: ',$fatalCount, "\n"; +print STDERR 'Done, ISSUES: ',$failCount, ', FATAL: ',$fatalCount, "\n"; |