diff options
Diffstat (limited to 'tests/auto')
8 files changed, 61 insertions, 0 deletions
diff --git a/tests/auto/qmake/testcompiler.cpp b/tests/auto/qmake/testcompiler.cpp index 8d7c9d2..4e1d9ba 100644 --- a/tests/auto/qmake/testcompiler.cpp +++ b/tests/auto/qmake/testcompiler.cpp @@ -261,3 +261,17 @@ bool TestCompiler::removeMakefile( const QString &workPath ) else return true; } + +QString TestCompiler::commandOutput() const +{ +#ifndef Q_OS_WIN + return testOutput_.join("\n"); +#else + return testOutput_.join("\r\n"); +#endif +} + +void TestCompiler::clearCommandOutput() +{ + testOutput_.clear(); +} diff --git a/tests/auto/qmake/testcompiler.h b/tests/auto/qmake/testcompiler.h index 76d9ee5..026344f 100644 --- a/tests/auto/qmake/testcompiler.h +++ b/tests/auto/qmake/testcompiler.h @@ -70,6 +70,10 @@ public: bool exists( const QString &destDir, const QString &exeName, BuildType buildType, const QString &version ); // removes the makefile bool removeMakefile( const QString &workPath ); + // returns each line of stdout of the last command append with a "new line" character(s) to suit the platform + QString commandOutput() const; + // clear the results of storage of stdout for running previous commands + void clearCommandOutput(); private: bool runCommand( QString cmdLine ); diff --git a/tests/auto/qmake/testdata/include_function/existing_file.pri b/tests/auto/qmake/testdata/include_function/existing_file.pri new file mode 100644 index 0000000..8b9aaca --- /dev/null +++ b/tests/auto/qmake/testdata/include_function/existing_file.pri @@ -0,0 +1,3 @@ +QT = +CONFIG = console +SOURCES = main.cpp diff --git a/tests/auto/qmake/testdata/include_function/include_existing_file.pro b/tests/auto/qmake/testdata/include_function/include_existing_file.pro new file mode 100644 index 0000000..424062a --- /dev/null +++ b/tests/auto/qmake/testdata/include_function/include_existing_file.pro @@ -0,0 +1,7 @@ +# Test to see if include(), by default, succeeds when the specific file +# to include exists +include(existing_file.pri) + +# Test to see if by specifying full set of parameters to include() +# succeeds when the specified filed to include exists +include(existing_file.pri, "", false) diff --git a/tests/auto/qmake/testdata/include_function/include_missing_file.pro b/tests/auto/qmake/testdata/include_function/include_missing_file.pro new file mode 100644 index 0000000..0b59981 --- /dev/null +++ b/tests/auto/qmake/testdata/include_function/include_missing_file.pro @@ -0,0 +1,3 @@ +# Test to see if include(), by default, fails when the specific file +# to include does not exist +include(missing_file.pri) diff --git a/tests/auto/qmake/testdata/include_function/include_missing_file2.pro b/tests/auto/qmake/testdata/include_function/include_missing_file2.pro new file mode 100644 index 0000000..542b9ff --- /dev/null +++ b/tests/auto/qmake/testdata/include_function/include_missing_file2.pro @@ -0,0 +1,3 @@ +# Specifying full set of parameters to include() to test that a warning +# is shown for this non-existing file. +include(missing_file.pri, "", false) diff --git a/tests/auto/qmake/testdata/include_function/main.cpp b/tests/auto/qmake/testdata/include_function/main.cpp new file mode 100644 index 0000000..0a8e3d3 --- /dev/null +++ b/tests/auto/qmake/testdata/include_function/main.cpp @@ -0,0 +1,4 @@ +int main(int /*argc*/, char ** /*argv*/) +{ + return 0; +} diff --git a/tests/auto/qmake/tst_qmake.cpp b/tests/auto/qmake/tst_qmake.cpp index 168fcfd..50ea5b9 100644 --- a/tests/auto/qmake/tst_qmake.cpp +++ b/tests/auto/qmake/tst_qmake.cpp @@ -88,6 +88,7 @@ private slots: // Test requires make void bundle_spaces(); #endif + void includefunction(); private: TestCompiler test_compiler; @@ -125,10 +126,12 @@ void tst_qmake::cleanupTestCase() void tst_qmake::init() { + test_compiler.clearCommandOutput(); } void tst_qmake::cleanup() { + test_compiler.clearCommandOutput(); } void tst_qmake::simple_app() @@ -438,6 +441,26 @@ void tst_qmake::bundle_spaces() } #endif // Q_OS_WIN +void tst_qmake::includefunction() +{ + QString workDir = base_path + "/testdata/include_function"; + QString warningMsg("Unable to find file for inclusion"); + QVERIFY(test_compiler.qmake( workDir, "include_existing_file")); + QVERIFY(!test_compiler.commandOutput().contains(warningMsg)); + + // test include() usage on a missing file + test_compiler.clearCommandOutput(); + workDir = base_path + "/testdata/include_function"; + QVERIFY(test_compiler.qmake( workDir, "include_missing_file" )); + QVERIFY(test_compiler.commandOutput().contains(warningMsg)); + + // test include() usage on a missing file when all function parameters are used + test_compiler.clearCommandOutput(); + workDir = base_path + "/testdata/include_function"; + QVERIFY(test_compiler.qmake( workDir, "include_missing_file2" )); + QVERIFY(test_compiler.commandOutput().contains(warningMsg)); +} + QTEST_MAIN(tst_qmake) #include "tst_qmake.moc" |