summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoão Abecasis <joao@abecasis.name>2009-03-19 12:36:56 (GMT)
committerJoão Abecasis <joao@abecasis.name>2009-04-02 14:29:49 (GMT)
commit605746fd14ff68f19a806bb54882fb967fccc8e8 (patch)
treef4679f7e4ae9cf7df7846fc416623fcbf699705e /tests
parent0d026b267badbf7890b02256826f0ff3821fcec7 (diff)
downloadQt-605746fd14ff68f19a806bb54882fb967fccc8e8.zip
Qt-605746fd14ff68f19a806bb54882fb967fccc8e8.tar.gz
Qt-605746fd14ff68f19a806bb54882fb967fccc8e8.tar.bz2
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')
-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 b518da8..122a2b8 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 90f7fea..41e5177 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 07389e9..70f1f3c 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()