summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2012-01-12 16:03:33 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-12 16:43:37 +0100
commitf865dc1ae44c88f6965acd09bafb01829c35447b (patch)
tree728e4660e377ee78c41444fc8efc7709e44862e8
parenteb8fce6e5674ce199c19843ac8071063580bc9f6 (diff)
Fixed qtmodule-configtests on Windows
open to "|-" and "-|" are unsupported on Windows (see `perldoc perlport'), so don't do that. Rather than parsing the output of make to decide if a config test is skipped, use a looser definition: it is skipped if qmake and make both succeed, but no binary is created. Change-Id: Idab7266888e9c934aa7b5c1c6ac5930439681107 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
-rwxr-xr-xbin/qtmodule-configtests88
1 files changed, 53 insertions, 35 deletions
diff --git a/bin/qtmodule-configtests b/bin/qtmodule-configtests
index 9640869fb8..505cc8049f 100755
--- a/bin/qtmodule-configtests
+++ b/bin/qtmodule-configtests
@@ -76,7 +76,9 @@ my $generator = $ARGV[3];
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');
if (!-x $QMAKE) {
@@ -162,36 +164,36 @@ sub hashesAreDifferent {
}
}
+
######################################################################
-# Syntax: executeSomething
-# Params: A list of things.
+# Syntax: executeLoggedCommand()
+# Params: path to executable, arguments
+#
+# This function is equivalent to system(), except that the command
+# details and output is placed in the configure log (only).
#
-# Purpose: Executes the first arg, passing the list.
-# stderr is redirected to stdout, and the output is captured.
-# Returns: The output.
+# Purpose: run a command and log the output
+# Returns: exit status (as returned by system())
######################################################################
-sub executeSomething {
- my ($program, @args) = @_;
+sub executeLoggedCommand {
+ 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: $!";
+ open(STDOUT, '>>', $configLogPath) || die "open $configLogPath: $!";
+ open(STDERR, '>&', STDOUT) || die "redirect STDERR to STDOUT: $!";
- my $output;
- if ($pid) { # parent
- while (<KID_TO_READ>) {
- $output = $output . $_;
- }
- close(KID_TO_READ) || $! == 0 || warn "\nFailed to execute $program: exited $?";
- } else {
- # redirect STDERR to STDOUT
- open STDERR, ">&STDOUT";
+ print "+ @command_with_args\n";
+ my $out = system(@command_with_args);
- # Exec something
- exec ($program, @args) || die "\nCan't exec $program: $!\n";
- # NOTREACHED
- }
+ # Put them back.
+ open(STDOUT, '>&', $save_stdout) || die "restoring STDOUT: $!";
+ open(STDERR, '>&', $save_stderr) || die "restoring STDERR: $!";
- return $output;
+ return $out;
}
######################################################################
@@ -211,12 +213,18 @@ sub executeSomething {
sub executeTest {
my ($testName) = @_;
+ {
+ my $fh;
+ open($fh, '>>', $configLogPath) || die "open $configLogPath: $!";
+ print $fh "executing config test $testName:\n";
+ }
+
my $oldWorkingDir = getcwd();
- my $ret = 0;
+ my $ret;
my @QMAKEARGS = ('CONFIG-=debug_and_release', 'CONFIG-=app_bundle');
- my $testOutDir = catdir($out_basedir, 'config.tests', $testName);
+ my $testOutDir = abs_path(catdir($out_basedir, 'config.tests', $testName));
# Since we might be cross compiling, look for barename (Linux) and .exe (Win32/Symbian)
my $testOutFile1 = catfile($testOutDir, "$testName.exe");
@@ -236,26 +244,31 @@ sub executeTest {
# First remove existing stuff (XXX this probably needs generator specific code, but hopefully
# the target removal below will suffice)
if (-e "Makefile") {
- executeSomething($MAKE, 'distclean');
+ executeLoggedCommand($MAKE, 'distclean');
}
# and any targets that we might find that weren't distcleaned
unlink $testOutFile1, $testOutFile2;
# Run qmake && make
- executeSomething($QMAKE, @QMAKEARGS);
- my $makeOutput = executeSomething(($MAKE));
-
- # If make prints "blah blah blah\nSkipped." we consider this a skipped test
- if ($makeOutput !~ qr(^Skipped\.$)ms) {
- # Check the test exists (can't reliably execute, especially for cross compilation)
- if (-e $testOutFile1 or -e $testOutFile2) {
- $ret = 1;
- }
+ if (executeLoggedCommand($QMAKE, @QMAKEARGS)) {
+ # qmake failed -> config test failed
+ $ret = 0;
+ } elsif (executeLoggedCommand($MAKE)) {
+ # make failed -> config test failed
+ $ret = 0;
+ } elsif (-e $testOutFile1 or -e $testOutFile2) {
+ # qmake, make passed, output file exists -> success
+ $ret = 1;
} else {
+ # qmake, make passed, output file doesn't exist -> skipped
$ret = 2;
}
+ my $fh;
+ open($fh, '>>', $configLogPath) || die "open $configLogPath: $!";
+ print $fh "config test $testName completed with result $ret\n";
+
chdir $oldWorkingDir or die "\nUnable to restore working directory: $!\n";
return $ret;
}
@@ -297,6 +310,11 @@ if (abs_path($out_basedir) ne abs_path($qtbasedir)) {
# Turn off buffering
$| = 1;
+ # Remove existing config.log
+ if (-e $configLogPath) {
+ unlink($configLogPath) || die "unlink $configLogPath: $!";
+ }
+
# Now run the configuration tests
print "Configuration tests:\n" if (%configtests);