diff options
| author | Rohan McGovern <rohan.mcgovern@nokia.com> | 2012-04-30 10:11:44 +1000 |
|---|---|---|
| committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-30 05:33:24 +0200 |
| commit | 44849808f32650f7be3480cb2a19482a255848e5 (patch) | |
| tree | 38ff9c001513b2a708278434689a7c45894c0207 /scripts/lib/perl5/QtQA/TestScript.pm | |
| parent | d54b128501df26b5b49e26d77e0096cac6cc91a1 (diff) | |
QtQA::TestScript: during exe, print CWD and PATH when they change
We always print each command we run, but we weren't printing the CWD or
PATH, making the command log often useless.
At each exe(), print the current working directory and PATH if they are
different from the last exe(). This makes the logs less ambiguous.
Change-Id: I78f5e2b5589889f8e98f2e62ee5697e7e6018499
Reviewed-by: Toby Tomkins <toby.tomkins@nokia.com>
Reviewed-by: Kalle Lehtonen <kalle.ju.lehtonen@nokia.com>
Diffstat (limited to 'scripts/lib/perl5/QtQA/TestScript.pm')
| -rw-r--r-- | scripts/lib/perl5/QtQA/TestScript.pm | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/scripts/lib/perl5/QtQA/TestScript.pm b/scripts/lib/perl5/QtQA/TestScript.pm index c63c78e8..dc64027a 100644 --- a/scripts/lib/perl5/QtQA/TestScript.pm +++ b/scripts/lib/perl5/QtQA/TestScript.pm @@ -50,6 +50,7 @@ use Carp; use Config; use Cwd qw(); use Data::Dumper qw(); +use File::chdir; use Getopt::Long qw(GetOptionsFromArray); use IO::Socket::INET; use Lingua::EN::Numbers qw(num2en_ordinal); @@ -234,12 +235,36 @@ sub exe local @ENV{@property_env_keys} = values %{$self->{resolved_property}}; + $self->_track_exe_environment( ); $self->print_when_verbose(0, '+ ', join(' ', @command), "\n"); $self->_reliable_exe( \%options, @command ); return; } +# Immediately prior to running a subprocess, record the CWD and PATH, +# and print the value(s) of these if they are different from last time. +# Should be called once for each exe() invocation. +sub _track_exe_environment +{ + my ($self) = @_; + + my $last_cwd = $self->{ _last_exe_cwd }; + if (!$last_cwd || $last_cwd ne $CWD) { + $self->print_when_verbose( 0, "+ CWD: $CWD\n" ); + $self->{ _last_exe_cwd } = $CWD; + } + + my $PATH = $ENV{ PATH }; + my $last_path = $self->{ _last_exe_path }; + if (!$last_path || $last_path ne $PATH) { + $self->print_when_verbose( 0, "+ PATH: $PATH\n" ); + $self->{ _last_exe_path } = $PATH; + } + + return; +} + sub _handle_exe_status { my ($self, $status, @command) = @_; |
