diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2018-05-28 16:03:16 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2018-05-30 13:29:10 +0000 |
commit | 24b624b09388e4ea27de38e058b3d3d59e67bb30 (patch) | |
tree | e484e163c93bb7259a1440bd9865bdad68850656 /tests/auto | |
parent | bb86d55c9e8614e6cf5819f0300d12d021402195 (diff) | |
download | qbs-24b624b09388e4ea27de38e058b3d3d59e67bb30.tar.gz |
C++ scanner: Properly handle UTF-8 byte order mark
Includes in the first line of a source file starting with a byte order
mark would not get detected, resulting in failure to recompile after a
header file change.
Skip over the BOM before passing the data to the lexer.
Task-number: QBS-1348
Done-with: Ola Røer Thorsen <ola@silentwings.no>
Change-Id: I894a5b1667e49be5f8ce9b5cc66e4e796fd073f1
Reviewed-by: Ola Røer Thorsen <ola@silentwings.no>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/blackbox/testdata/bom-sources/bom-sources.qbs | 6 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/bom-sources/main.cpp | 3 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/bom-sources/theheader.h | 0 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.cpp | 15 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.h | 1 |
5 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/blackbox/testdata/bom-sources/bom-sources.qbs b/tests/auto/blackbox/testdata/bom-sources/bom-sources.qbs new file mode 100644 index 000000000..8b5dbb238 --- /dev/null +++ b/tests/auto/blackbox/testdata/bom-sources/bom-sources.qbs @@ -0,0 +1,6 @@ +import qbs + +CppApplication { + name: "app" + files: ["main.cpp", "theheader.h"] +} diff --git a/tests/auto/blackbox/testdata/bom-sources/main.cpp b/tests/auto/blackbox/testdata/bom-sources/main.cpp new file mode 100644 index 000000000..de10a65a2 --- /dev/null +++ b/tests/auto/blackbox/testdata/bom-sources/main.cpp @@ -0,0 +1,3 @@ +#include "theheader.h" + +int main() {} diff --git a/tests/auto/blackbox/testdata/bom-sources/theheader.h b/tests/auto/blackbox/testdata/bom-sources/theheader.h new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/auto/blackbox/testdata/bom-sources/theheader.h diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index a833bd264..8ca35249a 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -5839,6 +5839,21 @@ void TestBlackbox::badInterpreter() QCOMPARE(runQbs(QbsRunParameters("run", QStringList() << "-p" << "script-ok")), 0); } +void TestBlackbox::bomSources() +{ + QDir::setCurrent(testDataDir + "/bom-sources"); + const bool success = runQbs() == 0; + if (!success) + QSKIP("Assuming compiler cannot deal with byte order mark"); + QVERIFY2(m_qbsStdout.contains("compiling main.cpp"), m_qbsStdout.constData()); + WAIT_FOR_NEW_TIMESTAMP(); + QCOMPARE(runQbs(), 0); + QVERIFY2(!m_qbsStdout.contains("compiling main.cpp"), m_qbsStdout.constData()); + touch("theheader.h"); + QCOMPARE(runQbs(), 0); + QVERIFY2(m_qbsStdout.contains("compiling main.cpp"), m_qbsStdout.constData()); +} + void TestBlackbox::buildDataOfDisabledProduct() { QDir::setCurrent(testDataDir + QLatin1String("/build-data-of-disabled-product")); diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h index fb95e723a..e5adc762f 100644 --- a/tests/auto/blackbox/tst_blackbox.h +++ b/tests/auto/blackbox/tst_blackbox.h @@ -50,6 +50,7 @@ private slots: void autotestWithDependencies(); void auxiliaryInputsFromDependencies(); void badInterpreter(); + void bomSources(); void buildDataOfDisabledProduct(); void buildDirectories(); void buildEnvChange(); |