aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/blackbox/tst_blackbox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/blackbox/tst_blackbox.cpp')
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp308
1 files changed, 200 insertions, 108 deletions
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index cc68a57d4..c48eb0611 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -47,6 +47,12 @@ using qbs::Internal::HostOsInfo;
using qbs::Internal::removeDirectoryWithContents;
using qbs::Profile;
+static bool regularFileExists(const QString &filePath)
+{
+ const QFileInfo fi(filePath);
+ return fi.exists() && fi.isFile();
+}
+
static QString initQbsExecutableFilePath()
{
QString filePath = QCoreApplication::applicationDirPath() + QLatin1String("/qbs");
@@ -173,7 +179,7 @@ QByteArray TestBlackbox::unifiedLineEndings(const QByteArray &ba)
void TestBlackbox::initTestCase()
{
- QVERIFY(QFile::exists(qbsExecutableFilePath));
+ QVERIFY(regularFileExists(qbsExecutableFilePath));
SettingsPtr settings = qbsSettings(QString());
if (!settings->profiles().contains(buildProfileName))
@@ -259,49 +265,71 @@ void TestBlackbox::baseProperties()
QCOMPARE(runQbs(), 0);
}
+void TestBlackbox::buildDirectories()
+{
+ const QString projectDir
+ = QDir::cleanPath(testDataDir + QLatin1String("/build-directories"));
+ const QString projectBuildDir = projectDir + '/' + buildDir;
+ QDir::setCurrent(projectDir);
+ QCOMPARE(runQbs(QStringList("-qq")), 0);
+ const QStringList outputLines
+ = QString::fromLocal8Bit(m_qbsStderr.trimmed()).split('\n', QString::SkipEmptyParts);
+ QCOMPARE(outputLines.count(), 4);
+ QCOMPARE(outputLines.at(0).trimmed(), projectBuildDir + "/p1");
+ QCOMPARE(outputLines.at(1).trimmed(), projectBuildDir + "/p2");
+ QCOMPARE(outputLines.at(2).trimmed(), projectBuildDir);
+ QCOMPARE(outputLines.at(3).trimmed(), projectDir);
+}
+
void TestBlackbox::build_project_data()
{
QTest::addColumn<QString>("projectSubDir");
QTest::addColumn<QString>("productFileName");
QTest::newRow("BPs in Sources")
<< QString("buildproperties_source")
- << QString(HostOsInfo::appendExecutableSuffix(buildDir + "/HelloWorld"));
+ << QString(HostOsInfo::appendExecutableSuffix(buildDir + "/HelloWorld/HelloWorld"));
QTest::newRow("code generator")
<< QString("codegen")
- << QString(HostOsInfo::appendExecutableSuffix(buildDir + "/codegen"));
+ << QString(HostOsInfo::appendExecutableSuffix(buildDir + "/codegen/codegen"));
QTest::newRow("link static libs")
<< QString("link_staticlib")
<< QString(buildDir + QLatin1String("/")
- + HostOsInfo::appendExecutableSuffix("HelloWorld"));
+ + HostOsInfo::appendExecutableSuffix("HelloWorld/HelloWorld"));
QTest::newRow("precompiled header")
<< QString("precompiledHeader")
<< QString(buildDir + QLatin1String("/")
- + HostOsInfo::appendExecutableSuffix("MyApp"));
+ + HostOsInfo::appendExecutableSuffix("MyApp/MyApp"));
QTest::newRow("lots of dots")
<< QString("lotsofdots")
<< QString(buildDir + QLatin1String("/")
- + HostOsInfo::appendExecutableSuffix("lots.of.dots"));
+ + HostOsInfo::appendExecutableSuffix("lots.of.dots/lots.of.dots"));
QTest::newRow("Qt5 plugin")
<< QString("qt5plugin")
- << QString(buildDir + QLatin1String("/") + HostOsInfo::dynamicLibraryName("echoplugin"));
+ << QString(buildDir + QLatin1String("/echoplugin/")
+ + HostOsInfo::dynamicLibraryName("echoplugin"));
QTest::newRow("Q_OBJECT in source")
<< QString("moc_cpp")
- << QString(HostOsInfo::appendExecutableSuffix(buildDir + "/moc_cpp"));
+ << QString(HostOsInfo::appendExecutableSuffix(buildDir + "/moc_cpp/moc_cpp"));
QTest::newRow("Q_OBJECT in header")
<< QString("moc_hpp")
- << QString(HostOsInfo::appendExecutableSuffix(buildDir + "/moc_hpp"));
+ << QString(HostOsInfo::appendExecutableSuffix(buildDir + "/moc_hpp/moc_hpp"));
QTest::newRow("Q_OBJECT in header, moc_XXX.cpp included")
<< QString("moc_hpp_included")
- << QString(HostOsInfo::appendExecutableSuffix(buildDir + "/moc_hpp_included"));
+ << QString(HostOsInfo::appendExecutableSuffix(buildDir
+ + "/moc_hpp_included/moc_hpp_included"));
QTest::newRow("app and lib with same source file")
<< QString("lib_samesource")
- << QString(HostOsInfo::appendExecutableSuffix(buildDir + "/HelloWorldApp"));
+ << QString(HostOsInfo::appendExecutableSuffix(buildDir
+ + "/HelloWorldApp/HelloWorldApp"));
QTest::newRow("source files with the same base name but different extensions")
<< QString("sameBaseName")
- << QString(HostOsInfo::appendExecutableSuffix(buildDir + "/basename"));
+ << QString(HostOsInfo::appendExecutableSuffix(buildDir + "/basename/basename"));
QTest::newRow("static library dependencies")
<< QString("staticLibDeps")
- << QString(HostOsInfo::appendExecutableSuffix(buildDir + "/staticLibDeps"));
+ << QString(HostOsInfo::appendExecutableSuffix(buildDir + "/staticLibDeps/staticLibDeps"));
+ QTest::newRow("simple probes")
+ << QString("simpleProbe")
+ << QString(HostOsInfo::appendExecutableSuffix(buildDir + "/MyApp/MyApp"));
}
void TestBlackbox::build_project()
@@ -315,13 +343,13 @@ void TestBlackbox::build_project()
rmDirR(buildDir);
QCOMPARE(runQbs(), 0);
- QVERIFY2(QFile::exists(productFileName), qPrintable(productFileName));
- QVERIFY(QFile::exists(buildGraphPath));
+ QVERIFY2(regularFileExists(productFileName), qPrintable(productFileName));
+ QVERIFY(regularFileExists(buildGraphPath));
QVERIFY2(QFile::remove(productFileName), qPrintable(productFileName));
waitForNewTimestamp();
QCOMPARE(runQbs(QbsRunParameters(QStringList("--check-timestamps"))), 0);
- QVERIFY2(QFile::exists(productFileName), qPrintable(productFileName));
- QVERIFY(QFile::exists(buildGraphPath));
+ QVERIFY2(regularFileExists(productFileName), qPrintable(productFileName));
+ QVERIFY(regularFileExists(buildGraphPath));
}
void TestBlackbox::build_project_dry_run_data()
@@ -387,7 +415,7 @@ void TestBlackbox::dependenciesProperty()
{
QDir::setCurrent(testDataDir + QLatin1String("/dependenciesProperty"));
QCOMPARE(runQbs(), 0);
- QFile depsFile(buildDir + QLatin1String("/product1.deps"));
+ QFile depsFile(buildDir + QLatin1String("/product1/product1.deps"));
QVERIFY(depsFile.open(QFile::ReadOnly));
QString deps = QString::fromLatin1(depsFile.readAll());
QVERIFY(!deps.isEmpty());
@@ -445,7 +473,7 @@ void TestBlackbox::resolve_project()
QCOMPARE(runQbs(QbsRunParameters("resolve")), 0);
QVERIFY2(!QFile::exists(productFileName), qPrintable(productFileName));
- QVERIFY(QFile::exists(buildGraphPath));
+ QVERIFY(regularFileExists(buildGraphPath));
}
void TestBlackbox::resolve_project_dry_run_data()
@@ -475,10 +503,10 @@ static bool symlinkExists(const QString &linkFilePath)
void TestBlackbox::clean()
{
- const QString appObjectFilePath = buildDir + "/.obj/app/main.cpp" + QTC_HOST_OBJECT_SUFFIX;
- const QString appExeFilePath = buildDir + "/app" + QTC_HOST_EXE_SUFFIX;
- const QString depObjectFilePath = buildDir + "/.obj/dep/dep.cpp" + QTC_HOST_OBJECT_SUFFIX;
- const QString depLibBase = buildDir + '/' + QTC_HOST_DYNAMICLIB_PREFIX + "dep";
+ const QString appObjectFilePath = buildDir + "/app/.obj/main.cpp" + QTC_HOST_OBJECT_SUFFIX;
+ const QString appExeFilePath = buildDir + "/app/app" + QTC_HOST_EXE_SUFFIX;
+ const QString depObjectFilePath = buildDir + "/dep/.obj/dep.cpp" + QTC_HOST_OBJECT_SUFFIX;
+ const QString depLibBase = buildDir + "/dep/" + QTC_HOST_DYNAMICLIB_PREFIX + "dep";
QString depLibFilePath;
QStringList symlinks;
if (qbs::Internal::HostOsInfo::isOsxHost()) {
@@ -499,24 +527,24 @@ void TestBlackbox::clean()
// Default behavior: Remove only temporaries.
QCOMPARE(runQbs(), 0);
- QVERIFY(QFile(appObjectFilePath).exists());
- QVERIFY(QFile(appExeFilePath).exists());
- QVERIFY(QFile(depObjectFilePath).exists());
- QVERIFY(QFile(depLibFilePath).exists());
+ QVERIFY(regularFileExists(appObjectFilePath));
+ QVERIFY(regularFileExists(appExeFilePath));
+ QVERIFY(regularFileExists(depObjectFilePath));
+ QVERIFY(regularFileExists(depLibFilePath));
foreach (const QString &symLink, symlinks)
- QVERIFY2(QFile(symLink).exists(), qPrintable(symLink));
+ QVERIFY2(regularFileExists(symLink), qPrintable(symLink));
QCOMPARE(runQbs(QbsRunParameters("clean")), 0);
QVERIFY(!QFile(appObjectFilePath).exists());
- QVERIFY(QFile(appExeFilePath).exists());
+ QVERIFY(regularFileExists(appExeFilePath));
QVERIFY(!QFile(depObjectFilePath).exists());
- QVERIFY(QFile(depLibFilePath).exists());
+ QVERIFY(regularFileExists(depLibFilePath));
foreach (const QString &symLink, symlinks)
QVERIFY2(symlinkExists(symLink), qPrintable(symLink));
// Remove all.
QCOMPARE(runQbs(), 0);
- QVERIFY(QFile(appObjectFilePath).exists());
- QVERIFY(QFile(appExeFilePath).exists());
+ QVERIFY(regularFileExists(appObjectFilePath));
+ QVERIFY(regularFileExists(appExeFilePath));
QCOMPARE(runQbs(QbsRunParameters(QLatin1String("clean"), QStringList("--all-artifacts"))), 0);
QVERIFY(!QFile(appObjectFilePath).exists());
QVERIFY(!QFile(appExeFilePath).exists());
@@ -527,28 +555,28 @@ void TestBlackbox::clean()
// Dry run.
QCOMPARE(runQbs(), 0);
- QVERIFY(QFile(appObjectFilePath).exists());
- QVERIFY(QFile(appExeFilePath).exists());
+ QVERIFY(regularFileExists(appObjectFilePath));
+ QVERIFY(regularFileExists(appExeFilePath));
QCOMPARE(runQbs(QbsRunParameters(QLatin1String("clean"),
QStringList("--all-artifacts") << "-n")), 0);
- QVERIFY(QFile(appObjectFilePath).exists());
- QVERIFY(QFile(appExeFilePath).exists());
- QVERIFY(QFile(depObjectFilePath).exists());
- QVERIFY(QFile(depLibFilePath).exists());
+ QVERIFY(regularFileExists(appObjectFilePath));
+ QVERIFY(regularFileExists(appExeFilePath));
+ QVERIFY(regularFileExists(depObjectFilePath));
+ QVERIFY(regularFileExists(depLibFilePath));
foreach (const QString &symLink, symlinks)
QVERIFY2(symlinkExists(symLink), qPrintable(symLink));
// Product-wise, dependency only.
QCOMPARE(runQbs(), 0);
- QVERIFY(QFile(appObjectFilePath).exists());
- QVERIFY(QFile(appExeFilePath).exists());
- QVERIFY(QFile(depObjectFilePath).exists());
- QVERIFY(QFile(depLibFilePath).exists());
+ QVERIFY(regularFileExists(appObjectFilePath));
+ QVERIFY(regularFileExists(appExeFilePath));
+ QVERIFY(regularFileExists(depObjectFilePath));
+ QVERIFY(regularFileExists(depLibFilePath));
QCOMPARE(runQbs(QbsRunParameters(QLatin1String("clean"),
QStringList("--all-artifacts") << "-p" << "dep")),
0);
- QVERIFY(QFile(appObjectFilePath).exists());
- QVERIFY(QFile(appExeFilePath).exists());
+ QVERIFY(regularFileExists(appObjectFilePath));
+ QVERIFY(regularFileExists(appExeFilePath));
QVERIFY(!QFile(depObjectFilePath).exists());
QVERIFY(!QFile(depLibFilePath).exists());
foreach (const QString &symLink, symlinks)
@@ -556,17 +584,17 @@ void TestBlackbox::clean()
// Product-wise, dependent product only.
QCOMPARE(runQbs(), 0);
- QVERIFY(QFile(appObjectFilePath).exists());
- QVERIFY(QFile(appExeFilePath).exists());
- QVERIFY(QFile(depObjectFilePath).exists());
- QVERIFY(QFile(depLibFilePath).exists());
+ QVERIFY(regularFileExists(appObjectFilePath));
+ QVERIFY(regularFileExists(appExeFilePath));
+ QVERIFY(regularFileExists(depObjectFilePath));
+ QVERIFY(regularFileExists(depLibFilePath));
QCOMPARE(runQbs(QbsRunParameters(QLatin1String("clean"),
QStringList("--all-artifacts") << "-p" << "app")),
0);
QVERIFY(!QFile(appObjectFilePath).exists());
QVERIFY(!QFile(appExeFilePath).exists());
- QVERIFY(QFile(depObjectFilePath).exists());
- QVERIFY(QFile(depLibFilePath).exists());
+ QVERIFY(regularFileExists(depObjectFilePath));
+ QVERIFY(regularFileExists(depLibFilePath));
foreach (const QString &symLink, symlinks)
QVERIFY2(symlinkExists(symLink), qPrintable(symLink));
}
@@ -708,8 +736,8 @@ void TestBlackbox::track_qrc()
{
QDir::setCurrent(testDataDir + "/qrc");
QCOMPARE(runQbs(), 0);
- const QString fileName = HostOsInfo::appendExecutableSuffix(buildDir + "/i");
- QVERIFY2(QFile(fileName).exists(), qPrintable(fileName));
+ const QString fileName = buildDir + "/i/" + HostOsInfo::appendExecutableSuffix("i");
+ QVERIFY2(regularFileExists(fileName), qPrintable(fileName));
QDateTime dt = QFileInfo(fileName).lastModified();
QTest::qSleep(2020);
{
@@ -720,7 +748,7 @@ void TestBlackbox::track_qrc()
f.close();
}
QCOMPARE(runQbs(), 0);
- QVERIFY(QFile(fileName).exists());
+ QVERIFY(regularFileExists(fileName));
QVERIFY(dt < QFileInfo(fileName).lastModified());
}
@@ -731,18 +759,18 @@ void TestBlackbox::track_qobject_change()
QVERIFY(QFile("bla_qobject.h").copy("bla.h"));
touch("bla.h");
QCOMPARE(runQbs(), 0);
- const QString productFilePath = HostOsInfo::appendExecutableSuffix(buildDir + "/i");
- QVERIFY2(QFile(productFilePath).exists(), qPrintable(productFilePath));
+ const QString productFilePath = buildDir + "/i/" + HostOsInfo::appendExecutableSuffix("i");
+ QVERIFY2(regularFileExists(productFilePath), qPrintable(productFilePath));
QString moc_bla_objectFileName
- = buildDir + "/.obj/i/GeneratedFiles/i/moc_bla.cpp" QTC_HOST_OBJECT_SUFFIX;
- QVERIFY(QFile(moc_bla_objectFileName).exists());
+ = buildDir + "/i/.obj/i/GeneratedFiles/moc_bla.cpp" QTC_HOST_OBJECT_SUFFIX;
+ QVERIFY2(regularFileExists(moc_bla_objectFileName), qPrintable(moc_bla_objectFileName));
QTest::qSleep(1000);
QFile("bla.h").remove();
QVERIFY(QFile("bla_noqobject.h").copy("bla.h"));
touch("bla.h");
QCOMPARE(runQbs(), 0);
- QVERIFY(QFile(productFilePath).exists());
+ QVERIFY(regularFileExists(productFilePath));
QVERIFY(!QFile(moc_bla_objectFileName).exists());
}
@@ -758,7 +786,7 @@ void TestBlackbox::trackAddFile()
QDir::setCurrent(testDataDir + "/trackAddFile/work");
QCOMPARE(runQbs(), 0);
- process.start(buildDir + "/someapp");
+ process.start(buildDir + "/someapp/someapp");
QVERIFY2(process.waitForStarted(), qPrintable(process.errorString()));
QVERIFY2(process.waitForFinished(), qPrintable(process.errorString()));
QCOMPARE(process.exitCode(), 0);
@@ -774,7 +802,7 @@ void TestBlackbox::trackAddFile()
touch("main.cpp");
QCOMPARE(runQbs(), 0);
- process.start(buildDir + "/someapp");
+ process.start(buildDir + "/someapp/someapp");
QVERIFY(process.waitForStarted());
QVERIFY(process.waitForFinished());
QCOMPARE(process.exitCode(), 0);
@@ -863,7 +891,7 @@ void TestBlackbox::trackRemoveFile()
QDir::setCurrent(testDataDir + "/trackAddFile/work");
QCOMPARE(runQbs(), 0);
- process.start(buildDir + "/someapp");
+ process.start(buildDir + "/someapp/someapp");
QVERIFY2(process.waitForStarted(), qPrintable(process.errorString()));
QVERIFY2(process.waitForFinished(), qPrintable(process.errorString()));
QCOMPARE(process.exitCode(), 0);
@@ -887,7 +915,7 @@ void TestBlackbox::trackRemoveFile()
touch("project.qbs");
QCOMPARE(runQbs(), 0);
- process.start(buildDir + "/someapp");
+ process.start(buildDir + "/someapp/someapp");
QVERIFY(process.waitForStarted());
QVERIFY(process.waitForFinished());
QCOMPARE(process.exitCode(), 0);
@@ -900,7 +928,7 @@ void TestBlackbox::trackRemoveFile()
QCOMPARE(unchangedObjectFileTime1, unchangedObjectFileTime2);
// the object file for the removed cpp file should have vanished too
- QCOMPARE(QFile::exists(buildDir + "/someapp/zort.cpp" QTC_HOST_OBJECT_SUFFIX), false);
+ QCOMPARE(regularFileExists(buildDir + "/someapp/zort.cpp" QTC_HOST_OBJECT_SUFFIX), false);
}
void TestBlackbox::trackAddFileTag()
@@ -915,7 +943,7 @@ void TestBlackbox::trackAddFileTag()
QDir::setCurrent(testDataDir + "/trackFileTags/work");
QCOMPARE(runQbs(), 0);
- process.start(buildDir + "/someapp");
+ process.start(buildDir + "/someapp/someapp");
QVERIFY2(process.waitForStarted(), qPrintable(process.errorString()));
QVERIFY2(process.waitForFinished(), qPrintable(process.errorString()));
QCOMPARE(process.exitCode(), 0);
@@ -928,7 +956,7 @@ void TestBlackbox::trackAddFileTag()
touch("project.qbs");
QCOMPARE(runQbs(), 0);
- process.start(buildDir + "/someapp");
+ process.start(buildDir + "/someapp/someapp");
QVERIFY(process.waitForStarted());
QVERIFY(process.waitForFinished());
QCOMPARE(process.exitCode(), 0);
@@ -949,12 +977,11 @@ void TestBlackbox::trackRemoveFileTag()
QCOMPARE(runQbs(), 0);
// check if the artifacts are here that will become stale in the 2nd step
- QVERIFY2(QFile::exists(buildDir + "/.obj/someapp/main_foo.cpp" QTC_HOST_OBJECT_SUFFIX),
- qPrintable(buildDir + "/.obj/someapp/main_foo.cpp" QTC_HOST_OBJECT_SUFFIX));
- QVERIFY2(QFile::exists(buildDir + "/main_foo.cpp"), qPrintable(buildDir + "/main_foo.cpp"));
- QVERIFY2(QFile::exists(buildDir + "/main.foo"), qPrintable(buildDir + "/main.foo"));
+ QVERIFY(regularFileExists(buildDir + "/someapp/.obj/someapp/main_foo.cpp" QTC_HOST_OBJECT_SUFFIX));
+ QVERIFY(regularFileExists(buildDir + "/someapp/main_foo.cpp"));
+ QVERIFY(regularFileExists(buildDir + "/someapp/main.foo"));
- process.start(buildDir + "/someapp");
+ process.start(buildDir + "/someapp/someapp");
QVERIFY(process.waitForStarted());
QVERIFY(process.waitForFinished());
QCOMPARE(process.exitCode(), 0);
@@ -967,7 +994,7 @@ void TestBlackbox::trackRemoveFileTag()
touch("project.qbs");
QCOMPARE(runQbs(), 0);
- process.start(buildDir + "/someapp");
+ process.start(buildDir + "/someapp/someapp");
QVERIFY(process.waitForStarted());
QVERIFY(process.waitForFinished());
QCOMPARE(process.exitCode(), 0);
@@ -975,9 +1002,9 @@ void TestBlackbox::trackRemoveFileTag()
QCOMPARE(output.takeFirst().trimmed().constData(), "there's no foo here");
// check if stale artifacts have been removed
- QCOMPARE(QFile::exists(buildDir + "/someapp/main_foo.cpp" QTC_HOST_OBJECT_SUFFIX), false);
- QCOMPARE(QFile::exists(buildDir + "/someapp/main_foo.cpp"), false);
- QCOMPARE(QFile::exists(buildDir + "/someapp/main.foo"), false);
+ QCOMPARE(regularFileExists(buildDir + "/someapp/.obj/main_foo.cpp" QTC_HOST_OBJECT_SUFFIX), false);
+ QCOMPARE(regularFileExists(buildDir + "/someapp/main_foo.cpp"), false);
+ QCOMPARE(regularFileExists(buildDir + "/someapp/main.foo"), false);
}
void TestBlackbox::trackAddMocInclude()
@@ -1108,10 +1135,12 @@ void TestBlackbox::ruleConditions()
{
QDir::setCurrent(testDataDir + "/ruleConditions");
QCOMPARE(runQbs(), 0);
- QVERIFY(QFileInfo(buildDir + HostOsInfo::appendExecutableSuffix("/zorted")).exists());
- QVERIFY(QFileInfo(buildDir + HostOsInfo::appendExecutableSuffix("/unzorted")).exists());
- QVERIFY(QFileInfo(buildDir + "/zorted.foo.narf.zort").exists());
- QVERIFY(!QFileInfo(buildDir + "/unzorted.foo.narf.zort").exists());
+ QVERIFY(QFileInfo(buildDir + "/zorted/"
+ + HostOsInfo::appendExecutableSuffix("zorted")).exists());
+ QVERIFY(QFileInfo(buildDir + "/unzorted/"
+ + HostOsInfo::appendExecutableSuffix("unzorted")).exists());
+ QVERIFY(QFileInfo(buildDir + "/zorted/zorted.foo.narf.zort").exists());
+ QVERIFY(!QFileInfo(buildDir + "/unzorted/unzorted.foo.narf.zort").exists());
}
void TestBlackbox::ruleCycle()
@@ -1175,7 +1204,8 @@ void TestBlackbox::overrideProjectProperties()
<< QLatin1String("project.someInt:156")
<< QLatin1String("project.someStringList:one")
<< QLatin1String("MyAppForYou.mainFile:main.cpp"))), 0);
- QVERIFY(QFile::exists(buildDir + HostOsInfo::appendExecutableSuffix("/MyAppForYou")));
+ QVERIFY(regularFileExists(buildDir + "/MyAppForYou/"
+ + HostOsInfo::appendExecutableSuffix("MyAppForYou")));
QVERIFY(QFile::remove(buildGraphPath));
QbsRunParameters params;
@@ -1196,7 +1226,8 @@ void TestBlackbox::productProperties()
QDir::setCurrent(testDataDir + "/productproperties");
QCOMPARE(runQbs(QbsRunParameters(QStringList() << QLatin1String("-f")
<< QLatin1String("project.qbs"))), 0);
- QVERIFY(QFile::exists(buildDir + HostOsInfo::appendExecutableSuffix("/blubb_user")));
+ QVERIFY(regularFileExists(buildDir + "/blubb_user/"
+ + HostOsInfo::appendExecutableSuffix("blubb_user")));
}
void TestBlackbox::propertyChanges()
@@ -1214,7 +1245,7 @@ void TestBlackbox::propertyChanges()
QVERIFY(m_qbsStdout.contains("linking product 1.debug"));
QVERIFY(m_qbsStdout.contains("generated.txt"));
QVERIFY(m_qbsStdout.contains("Making output from input"));
- QFile generatedFile(buildDir + QLatin1String("/generated.txt"));
+ QFile generatedFile(buildDir + QLatin1String("/generated text file/generated.txt"));
QVERIFY(generatedFile.open(QIODevice::ReadOnly));
QCOMPARE(generatedFile.readAll(), QByteArray("prefix 1contents 1suffix 1"));
generatedFile.close();
@@ -1480,15 +1511,15 @@ void TestBlackbox::dynamicRuleOutputs()
QDir::setCurrent(testDir + "/work");
QCOMPARE(runQbs(), 0);
- const QString appFile = buildDir + "/genlexer" + QTC_HOST_EXE_SUFFIX;
- const QString headerFile1 = buildDir + "/GeneratedFiles/genlexer/numberscanner.h";
- const QString sourceFile1 = buildDir + "/GeneratedFiles/genlexer/numberscanner.c";
- const QString sourceFile2 = buildDir + "/GeneratedFiles/genlexer/lex.yy.c";
+ const QString appFile = buildDir + "/genlexer/genlexer" + QTC_HOST_EXE_SUFFIX;
+ const QString headerFile1 = buildDir + "/genlexer/GeneratedFiles/numberscanner.h";
+ const QString sourceFile1 = buildDir + "/genlexer/GeneratedFiles/numberscanner.c";
+ const QString sourceFile2 = buildDir + "/genlexer/GeneratedFiles/lex.yy.c";
// Check build #1: source and header file name are specified in numbers.l
- QVERIFY(QFile::exists(appFile));
- QVERIFY(QFile::exists(headerFile1));
- QVERIFY(QFile::exists(sourceFile1));
+ QVERIFY(regularFileExists(appFile));
+ QVERIFY(regularFileExists(headerFile1));
+ QVERIFY(regularFileExists(sourceFile1));
QVERIFY(!QFile::exists(sourceFile2));
QDateTime appFileTimeStamp1 = QFileInfo(appFile).lastModified();
@@ -1504,7 +1535,7 @@ void TestBlackbox::dynamicRuleOutputs()
QVERIFY(appFileTimeStamp1 < appFileTimeStamp2);
QVERIFY(!QFile::exists(headerFile1));
QVERIFY(!QFile::exists(sourceFile1));
- QVERIFY(QFile::exists(sourceFile2));
+ QVERIFY(regularFileExists(sourceFile2));
waitForNewTimestamp();
QFile::remove("numbers.l");
@@ -1515,9 +1546,9 @@ void TestBlackbox::dynamicRuleOutputs()
// Check build #3: source and header file name are specified in numbers.l
QDateTime appFileTimeStamp3 = QFileInfo(appFile).lastModified();
QVERIFY(appFileTimeStamp2 < appFileTimeStamp3);
- QVERIFY(QFile::exists(appFile));
- QVERIFY(QFile::exists(headerFile1));
- QVERIFY(QFile::exists(sourceFile1));
+ QVERIFY(regularFileExists(appFile));
+ QVERIFY(regularFileExists(headerFile1));
+ QVERIFY(regularFileExists(sourceFile1));
QVERIFY(!QFile::exists(sourceFile2));
}
@@ -1541,8 +1572,9 @@ void TestBlackbox::fileDependencies()
QCOMPARE(runQbs(), 0);
QVERIFY(m_qbsStdout.contains("compiling narf.cpp"));
QVERIFY(m_qbsStdout.contains("compiling zort.cpp"));
- const QString productFileName = HostOsInfo::appendExecutableSuffix(buildDir + "/myapp");
- QVERIFY2(QFile::exists(productFileName), qPrintable(productFileName));
+ const QString productFileName = buildDir + "/myapp/"
+ + HostOsInfo::appendExecutableSuffix("myapp");
+ QVERIFY2(regularFileExists(productFileName), qPrintable(productFileName));
// Incremental build without changes.
QCOMPARE(runQbs(), 0);
@@ -1720,7 +1752,8 @@ void TestBlackbox::qmlDebugging()
QDir::setCurrent(testDataDir + "/qml-debugging");
QCOMPARE(runQbs(), 0);
QProcess nm;
- nm.start("nm", QStringList(HostOsInfo::appendExecutableSuffix(buildDir + "/debuggable-app")));
+ nm.start("nm", QStringList(HostOsInfo::appendExecutableSuffix(buildDir
+ + "/debuggable-app/debuggable-app")));
if (nm.waitForStarted()) { // Let's ignore hosts without nm.
QVERIFY2(nm.waitForFinished(), qPrintable(nm.errorString()));
QVERIFY2(nm.exitCode() == 0, nm.readAllStandardError().constData());
@@ -1758,12 +1791,12 @@ void TestBlackbox::installedApp()
QDir::setCurrent(testDataDir + "/installed_artifact");
QCOMPARE(runQbs(QbsRunParameters("install")), 0);
- QVERIFY(QFile::exists(defaultInstallRoot
+ QVERIFY(regularFileExists(defaultInstallRoot
+ HostOsInfo::appendExecutableSuffix(QLatin1String("/usr/bin/installedApp"))));
QCOMPARE(runQbs(QbsRunParameters(QLatin1String("install"), QStringList("--install-root")
<< (testDataDir + "/installed-app"))), 0);
- QVERIFY(QFile::exists(testDataDir
+ QVERIFY(regularFileExists(testDataDir
+ HostOsInfo::appendExecutableSuffix("/installed-app/usr/bin/installedApp")));
QFile addedFile(defaultInstallRoot + QLatin1String("/blubb.txt"));
@@ -1771,9 +1804,9 @@ void TestBlackbox::installedApp()
addedFile.close();
QVERIFY(addedFile.exists());
QCOMPARE(runQbs(QbsRunParameters(QLatin1String("install"), QStringList("--remove-first"))), 0);
- QVERIFY(QFile::exists(defaultInstallRoot
+ QVERIFY(regularFileExists(defaultInstallRoot
+ HostOsInfo::appendExecutableSuffix(QLatin1String("/usr/bin/installedApp"))));
- QVERIFY(QFile::exists(defaultInstallRoot + QLatin1String("/usr/src/main.cpp")));
+ QVERIFY(regularFileExists(defaultInstallRoot + QLatin1String("/usr/src/main.cpp")));
QVERIFY(!addedFile.exists());
// Check whether changing install parameters on the product causes re-installation.
@@ -1786,9 +1819,9 @@ void TestBlackbox::installedApp()
projectFile.write(content);
QVERIFY(projectFile.flush());
QCOMPARE(runQbs(QbsRunParameters(QLatin1String("install"))), 0);
- QVERIFY(QFile::exists(defaultInstallRoot
+ QVERIFY(regularFileExists(defaultInstallRoot
+ HostOsInfo::appendExecutableSuffix(QLatin1String("/usr/local/bin/installedApp"))));
- QVERIFY(QFile::exists(defaultInstallRoot + QLatin1String("/usr/local/src/main.cpp")));
+ QVERIFY(regularFileExists(defaultInstallRoot + QLatin1String("/usr/local/src/main.cpp")));
// Check whether changing install parameters on the artifact causes re-installation.
content.replace("qbs.installDir: \"bin\"", "qbs.installDir: 'custom'");
@@ -1797,7 +1830,7 @@ void TestBlackbox::installedApp()
projectFile.write(content);
QVERIFY(projectFile.flush());
QCOMPARE(runQbs(QbsRunParameters(QLatin1String("install"))), 0);
- QVERIFY(QFile::exists(defaultInstallRoot
+ QVERIFY(regularFileExists(defaultInstallRoot
+ HostOsInfo::appendExecutableSuffix(QLatin1String("/usr/local/custom/installedApp"))));
// Check whether changing install parameters on a source file causes re-installation.
@@ -1807,7 +1840,7 @@ void TestBlackbox::installedApp()
projectFile.write(content);
projectFile.close();
QCOMPARE(runQbs(QbsRunParameters(QLatin1String("install"))), 0);
- QVERIFY(QFile::exists(defaultInstallRoot + QLatin1String("/usr/local/source/main.cpp")));
+ QVERIFY(regularFileExists(defaultInstallRoot + QLatin1String("/usr/local/source/main.cpp")));
rmDirR(buildDir);
QbsRunParameters params;
@@ -1910,7 +1943,7 @@ void TestBlackbox::testNsis()
bool haveMakeNsis = false;
foreach (const QString &path, paths) {
- if (QFile::exists(QDir::fromNativeSeparators(path) +
+ if (regularFileExists(QDir::fromNativeSeparators(path) +
HostOsInfo::appendExecutableSuffix(QLatin1String("/makensis")))) {
haveMakeNsis = true;
break;
@@ -1970,9 +2003,9 @@ static bool haveWiX()
}
foreach (const QString &path, paths) {
- if (QFile::exists(QDir::fromNativeSeparators(path) +
+ if (regularFileExists(QDir::fromNativeSeparators(path) +
HostOsInfo::appendExecutableSuffix(QLatin1String("/candle"))) &&
- QFile::exists(QDir::fromNativeSeparators(path) +
+ regularFileExists(QDir::fromNativeSeparators(path) +
HostOsInfo::appendExecutableSuffix(QLatin1String("/light")))) {
return true;
}
@@ -2003,8 +2036,67 @@ void TestBlackbox::testWiX()
QVERIFY(m_qbsStdout.contains("compiling QbsBootstrapper.wxs"));
QVERIFY(m_qbsStdout.contains("linking qbs-" + arch + ".msi"));
QVERIFY(m_qbsStdout.contains("linking qbs-setup-" + arch + ".exe"));
- QVERIFY(QFile::exists(buildDir + "/qbs-" + arch + ".msi"));
- QVERIFY(QFile::exists(buildDir + "/qbs-setup-" + arch + ".exe"));
+ QVERIFY(regularFileExists(buildDir + "/qbs-" + arch + ".msi"));
+ QVERIFY(regularFileExists(buildDir + "/qbs-setup-" + arch + ".exe"));
+}
+
+static QString findExecutable(const QStringList &fileNames)
+{
+ const QStringList path = QString::fromLocal8Bit(qgetenv("PATH"))
+ .split(HostOsInfo::pathListSeparator(), QString::SkipEmptyParts);
+
+ foreach (const QString &fileName, fileNames) {
+ foreach (const QString &ppath, path) {
+ const QString fullPath = ppath + QLatin1Char('/') + fileName;
+ if (QFileInfo(fullPath).exists())
+ return QDir::cleanPath(fullPath);
+ }
+ }
+ return QString();
+}
+
+static bool haveNodeJs()
+{
+ // The Node.js binary is called nodejs on Debian/Ubuntu-family operating systems due to a
+ // conflict with another package containing a binary named node
+ return !findExecutable(QStringList()
+ << QLatin1String("nodejs")
+ << QLatin1String("node")).isEmpty();
+}
+
+void TestBlackbox::testNodeJs()
+{
+ if (!haveNodeJs()) {
+ SKIP_TEST("Node.js is not installed");
+ return;
+ }
+
+ QDir::setCurrent(testDataDir + QLatin1String("/nodejs"));
+
+ QbsRunParameters params;
+ params.command = QLatin1String("run");
+ QCOMPARE(runQbs(params), 0);
+ QVERIFY((bool)m_qbsStdout.contains("hello world"));
+ QVERIFY(regularFileExists(buildDir + "/hello/hello.js"));
+}
+
+void TestBlackbox::testTypeScript()
+{
+ if (!haveNodeJs()) {
+ SKIP_TEST("node.js is not installed");
+ return;
+ }
+
+ QDir::setCurrent(testDataDir + QLatin1String("/typescript"));
+
+ QbsRunParameters params;
+ params.command = QLatin1String("run");
+ params.arguments = QStringList() << "-p" << "animals";
+ QCOMPARE(runQbs(params), 0);
+
+ QVERIFY(regularFileExists(buildDir + "/animals/animals.js"));
+ QVERIFY(regularFileExists(buildDir + "/animals/extra.js"));
+ QVERIFY(regularFileExists(buildDir + "/animals/main.js"));
}
QTEST_MAIN(TestBlackbox)