summaryrefslogtreecommitdiffstats
path: root/tests/auto/qmake
diff options
context:
space:
mode:
authorJoão Abecasis <joao@abecasis.name>2009-03-19 13:36:56 +0100
committerJoão Abecasis <joao@abecasis.name>2009-04-02 16:29:49 +0200
commit605746fd14ff68f19a806bb54882fb967fccc8e8 (patch)
treef4679f7e4ae9cf7df7846fc416623fcbf699705e /tests/auto/qmake
parent0d026b267badbf7890b02256826f0ff3821fcec7 (diff)
In qmake tests, allow child environment to be manipulated
... without having to change the parent process's environment. Reviewed-by: mariusSO
Diffstat (limited to 'tests/auto/qmake')
-rw-r--r--tests/auto/qmake/testcompiler.cpp13
-rw-r--r--tests/auto/qmake/testcompiler.h3
-rw-r--r--tests/auto/qmake/tst_qmake.cpp4
3 files changed, 18 insertions, 2 deletions
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()