diff --git a/testing/dav_test b/testing/dav_test index c1d665cc..52107ba8 100755 --- a/testing/dav_test +++ b/testing/dav_test @@ -10,6 +10,7 @@ use File::Copy; use DBI; use Getopt::Long qw(:config permute); # allow mixed args. +use File::pushd; # Options variables my $debug = 0; @@ -57,8 +58,9 @@ push @arguments, "--silent" unless ( $debug ); push @arguments, "--verbose" if ( $debug ); my $url; -my $script; -my @scripts = ( ); +my $script; # Not neede as global, used as flag. +my $script_dir; +my $is_head_request = 0; my @auth = ( "--user", "user1:user1" ); # Allow easier pasting of tests on the command line. @@ -249,6 +251,7 @@ while( ) { } }; + # HTTP headers to send with curl $line =~ /^\s*HEADER\s*=\s*(\S.*)$/ && do { my $arg = $1; $arg =~ s{regression.host}{$webhost}; @@ -257,6 +260,7 @@ while( ) { push @arguments, "--header", $arg; }; + # URL to use with curl $line =~ /^\s*URL\s*=\s*(\S.*)$/ && do { $url=$1; $url =~ s{regression.host}{$webhost}; @@ -264,12 +268,32 @@ while( ) { $url =~ s{alternate.host}{$althost}; }; + + # The directory to run the next SCRIPT in. + $line =~ /^\s*SCRIPT_DIR\s*=\s*(\S.*)$/ && do { + $script_dir = $1; + }; + + # Run this SCRIPT, collect the output. $line =~ /^\s*SCRIPT\s*=\s*(\S.*)$/ && do { $script=$1; $script =~ s{regression.host}{$webhost}; $script =~ s{regression_ldap.host}{$ldaphost}; $script =~ s{alternate.host}{$althost}; - push @scripts, $script; + + my $dir = pushd($script_dir) + if defined $script_dir; + + open RESULTS, "-|", $script; + while( ) { + my $line = $_; + foreach my $replacement ( @$replacements ) { + $line =~ s/$replacement->{'pattern'}/$replacement->{'replacement'}/; + } + print $line; + } + + $script_dir = undef; }; $line =~ /^\s*STATIC\s*=\s*(.*?)\s*$/ && do { @@ -323,19 +347,6 @@ if ( defined($url) ) { } } -if ( defined($script) ) { - foreach $script ( @scripts ) { - open RESULTS, "-|", $script; - while( ) { - my $line = $_; - foreach my $replacement ( @$replacements ) { - $line =~ s/$replacement->{'pattern'}/$replacement->{'replacement'}/; - } - print $line; - } - } -} - if ( defined($queries) && @{$queries} ) { opendb() unless defined($dbh); print "\n"; @@ -345,10 +356,15 @@ if ( defined($queries) && @{$queries} ) { foreach $sql_statement ( @$queries ) { # run SQL statement and dump results, into array of hashes my $results = $dbh->selectall_arrayref($sql_statement, { Slice => {} } ); + if ( $dbh->err ) { print $dbh->errstr, "\n"; next; + } elsif (! defined $results) { + print "No results from SQL query\n"; + next; } + foreach my $row ( @$results ) { warn "Query result ================================================\n" if $debug; diff --git a/testing/gitlab_ci_script.sh b/testing/gitlab_ci_script.sh index a3b8102d..2b321859 100755 --- a/testing/gitlab_ci_script.sh +++ b/testing/gitlab_ci_script.sh @@ -51,14 +51,15 @@ echo "LANG=en_NZ.UTF-8" > /etc/default/locale ### packages="libdbd-pg-perl libyaml-perl postgresql-client postgresql - curl xmlstarlet netcat-openbsd libtest-www-mechanize-perl" + curl xmlstarlet netcat-openbsd libtest-www-mechanize-perl + libfile-pushd-perl" if [[ $mode =~ "latestphp" ]]; then # PHP pgsql package is built from source, needs libpq-dev. packages="$packages libpq-dev" else - # The latestphp images already have some of these available, and others need - # to installed in another method. + # The latestphp images already have some of these available, and others + # need to installed in another method. packages="$packages libapache2-mod-php php php-cli php-pgsql php-xml php-curl" fi