aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Komissarov <ABBAPOH@gmail.com>2019-04-25 21:54:45 +0200
committerIvan Komissarov <ABBAPOH@gmail.com>2019-04-29 15:03:11 +0000
commit9ee0f0c07935e2429707c62ee088bc6b3d8911ef (patch)
treecaa81ccbbbe10c53ac7cf517c62b13e2a0a082ae
parente5036d2567c92eb309fbe32cbf2cdc11d406edc5 (diff)
Fix lexyaccOutputs with outdated Bison
On Macos, default bison version is 2.3 which means newer syntax is not recognized and test fails Change-Id: I1180528fc8f4aa49f5327e736c1c97dade53c194 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp42
-rw-r--r--tests/auto/blackbox/tst_blackbox.h1
2 files changed, 35 insertions, 8 deletions
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index 06165271b..93c0f0ce4 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -146,6 +146,25 @@ bool TestBlackbox::lexYaccExist()
&& !findExecutable(QStringList("yacc")).isEmpty();
}
+qbs::Version TestBlackbox::bisonVersion()
+{
+ const auto yaccBinary = findExecutable(QStringList("yacc"));
+ QProcess process;
+ process.start(yaccBinary, QStringList() << "--version");
+ if (!process.waitForStarted())
+ return qbs::Version();
+ if (!process.waitForFinished())
+ return qbs::Version();
+ const auto stdout = process.readAllStandardOutput();
+ if (stdout.isEmpty())
+ return qbs::Version();
+ const auto line = stdout.split('\n')[0];
+ const auto words = line.split(' ');
+ if (words.empty())
+ return qbs::Version();
+ return qbs::Version::fromString(words.last());
+}
+
void TestBlackbox::sevenZip()
{
QDir::setCurrent(testDataDir + "/archiver");
@@ -4343,20 +4362,27 @@ void TestBlackbox::lexyaccOutputs()
} \
}
- QVERIFY(QDir::setCurrent(testDataDir + "/lexyacc/lex_prefix"));
- rmDirR(relativeBuildDir());
- QCOMPARE(runQbs(params), 0);
- VERIFY_COMPILATION(yaccOutputFilePath);
+ const auto version = bisonVersion();
+ if (version >= qbs::Version(2, 6)) {
+ // prefix only supported starting from bison 2.6
+ QVERIFY(QDir::setCurrent(testDataDir + "/lexyacc/lex_prefix"));
+ rmDirR(relativeBuildDir());
+ QCOMPARE(runQbs(params), 0);
+ VERIFY_COMPILATION(yaccOutputFilePath);
+ }
QVERIFY(QDir::setCurrent(testDataDir + "/lexyacc/lex_outfile"));
rmDirR(relativeBuildDir());
QCOMPARE(runQbs(params), 0);
VERIFY_COMPILATION(yaccOutputFilePath);
- QVERIFY(QDir::setCurrent(testDataDir + "/lexyacc/yacc_output"));
- rmDirR(relativeBuildDir());
- QCOMPARE(runQbs(params), 0);
- VERIFY_COMPILATION(lexOutputFilePath);
+ if (version >= qbs::Version(2, 4)) {
+ // output syntax was changed in bison 2.4
+ QVERIFY(QDir::setCurrent(testDataDir + "/lexyacc/yacc_output"));
+ rmDirR(relativeBuildDir());
+ QCOMPARE(runQbs(params), 0);
+ VERIFY_COMPILATION(lexOutputFilePath);
+ }
#undef VERIFY_COMPILATION
}
diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h
index 624cd5fbb..f7f1c9a29 100644
--- a/tests/auto/blackbox/tst_blackbox.h
+++ b/tests/auto/blackbox/tst_blackbox.h
@@ -310,6 +310,7 @@ private:
QMap<QString, QString> findTypeScript(int *status);
QString findArchiver(const QString &fileName, int *status = nullptr);
static bool lexYaccExist();
+ static qbs::Version bisonVersion();
};
#endif // TST_BLACKBOX_H