diff options
author | Joerg Bornemann <joerg.bornemann@theqtcompany.com> | 2015-03-17 11:04:52 +0100 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@theqtcompany.com> | 2015-03-17 15:14:29 +0000 |
commit | 7bbe5cb1a3a9af08feda8f9a173fc354b8a18f4b (patch) | |
tree | 9f2b267f2bf666dd1f6c3f87e65f57b1891ecd27 /tests | |
parent | ac71a80c5a9dbf83f80b1ad83d9b753694b6af05 (diff) |
fix ignoring exit codes greater than 255
Having a command prefixed with - should ignore the exit code.
However, only exit codes <= 255 were properly ignored.
The exit code type is unsigned int in MSVC land.
Change-Id: I352f0f068aaed5afc18081a3125d46eeb5094d44
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/makefiles/blackbox/ignoreExitCodes/test.mk | 20 | ||||
-rw-r--r-- | tests/tests.cpp | 15 |
2 files changed, 23 insertions, 12 deletions
diff --git a/tests/makefiles/blackbox/ignoreExitCodes/test.mk b/tests/makefiles/blackbox/ignoreExitCodes/test.mk index 35dee3d..11d1d4a 100644 --- a/tests/makefiles/blackbox/ignoreExitCodes/test.mk +++ b/tests/makefiles/blackbox/ignoreExitCodes/test.mk @@ -1,11 +1,17 @@ # test ignore exit codes in make files -# -# http://msdn.microsoft.com/en-us/library/1whxt45w.aspx -all: test_ignoreExitCode - @echo ---SUCCESS--- +test1: testNonexistentCommand testExitCode1 testExitCode2 + @echo ---SUCCESS--- -test_ignoreExitCode: - -nonexistent_command - @echo Failing command was properly ignored +testNonexistentCommand: + -nonexistent_command 2>NUL +testExitCode1: + -cmd /k exit 1 + +testExitCode2: + -1cmd /k exit 1 + +# target test2 is supposed to fail +test2: + -6cmd /k exit 7 diff --git a/tests/tests.cpp b/tests/tests.cpp index a497101..30fbb54 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -33,6 +33,8 @@ #include <options.h> #include <exception.h> +#include <limits> + using namespace NMakeFile; void Tests::initTestCase() @@ -361,7 +363,7 @@ void Tests::dotDirectives() QVERIFY(target != 0); QCOMPARE(target->m_commands.count(), 2); cmd = target->m_commands.takeFirst(); - QCOMPARE(int(cmd.m_maxExitCode), 255); + QCOMPARE(cmd.m_maxExitCode, std::numeric_limits<unsigned int>::max()); target = mkfile->target(QLatin1String("ignorance_three")); QVERIFY(target != 0); @@ -580,13 +582,13 @@ void Tests::commandModifiers() QCOMPARE(cmd.m_silent, true); cmd = target->m_commands.at(1); - QCOMPARE((int)cmd.m_maxExitCode, 255); + QCOMPARE(cmd.m_maxExitCode, std::numeric_limits<unsigned int>::max()); cmd = target->m_commands.at(2); - QCOMPARE((int)cmd.m_maxExitCode, 5); + QCOMPARE(cmd.m_maxExitCode, 5u); cmd = target->m_commands.at(3); - QCOMPARE((int)cmd.m_maxExitCode, 15); + QCOMPARE(cmd.m_maxExitCode, 15u); cmd = target->m_commands.at(4); QCOMPARE(cmd.m_singleExecution, true); @@ -1101,7 +1103,10 @@ void Tests::ignoreExitCodes() QVERIFY(runJom(QStringList() << "/f" << "blackbox\\ignoreExitCodes\\test.mk")); QCOMPARE(m_jomProcess->exitCode(), 0); QByteArray output = m_jomProcess->readAllStandardOutput(); - QVERIFY(output.contains("Failing command was properly ignored")); + QVERIFY(output.contains("---SUCCESS---")); + + QVERIFY(runJom(QStringList() << "/f" << "blackbox\\ignoreExitCodes\\test.mk" << "test2")); + QCOMPARE(m_jomProcess->exitCode(), 2); } void Tests::inlineFiles() |