forked from qt-creator/qt-creator
		
	AutoTest: Provide additional test project...
...to also test combination of Qbs using Google Test. Change-Id: I4a5d32a32bfaadd0dfaaa4884b58d2ac1a952bd3 Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
This commit is contained in:
		@@ -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<QString>("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
 | 
			
		||||
 
 | 
			
		||||
@@ -52,6 +52,7 @@ private slots:
 | 
			
		||||
    void testCodeParserSwitchStartup();
 | 
			
		||||
    void testCodeParserSwitchStartup_data();
 | 
			
		||||
    void testCodeParserGTest();
 | 
			
		||||
    void testCodeParserGTest_data();
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    TestTreeModel *m_model;
 | 
			
		||||
 
 | 
			
		||||
@@ -41,17 +41,24 @@
 | 
			
		||||
        <file>unit_test/mixed_atp/tests/auto/quickauto2/quickauto2.qbs</file>
 | 
			
		||||
        <file>unit_test/simple_gt/src/main.cpp</file>
 | 
			
		||||
        <file>unit_test/simple_gt/src/src.pro</file>
 | 
			
		||||
        <file>unit_test/simple_gt/src/src.qbs</file>
 | 
			
		||||
        <file>unit_test/simple_gt/tests/gt1/further.cpp</file>
 | 
			
		||||
        <file>unit_test/simple_gt/tests/gt1/gt1.pro</file>
 | 
			
		||||
        <file>unit_test/simple_gt/tests/gt1/gt1.qbs</file>
 | 
			
		||||
        <file>unit_test/simple_gt/tests/gt1/main.cpp</file>
 | 
			
		||||
        <file>unit_test/simple_gt/tests/gt2/gt2.pro</file>
 | 
			
		||||
        <file>unit_test/simple_gt/tests/gt2/gt2.qbs</file>
 | 
			
		||||
        <file>unit_test/simple_gt/tests/gt2/main.cpp</file>
 | 
			
		||||
        <file>unit_test/simple_gt/tests/gt2/queuetest.h</file>
 | 
			
		||||
        <file>unit_test/simple_gt/tests/tests.pro</file>
 | 
			
		||||
        <file>unit_test/simple_gt/tests/tests.qbs</file>
 | 
			
		||||
        <file>unit_test/simple_gt/simple_gt.pro</file>
 | 
			
		||||
        <file>unit_test/simple_gt/simple_gt.qbs</file>
 | 
			
		||||
        <file>unit_test/simple_gt/tests/gtest_dependency.pri</file>
 | 
			
		||||
        <file>unit_test/simple_gt/tests/gt3/dummytest.h</file>
 | 
			
		||||
        <file>unit_test/simple_gt/tests/gt3/gt3.pro</file>
 | 
			
		||||
        <file>unit_test/simple_gt/tests/gt3/gt3.qbs</file>
 | 
			
		||||
        <file>unit_test/simple_gt/tests/gt3/main.cpp</file>
 | 
			
		||||
        <file>unit_test/simple_gt/tests/common/functions.js</file>
 | 
			
		||||
    </qresource>
 | 
			
		||||
</RCC>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										10
									
								
								src/plugins/autotest/unit_test/simple_gt/simple_gt.qbs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								src/plugins/autotest/unit_test/simple_gt/simple_gt.qbs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
import qbs
 | 
			
		||||
 | 
			
		||||
Project {
 | 
			
		||||
    name: "Simple GT"
 | 
			
		||||
 | 
			
		||||
    references: [
 | 
			
		||||
        "src/src.qbs",
 | 
			
		||||
        "tests/tests.qbs"
 | 
			
		||||
    ]
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										10
									
								
								src/plugins/autotest/unit_test/simple_gt/src/src.qbs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								src/plugins/autotest/unit_test/simple_gt/src/src.qbs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
import qbs
 | 
			
		||||
 | 
			
		||||
CppApplication {
 | 
			
		||||
    type: "application"
 | 
			
		||||
    name: "Dummy application"
 | 
			
		||||
 | 
			
		||||
    Depends { name: "Qt.core" }
 | 
			
		||||
 | 
			
		||||
    files: [ "main.cpp" ]
 | 
			
		||||
}
 | 
			
		||||
@@ -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")];
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										35
									
								
								src/plugins/autotest/unit_test/simple_gt/tests/gt1/gt1.qbs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								src/plugins/autotest/unit_test/simple_gt/tests/gt1/gt1.qbs
									
									
									
									
									
										Normal file
									
								
							@@ -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))
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										36
									
								
								src/plugins/autotest/unit_test/simple_gt/tests/gt2/gt2.qbs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								src/plugins/autotest/unit_test/simple_gt/tests/gt2/gt2.qbs
									
									
									
									
									
										Normal file
									
								
							@@ -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))
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										36
									
								
								src/plugins/autotest/unit_test/simple_gt/tests/gt3/gt3.qbs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								src/plugins/autotest/unit_test/simple_gt/tests/gt3/gt3.qbs
									
									
									
									
									
										Normal file
									
								
							@@ -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))
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										14
									
								
								src/plugins/autotest/unit_test/simple_gt/tests/tests.qbs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								src/plugins/autotest/unit_test/simple_gt/tests/tests.qbs
									
									
									
									
									
										Normal file
									
								
							@@ -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"
 | 
			
		||||
    ]
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user