diff options
author | Jyri Tahtela <jyri.tahtela@nokia.com> | 2011-12-19 15:31:55 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-21 00:52:37 +0100 |
commit | c894487020a5a24ef48b2041d98c58ebd13bcef1 (patch) | |
tree | cd398caf277263bc9429490185543b7c5382eca2 /scripts/test.pl | |
parent | 18363ab937d8982f21933273c3c1b346d4235e25 (diff) |
test.pl: make script more robust for network problems
virtualenv installation may cause failures due to network being
unreachable. Now script will try virtualenv installation multiple
times until proceeding further.
Change-Id: I63a630c4d729784e8ce9197c5f9a4b97a9ea5473
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Toby Tomkins <toby.tomkins@nokia.com>
Diffstat (limited to 'scripts/test.pl')
-rwxr-xr-x | scripts/test.pl | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/scripts/test.pl b/scripts/test.pl index eb4f29fc..13fe1b10 100755 --- a/scripts/test.pl +++ b/scripts/test.pl @@ -245,7 +245,30 @@ sub make_clean_prefix # python: virtualenv creates the dirs. It does not set env, # so we do it manually. my $virtualenv_dir = "$cleandir/python"; - $self->system_or_die('virtualenv', '--clear', $virtualenv_dir); + + # we'll retry up to this many times, e.g. to recover from temporary network issues. + my $MAX_TRIES = 8; + my $tries = 0; + while (1) { + eval { $self->system_or_die('virtualenv', '--clear', $virtualenv_dir) }; + if ( $@ ) { + print "\n$@\nLooks like virtualenv installation was not successful."; + if ($tries++ < $MAX_TRIES) { + # wait for 8, 16, 32, 64 ... seconds. + my $delay = 2**($tries+2); + print "\nTrying again in $delay seconds [attempt $tries of $MAX_TRIES].\n"; + sleep $delay; + } + else { + print "\nGiving up :(\n"; + return 0; + } + } + else { + print "\nInstallation of virtualenv was successful.\n"; + last; + } + } $ENV{VIRTUAL_ENV} = $virtualenv_dir; ## no critic - localized by caller $ENV{PATH} = "$virtualenv_dir/bin:".$ENV{PATH}; ## no critic - localized by caller |