Fixed qtmodule-configtests on Windows.
open() to "|-" and "-|" are unsupported on Windows (see `perldoc perlport'), so don't do that. Let the tests write a 'config.log' file which contains the output of the test commands. Brings back the part fixing the pipe logic from commit f865dc1ae44c88f6965acd09bafb01829c35447b which was reverted. Change-Id: I5060a0885702d925001b98f2d4e84743d6ff226e Reviewed-by: Kalle Lehtonen <kalle.ju.lehtonen@nokia.com>
This commit is contained in:
parent
0b1586f86c
commit
1db32565c6
@ -54,7 +54,8 @@ use warnings;
|
|||||||
# use packages -------------------------------------------------------
|
# use packages -------------------------------------------------------
|
||||||
use File::Basename;
|
use File::Basename;
|
||||||
use File::Path 'mkpath';
|
use File::Path 'mkpath';
|
||||||
use File::Spec::Functions;
|
use File::Spec::Functions qw/ :ALL /;
|
||||||
|
use File::Temp qw/ :POSIX /;
|
||||||
use Cwd;
|
use Cwd;
|
||||||
use Cwd 'abs_path';
|
use Cwd 'abs_path';
|
||||||
use Config;
|
use Config;
|
||||||
@ -76,7 +77,9 @@ my $generator = $ARGV[3];
|
|||||||
|
|
||||||
our %configtests;
|
our %configtests;
|
||||||
|
|
||||||
my $qmakeCachePath = catfile($out_basedir, ".qmake.cache");
|
my $absOutDir = abs_path($out_basedir);
|
||||||
|
my $qmakeCachePath = catfile($absOutDir, '.qmake.cache');
|
||||||
|
my $configLogPath = catfile($absOutDir, 'config.log');
|
||||||
|
|
||||||
my $QMAKE = catfile($qtbasedir, "bin", ($^O =~ /win32/i) ? 'qmake.exe' : 'qmake');
|
my $QMAKE = catfile($qtbasedir, "bin", ($^O =~ /win32/i) ? 'qmake.exe' : 'qmake');
|
||||||
if (!-x $QMAKE) {
|
if (!-x $QMAKE) {
|
||||||
@ -162,36 +165,51 @@ sub hashesAreDifferent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
# Syntax: executeSomething
|
# Syntax: executeLoggedCommand()
|
||||||
# Params: A list of things.
|
# Params: path to executable, arguments
|
||||||
#
|
#
|
||||||
# Purpose: Executes the first arg, passing the list.
|
# This function is equivalent to system(), except that the command
|
||||||
# stderr is redirected to stdout, and the output is captured.
|
# details and output is placed in the configure log (only).
|
||||||
# Returns: The output.
|
#
|
||||||
|
# Purpose: run a command and log the output
|
||||||
|
# Returns: exit code and output.
|
||||||
######################################################################
|
######################################################################
|
||||||
sub executeSomething {
|
sub executeLoggedCommand {
|
||||||
my ($program, @args) = @_;
|
my (@command_with_args) = @_;
|
||||||
|
|
||||||
my $pid = open(KID_TO_READ, "-|");
|
# Redirect all stdout, stderr into the config.log
|
||||||
|
my ($save_stdout, $save_stderr);
|
||||||
|
open($save_stdout, '>&', STDOUT) || die "save STDOUT: $!";
|
||||||
|
open($save_stderr, '>&', STDERR) || die "save STDERR: $!";
|
||||||
|
|
||||||
my $output;
|
my $tmpName = File::Temp::tempnam(File::Spec->tmpdir(), 'log');
|
||||||
|
open(STDOUT, '>', $tmpName) || die "open $tmpName: $!";
|
||||||
|
open(STDERR, '>&', STDOUT) || die "redirect STDERR to STDOUT: $!";
|
||||||
|
|
||||||
if ($pid) { # parent
|
print "+ @command_with_args\n";
|
||||||
while (<KID_TO_READ>) {
|
my $exitCode = system(@command_with_args) >> 8;
|
||||||
$output = $output . $_;
|
|
||||||
|
# Put them back.
|
||||||
|
close(STDOUT);
|
||||||
|
close(STDERR);
|
||||||
|
open(STDOUT, '>&', $save_stdout) || die "restoring STDOUT: $!";
|
||||||
|
open(STDERR, '>&', $save_stderr) || die "restoring STDERR: $!";
|
||||||
|
|
||||||
|
# Append output to config log and return it.
|
||||||
|
my ($tmpFile, $configLog);
|
||||||
|
my $out = '';
|
||||||
|
open($tmpFile, '<', $tmpName) || die "open $tmpName: $!";
|
||||||
|
open($configLog, '>>', $configLogPath) || die "open $configLogPath: $!";
|
||||||
|
while (my $line = <$tmpFile>) {
|
||||||
|
print $configLog $line;
|
||||||
|
$out .= $line;
|
||||||
}
|
}
|
||||||
close(KID_TO_READ) || $! == 0 || warn "\nFailed to execute $program: exited $?";
|
close($tmpFile);
|
||||||
} else {
|
close($configLog);
|
||||||
# redirect STDERR to STDOUT
|
unlink($tmpName);
|
||||||
open STDERR, ">&STDOUT";
|
return ($exitCode, $out);
|
||||||
|
|
||||||
# Exec something
|
|
||||||
exec ($program, @args) || die "\nCan't exec $program: $!\n";
|
|
||||||
# NOTREACHED
|
|
||||||
}
|
|
||||||
|
|
||||||
return $output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
@ -211,12 +229,19 @@ sub executeSomething {
|
|||||||
sub executeTest {
|
sub executeTest {
|
||||||
my ($testName) = @_;
|
my ($testName) = @_;
|
||||||
|
|
||||||
|
{
|
||||||
|
my $fh;
|
||||||
|
open($fh, '>>', $configLogPath) || die "open $configLogPath: $!";
|
||||||
|
print $fh 'executing config test "',$testName, "\":\n";
|
||||||
|
close($fh);
|
||||||
|
}
|
||||||
|
|
||||||
my $oldWorkingDir = getcwd();
|
my $oldWorkingDir = getcwd();
|
||||||
my $ret = 0;
|
my $ret = 0;
|
||||||
|
|
||||||
my @QMAKEARGS = ('CONFIG-=debug_and_release', 'CONFIG-=app_bundle');
|
my @QMAKEARGS = ('CONFIG-=debug_and_release', 'CONFIG-=app_bundle');
|
||||||
|
|
||||||
my $testOutDir = catdir($out_basedir, 'config.tests', $testName);
|
my $testOutDir = catdir($absOutDir, 'config.tests', $testName);
|
||||||
|
|
||||||
# Since we might be cross compiling, look for barename (Linux) and .exe (Win32/Symbian)
|
# Since we might be cross compiling, look for barename (Linux) and .exe (Win32/Symbian)
|
||||||
my $testOutFile1 = catfile($testOutDir, "$testName.exe");
|
my $testOutFile1 = catfile($testOutDir, "$testName.exe");
|
||||||
@ -236,15 +261,15 @@ sub executeTest {
|
|||||||
# First remove existing stuff (XXX this probably needs generator specific code, but hopefully
|
# First remove existing stuff (XXX this probably needs generator specific code, but hopefully
|
||||||
# the target removal below will suffice)
|
# the target removal below will suffice)
|
||||||
if (-e "Makefile") {
|
if (-e "Makefile") {
|
||||||
executeSomething($MAKE, 'distclean');
|
executeLoggedCommand($MAKE, 'distclean');
|
||||||
}
|
}
|
||||||
|
|
||||||
# and any targets that we might find that weren't distcleaned
|
# and any targets that we might find that weren't distcleaned
|
||||||
unlink $testOutFile1, $testOutFile2;
|
unlink $testOutFile1, $testOutFile2;
|
||||||
|
|
||||||
# Run qmake && make
|
# Run qmake && make
|
||||||
executeSomething($QMAKE, @QMAKEARGS);
|
executeLoggedCommand($QMAKE, @QMAKEARGS);
|
||||||
my $makeOutput = executeSomething(($MAKE));
|
my ($makeExitCode, $makeOutput) = executeLoggedCommand($MAKE);
|
||||||
|
|
||||||
# If make prints "blah blah blah\nSkipped." we consider this a skipped test
|
# If make prints "blah blah blah\nSkipped." we consider this a skipped test
|
||||||
if ($makeOutput !~ qr(^Skipped\.$)ms) {
|
if ($makeOutput !~ qr(^Skipped\.$)ms) {
|
||||||
@ -256,10 +281,20 @@ sub executeTest {
|
|||||||
$ret = 2;
|
$ret = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $fh;
|
||||||
|
open($fh, '>>', $configLogPath) || die "open $configLogPath: $!";
|
||||||
|
print $fh 'config test "',$testName, '" completed with result ',$ret, "\n";
|
||||||
|
close($fh);
|
||||||
|
|
||||||
chdir $oldWorkingDir or die "\nUnable to restore working directory: $!\n";
|
chdir $oldWorkingDir or die "\nUnable to restore working directory: $!\n";
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Remove existing config.log
|
||||||
|
if (-e $configLogPath) {
|
||||||
|
unlink($configLogPath) || die "unlink $configLogPath: $!";
|
||||||
|
}
|
||||||
|
|
||||||
# Now run configuration tests
|
# Now run configuration tests
|
||||||
# %configtests is a map from config test name to a map of parameters
|
# %configtests is a map from config test name to a map of parameters
|
||||||
# e.g:
|
# e.g:
|
||||||
@ -297,6 +332,11 @@ if (abs_path($out_basedir) ne abs_path($qtbasedir)) {
|
|||||||
# Turn off buffering
|
# Turn off buffering
|
||||||
$| = 1;
|
$| = 1;
|
||||||
|
|
||||||
|
# Remove existing config.log
|
||||||
|
if (-e $configLogPath) {
|
||||||
|
unlink($configLogPath) || die "unlink $configLogPath: $!";
|
||||||
|
}
|
||||||
|
|
||||||
# Now run the configuration tests
|
# Now run the configuration tests
|
||||||
print "Configuration tests:\n" if (%configtests);
|
print "Configuration tests:\n" if (%configtests);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user