diff --git a/src/plugins/autotest/autotestunittests.cpp b/src/plugins/autotest/autotestunittests.cpp index d20fcf81490..2628c0698d1 100644 --- a/src/plugins/autotest/autotestunittests.cpp +++ b/src/plugins/autotest/autotestunittests.cpp @@ -194,9 +194,9 @@ void AutoTestUnitTests::testCodeParserGTest() if (qgetenv("GOOGLETEST_DIR").isEmpty()) QSKIP("This test needs googletest - set GOOGLETEST_DIR (point to googletest repository)"); + QFETCH(QString, projectFilePath); CppTools::Tests::ProjectOpenerAndCloser projectManager; - CppTools::ProjectInfo projectInfo = projectManager.open( - QString(m_tmpDir->path() + QLatin1String("/simple_gt/simple_gt.pro")), true); + CppTools::ProjectInfo projectInfo = projectManager.open(projectFilePath, true); QVERIFY(projectInfo.isValid()); QSignalSpy parserSpy(m_model->parser(), SIGNAL(parsingFinished())); @@ -226,5 +226,14 @@ void AutoTestUnitTests::testCodeParserGTest() QCOMPARE(m_model->dataTagsCount(), 0); } +void AutoTestUnitTests::testCodeParserGTest_data() +{ + QTest::addColumn("projectFilePath"); + QTest::newRow("simpleGoogletest") + << QString(m_tmpDir->path() + QLatin1String("/simple_gt/simple_gt.pro")); + QTest::newRow("simpleGoogletestQbs") + << QString(m_tmpDir->path() + QLatin1String("/simple_gt/simple_gt.qbs")); +} + } // namespace Internal } // namespace Autotest diff --git a/src/plugins/autotest/autotestunittests.h b/src/plugins/autotest/autotestunittests.h index 6eab3749d45..a6c24987f27 100644 --- a/src/plugins/autotest/autotestunittests.h +++ b/src/plugins/autotest/autotestunittests.h @@ -52,6 +52,7 @@ private slots: void testCodeParserSwitchStartup(); void testCodeParserSwitchStartup_data(); void testCodeParserGTest(); + void testCodeParserGTest_data(); private: TestTreeModel *m_model; diff --git a/src/plugins/autotest/autotestunittests.qrc b/src/plugins/autotest/autotestunittests.qrc index 861f5c26654..0bc8017cc32 100644 --- a/src/plugins/autotest/autotestunittests.qrc +++ b/src/plugins/autotest/autotestunittests.qrc @@ -41,17 +41,24 @@ unit_test/mixed_atp/tests/auto/quickauto2/quickauto2.qbs unit_test/simple_gt/src/main.cpp unit_test/simple_gt/src/src.pro + unit_test/simple_gt/src/src.qbs unit_test/simple_gt/tests/gt1/further.cpp unit_test/simple_gt/tests/gt1/gt1.pro + unit_test/simple_gt/tests/gt1/gt1.qbs unit_test/simple_gt/tests/gt1/main.cpp unit_test/simple_gt/tests/gt2/gt2.pro + unit_test/simple_gt/tests/gt2/gt2.qbs unit_test/simple_gt/tests/gt2/main.cpp unit_test/simple_gt/tests/gt2/queuetest.h unit_test/simple_gt/tests/tests.pro + unit_test/simple_gt/tests/tests.qbs unit_test/simple_gt/simple_gt.pro + unit_test/simple_gt/simple_gt.qbs unit_test/simple_gt/tests/gtest_dependency.pri unit_test/simple_gt/tests/gt3/dummytest.h unit_test/simple_gt/tests/gt3/gt3.pro + unit_test/simple_gt/tests/gt3/gt3.qbs unit_test/simple_gt/tests/gt3/main.cpp + unit_test/simple_gt/tests/common/functions.js diff --git a/src/plugins/autotest/unit_test/simple_gt/simple_gt.qbs b/src/plugins/autotest/unit_test/simple_gt/simple_gt.qbs new file mode 100644 index 00000000000..8d4af25287b --- /dev/null +++ b/src/plugins/autotest/unit_test/simple_gt/simple_gt.qbs @@ -0,0 +1,10 @@ +import qbs + +Project { + name: "Simple GT" + + references: [ + "src/src.qbs", + "tests/tests.qbs" + ] +} diff --git a/src/plugins/autotest/unit_test/simple_gt/src/src.qbs b/src/plugins/autotest/unit_test/simple_gt/src/src.qbs new file mode 100644 index 00000000000..bbdcaca22bc --- /dev/null +++ b/src/plugins/autotest/unit_test/simple_gt/src/src.qbs @@ -0,0 +1,10 @@ +import qbs + +CppApplication { + type: "application" + name: "Dummy application" + + Depends { name: "Qt.core" } + + files: [ "main.cpp" ] +} diff --git a/src/plugins/autotest/unit_test/simple_gt/tests/common/functions.js b/src/plugins/autotest/unit_test/simple_gt/tests/common/functions.js new file mode 100644 index 00000000000..8ce7f31ad95 --- /dev/null +++ b/src/plugins/autotest/unit_test/simple_gt/tests/common/functions.js @@ -0,0 +1,49 @@ +var FileInfo = loadExtension("qbs.FileInfo") + +function getGTestDir(str) { + if (!str) { + if (qbs.hostOS.contains("linux")) + return "/usr/include/gtest"; + } else { + return FileInfo.joinPaths(str, "googletest"); + } + return ""; +} + +function getGMockDir(str) { + if (!str) { + if (qbs.hostOS.contains("linux")) + return "/usr/include/gmock"; + } else { + return FileInfo.joinPaths(str, "googlemock"); + } + return ""; +} + +function getGTestAll(str) { + var gtest = getGTestDir(str); + if (!gtest) + return []; + return [FileInfo.joinPaths(gtest, "src/gtest-all.cc")]; +} + +function getGMockAll(str) { + var gmock = getGMockDir(str); + if (!gmock) + return []; + return [FileInfo.joinPaths(gmock, "src/gmock-all.cc")]; +} + +function getGTestIncludes(str) { + var gtest = getGTestDir(str); + if (!gtest) + return []; + return [gtest, FileInfo.joinPaths(gtest, "include")]; +} + +function getGMockIncludes(str) { + var mock = getGMockDir(str); + if (!mock) + return []; + return [mock, FileInfo.joinPaths(mock, "include")]; +} diff --git a/src/plugins/autotest/unit_test/simple_gt/tests/gt1/gt1.qbs b/src/plugins/autotest/unit_test/simple_gt/tests/gt1/gt1.qbs new file mode 100644 index 00000000000..f560bb41e6a --- /dev/null +++ b/src/plugins/autotest/unit_test/simple_gt/tests/gt1/gt1.qbs @@ -0,0 +1,35 @@ +import qbs +import qbs.File +import qbs.FileInfo +import "../common/functions.js" as googleCommon + +CppApplication { + type: "application" + name: "googletest1" + + property string gtestDir: googleCommon.getGTestDir(project.googletestDir) + property string gmockDir: googleCommon.getGMockDir(project.googletestDir) + + condition: { + if (File.exists(gtestDir) && File.exists(gmockDir)) + return true; + + console.error("Cannot find Google Test - specify environment variable GOOGLETEST_DIR " + + "or qbs property " + project.name + ".googletestDir" ); + return false; + } + + cpp.includePaths: [].concat(googleCommon.getGTestIncludes(project.googletestDir)) + .concat(googleCommon.getGMockIncludes(project.googletestDir)) + + cpp.cxxLanguageVersion: "c++11" + cpp.defines: ["GTEST_LANG_CXX11"] + cpp.dynamicLibraries: [ "pthread" ] + + files: [ + // own stuff + "further.cpp", + "main.cpp", + ].concat(googleCommon.getGTestAll(project.googletestDir)) + .concat(googleCommon.getGMockAll(project.googletestDir)) +} diff --git a/src/plugins/autotest/unit_test/simple_gt/tests/gt2/gt2.qbs b/src/plugins/autotest/unit_test/simple_gt/tests/gt2/gt2.qbs new file mode 100644 index 00000000000..b0a898103f5 --- /dev/null +++ b/src/plugins/autotest/unit_test/simple_gt/tests/gt2/gt2.qbs @@ -0,0 +1,36 @@ +import qbs +import qbs.File +import qbs.FileInfo +import "../common/functions.js" as googleCommon + +CppApplication { + type: "application" + name: "googletest2" + + property string gtestDir: googleCommon.getGTestDir(project.googletestDir) + property string gmockDir: googleCommon.getGMockDir(project.googletestDir) + + Depends { name: "Qt.core" } + + condition: { + if (File.exists(gtestDir) && File.exists(gmockDir)) + return true; + + console.error("Cannot find Google Test - specify environment variable GOOGLETEST_DIR " + + "or qbs property " + project.name + ".googletestDir" ); + return false; + } + + cpp.includePaths: [].concat(googleCommon.getGTestIncludes(project.googletestDir)) + .concat(googleCommon.getGMockIncludes(project.googletestDir)) + + cpp.cxxLanguageVersion: "c++11" + cpp.defines: ["GTEST_LANG_CXX11"] + + files: [ + // own stuff + "queuetest.h", + "main.cpp", + ].concat(googleCommon.getGTestAll(project.googletestDir)) + .concat(googleCommon.getGMockAll(project.googletestDir)) +} diff --git a/src/plugins/autotest/unit_test/simple_gt/tests/gt3/gt3.qbs b/src/plugins/autotest/unit_test/simple_gt/tests/gt3/gt3.qbs new file mode 100644 index 00000000000..2bd250a5880 --- /dev/null +++ b/src/plugins/autotest/unit_test/simple_gt/tests/gt3/gt3.qbs @@ -0,0 +1,36 @@ +import qbs +import qbs.File +import qbs.FileInfo +import "../common/functions.js" as googleCommon + +CppApplication { + type: "application" + name: "googletest3" + + property string gtestDir: googleCommon.getGTestDir(project.googletestDir) + property string gmockDir: googleCommon.getGMockDir(project.googletestDir) + + Depends { name: "Qt.core" } + + condition: { + if (File.exists(gtestDir) && File.exists(gmockDir)) + return true; + + console.error("Cannot find Google Test - specify environment variable GOOGLETEST_DIR " + + "or qbs property " + project.name + ".googletestDir" ); + return false; + } + + cpp.includePaths: [].concat(googleCommon.getGTestIncludes(project.googletestDir)) + .concat(googleCommon.getGMockIncludes(project.googletestDir)) + + cpp.cxxLanguageVersion: "c++11" + cpp.defines: ["GTEST_LANG_CXX11"] + + files: [ + // own stuff + "dummytest.h", + "main.cpp", + ].concat(googleCommon.getGTestAll(project.googletestDir)) + .concat(googleCommon.getGMockAll(project.googletestDir)) +} diff --git a/src/plugins/autotest/unit_test/simple_gt/tests/tests.qbs b/src/plugins/autotest/unit_test/simple_gt/tests/tests.qbs new file mode 100644 index 00000000000..e223da36474 --- /dev/null +++ b/src/plugins/autotest/unit_test/simple_gt/tests/tests.qbs @@ -0,0 +1,14 @@ +import qbs +import qbs.Environment + +Project { + name: "Tests" + + property string googletestDir: Environment.getEnv("GOOGLETEST_DIR") + + references: [ + "gt1/gt1.qbs", + "gt2/gt2.qbs", + "gt3/gt3.qbs" + ] +}