From 605746fd14ff68f19a806bb54882fb967fccc8e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 19 Mar 2009 13:36:56 +0100 Subject: In qmake tests, allow child environment to be manipulated ... without having to change the parent process's environment. Reviewed-by: mariusSO --- tests/auto/qmake/testcompiler.cpp | 13 +++++++++++++ tests/auto/qmake/testcompiler.h | 3 +++ tests/auto/qmake/tst_qmake.cpp | 4 ++-- 3 files changed, 18 insertions(+), 2 deletions(-) (limited to 'tests/auto/qmake') diff --git a/tests/auto/qmake/testcompiler.cpp b/tests/auto/qmake/testcompiler.cpp index b518da808e..122a2b8217 100644 --- a/tests/auto/qmake/testcompiler.cpp +++ b/tests/auto/qmake/testcompiler.cpp @@ -133,6 +133,9 @@ bool TestCompiler::runCommand( QString cmdline ) testOutput_.append("Running command: " + cmdline); QProcess child; + if (!environment_.empty()) + child.setEnvironment(QProcess::systemEnvironment() + environment_); + child.start(cmdline); if (!child.waitForStarted(-1)) { testOutput_.append( "Unable to start child process." ); @@ -166,6 +169,16 @@ void TestCompiler::setBaseCommands( QString makeCmd, QString qmakeCmd ) qmakeCmd_ = qmakeCmd; } +void TestCompiler::resetEnvironment() +{ + environment_.clear(); +} + +void TestCompiler::addToEnvironment( QString varAssignment ) +{ + environment_.push_back(varAssignment); +} + bool TestCompiler::makeClean( const QString &workPath ) { QDir D; diff --git a/tests/auto/qmake/testcompiler.h b/tests/auto/qmake/testcompiler.h index 90f7fea155..41e51774f4 100644 --- a/tests/auto/qmake/testcompiler.h +++ b/tests/auto/qmake/testcompiler.h @@ -55,6 +55,8 @@ public: virtual ~TestCompiler(); void setBaseCommands( QString makeCmd, QString qmakeCmd ); + void resetEnvironment(); + void addToEnvironment( QString varAssignment ); // executes a make clean in the specified workPath bool makeClean( const QString &workPath ); @@ -74,6 +76,7 @@ private: QString makeCmd_; QString qmakeCmd_; + QStringList environment_; // need to make this available somewhere QStringList testOutput_; diff --git a/tests/auto/qmake/tst_qmake.cpp b/tests/auto/qmake/tst_qmake.cpp index 07389e9531..70f1f3c6e1 100644 --- a/tests/auto/qmake/tst_qmake.cpp +++ b/tests/auto/qmake/tst_qmake.cpp @@ -247,10 +247,10 @@ void tst_qmake::duplicateLibraryEntries() void tst_qmake::export_across_file_boundaries() { // This relies on features so we need to set the QMAKEFEATURES environment variable - putenv("QMAKEFEATURES=."); + test_compiler.addToEnvironment("QMAKEFEATURES=."); QString workDir = base_path + "/testdata/export_across_file_boundaries"; QVERIFY( test_compiler.qmake( workDir, "foo" )); - putenv("QMAKEFEATURES="); + test_compiler.resetEnvironment(); } void tst_qmake::include_dir() -- cgit v1.2.1