diff options
author | Christian Kandeler <christian.kandeler@theqtcompany.com> | 2015-02-17 11:14:10 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@theqtcompany.com> | 2015-02-17 10:27:03 +0000 |
commit | 3ff29a66b153c1a76d476ff91a26db931df5de89 (patch) | |
tree | 05bf2055128d5be42e2be70095e82fb3314e41d3 /tests/fuzzy-test/fuzzytester.cpp | |
parent | 78516687e1bd7aef305e31f4596750f081bbe641 (diff) |
fuzzy tester: Allow to run for a given time span.
This is helpful e.g. for letting the tool run overnight.
Change-Id: I03fc9942dff35b6f9c4f966ab6795fede49f0ee6
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'tests/fuzzy-test/fuzzytester.cpp')
-rw-r--r-- | tests/fuzzy-test/fuzzytester.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/tests/fuzzy-test/fuzzytester.cpp b/tests/fuzzy-test/fuzzytester.cpp index 0fb31d431..4aee4193b 100644 --- a/tests/fuzzy-test/fuzzytester.cpp +++ b/tests/fuzzy-test/fuzzytester.cpp @@ -30,6 +30,7 @@ #include "fuzzytester.h" #include <QDir> +#include <QElapsedTimer> #include <QProcess> #include <algorithm> @@ -40,7 +41,8 @@ FuzzyTester::FuzzyTester() { } -void FuzzyTester::runTest(const QString &profile, const QString &startCommit) +void FuzzyTester::runTest(const QString &profile, const QString &startCommit, + int maxDurationInMinutes) { m_profile = profile; @@ -61,12 +63,20 @@ void FuzzyTester::runTest(const QString &profile, const QString &startCommit) quint64 run = 0; QStringList buildSequence(workingStartCommit); + QElapsedTimer timer; + const qint64 maxDurationInMillis = maxDurationInMinutes * 60 * 1000; + if (maxDurationInMillis != 0) + timer.start(); - // This is in effect an infinite loop for all but the tiniest commit sets. - // That's not a problem -- if you want the application to finish early, just kill it. - while (std::next_permutation(allCommits.begin(), allCommits.end())) { + bool timerHasExpired = false; + while (std::next_permutation(allCommits.begin(), allCommits.end()) && !timerHasExpired) { qDebug("Testing permutation %llu...", ++run); foreach (const QString ¤tCommit, allCommits) { + if (timer.isValid() && timer.hasExpired(maxDurationInMillis)) { + timerHasExpired = true; + break; + } + buildSequence << currentCommit; checkoutCommit(currentCommit); qDebug("Testing incremental build #%d (%s)", buildSequence.count() - 1, @@ -99,6 +109,11 @@ void FuzzyTester::runTest(const QString &profile, const QString &startCommit) } } } + + if (timerHasExpired) + qDebug("Maximum duration reached."); + else + qDebug("All possible permutations were tried."); } void FuzzyTester::checkoutCommit(const QString &commit) |