AutoTest: Update Qbs/GTest wizard

Instead of using undefined objects pass the needed objects around
to access them inside the JavaScript file.
Also update deprecated function use.

Change-Id: I4c0cafc319047d0b72a0f9310e5335f793f800ac
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Christian Stenger
2018-03-09 14:10:57 +01:00
parent c25ba91fc1
commit d90da11f07
2 changed files with 15 additions and 15 deletions

View File

@@ -13,9 +13,9 @@
** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
** **
**/ **/
var FileInfo = loadExtension("qbs.FileInfo") var FileInfo = require("qbs.FileInfo")
function getGTestDir(str) { function getGTestDir(qbs, str) {
if (!str) { if (!str) {
if (qbs.hostOS.contains("linux")) if (qbs.hostOS.contains("linux"))
return "/usr/include/gtest"; return "/usr/include/gtest";
@@ -25,7 +25,7 @@ function getGTestDir(str) {
return ""; return "";
} }
function getGMockDir(str) { function getGMockDir(qbs, str) {
if (!str) { if (!str) {
if (qbs.hostOS.contains("linux")) if (qbs.hostOS.contains("linux"))
return "/usr/include/gmock"; return "/usr/include/gmock";
@@ -35,29 +35,29 @@ function getGMockDir(str) {
return ""; return "";
} }
function getGTestAll(str) { function getGTestAll(qbs, str) {
var gtest = getGTestDir(str); var gtest = getGTestDir(qbs, str);
if (!gtest) if (!gtest)
return []; return [];
return [FileInfo.joinPaths(gtest, "src/gtest-all.cc")]; return [FileInfo.joinPaths(gtest, "src/gtest-all.cc")];
} }
function getGMockAll(str) { function getGMockAll(qbs, str) {
var gmock = getGMockDir(str); var gmock = getGMockDir(qbs, str);
if (!gmock) if (!gmock)
return []; return [];
return [FileInfo.joinPaths(gmock, "src/gmock-all.cc")]; return [FileInfo.joinPaths(gmock, "src/gmock-all.cc")];
} }
function getGTestIncludes(str) { function getGTestIncludes(qbs, str) {
var gtest = getGTestDir(str); var gtest = getGTestDir(qbs, str);
if (!gtest) if (!gtest)
return []; return [];
return [gtest, FileInfo.joinPaths(gtest, "include")]; return [gtest, FileInfo.joinPaths(gtest, "include")];
} }
function getGMockIncludes(str) { function getGMockIncludes(qbs, str) {
var mock = getGMockDir(str); var mock = getGMockDir(qbs, str);
if (!mock) if (!mock)
return []; return [];
return [mock, FileInfo.joinPaths(mock, "include")]; return [mock, FileInfo.joinPaths(mock, "include")];

View File

@@ -43,14 +43,14 @@ CppApplication {
} }
cpp.includePaths: [].concat(googleCommon.getGTestIncludes(googletestDir)) cpp.includePaths: [].concat(googleCommon.getGTestIncludes(qbs, googletestDir))
.concat(googleCommon.getGMockIncludes(googletestDir)) .concat(googleCommon.getGMockIncludes(qbs, googletestDir))
files: [ files: [
"%{MainCppName}", "%{MainCppName}",
"%{TestCaseFileWithHeaderSuffix}", "%{TestCaseFileWithHeaderSuffix}",
].concat(googleCommon.getGTestAll(googletestDir)) ].concat(googleCommon.getGTestAll(qbs, googletestDir))
.concat(googleCommon.getGMockAll(googletestDir)) .concat(googleCommon.getGMockAll(qbs, googletestDir))
@endif @endif
@if "%{TestFrameWork}" == "QtQuickTest" @if "%{TestFrameWork}" == "QtQuickTest"
Depends { name: "cpp" } Depends { name: "cpp" }