From e19bbdf888e1fdf73872fd8b1598a245ad77d459 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Fri, 9 Oct 2015 14:43:25 +0200 Subject: Skip tests that crashes. Change-Id: I45ad981fa4d6d7302cf2e06429ea1134957034f3 Reviewed-by: Erik Verbruggen Reviewed-by: Frederik Gladhorn --- tests/auto/xmlpatternssdk/TestCase.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/xmlpatternssdk/TestCase.cpp b/tests/auto/xmlpatternssdk/TestCase.cpp index d84ac06..642e84d 100644 --- a/tests/auto/xmlpatternssdk/TestCase.cpp +++ b/tests/auto/xmlpatternssdk/TestCase.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include "DebugExpressionFactory.h" #include "ExternalSourceLoader.h" @@ -62,9 +63,16 @@ TestCase::~TestCase() delete m_result; } +static bool lessThan(const char *a, const char *b) +{ + return qstrcmp(a, b) < 0; +} + TestResult::List TestCase::execute(const ExecutionStage stage, TestSuite *) { + const QByteArray nm = name().toAscii(); + if(name() == QLatin1String("Constr-cont-document-3")) { TestResult::List result; @@ -95,9 +103,28 @@ TestResult::List TestCase::execute(const ExecutionStage stage, result.append(createTestResult(TestResult::Fail, QLatin1String("Skipped this test, we crash on it."))); return result; } + else { + // Should be sorted in the order that std::binary_search expects + static const char *crashes[] = {"Constr-attr-content-4", + "K2-DirectConElem-12", + "K2-DirectConElem-50", + "K2-DirectConElemAttr-10", + "K2-DirectConElemAttr-18", + "K2-DirectConElemAttr-19", + "K2-DirectConElemAttr-20", + "K2-DirectConElemAttr-21" + }; + + const bool skip = std::binary_search(&crashes[0], &crashes[sizeof(crashes)/sizeof(crashes[0])], nm.constData(), lessThan); + if (skip) { + TestResult::List result; + result.append(createTestResult(TestResult::Fail, QLatin1String("Skipped this test, we crash on it."))); + return result; + } + } - qDebug() << "Running test case: " << name(); + qDebug() << "Running test case: " << nm; return execute(stage); Q_ASSERT(false); -- cgit v1.2.1 From 7367d313378fb548449feda3bb0f437d29f20e8b Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Fri, 9 Oct 2015 14:46:41 +0200 Subject: Can now specify which tests to skip with an environment variable e.g. export XMLPATTERNSXQTS_TESTRANGE=42,49 will execute the tests from number 42 to number 49. The tests are numbered sequentially. This will allow us to not having to run through all the tests when testing for a specific testcase. Change-Id: I4c21158a4eada1b48eb809a887216a7160d73220 Reviewed-by: Frederik Gladhorn --- tests/auto/xmlpatternssdk/TestCase.cpp | 9 ++++++++- tests/auto/xmlpatternssdk/TreeItem.cpp | 4 ++++ tests/auto/xmlpatternssdk/TreeItem.h | 3 +++ tests/auto/xmlpatternsxqts/tst_suitetest.cpp | 9 +++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/xmlpatternssdk/TestCase.cpp b/tests/auto/xmlpatternssdk/TestCase.cpp index 642e84d..9ae86ad 100644 --- a/tests/auto/xmlpatternssdk/TestCase.cpp +++ b/tests/auto/xmlpatternssdk/TestCase.cpp @@ -71,6 +71,13 @@ static bool lessThan(const char *a, const char *b) TestResult::List TestCase::execute(const ExecutionStage stage, TestSuite *) { + ++TestCase::executions; + + if ((TestCase::executions < TestCase::executeRange.first) || (TestCase::executions > TestCase::executeRange.second)) { + qDebug("Skipping test case #%6d", TestCase::executions); + return TestResult::List(); + } + const QByteArray nm = name().toAscii(); if(name() == QLatin1String("Constr-cont-document-3")) @@ -124,7 +131,7 @@ TestResult::List TestCase::execute(const ExecutionStage stage, } - qDebug() << "Running test case: " << nm; + qDebug("Running test case #%6d: %s", TestCase::executions, nm.constData()); return execute(stage); Q_ASSERT(false); diff --git a/tests/auto/xmlpatternssdk/TreeItem.cpp b/tests/auto/xmlpatternssdk/TreeItem.cpp index 9b91f0c..6c8c265 100644 --- a/tests/auto/xmlpatternssdk/TreeItem.cpp +++ b/tests/auto/xmlpatternssdk/TreeItem.cpp @@ -51,4 +51,8 @@ int TreeItem::row() const return -1; } +QPair TreeItem::executeRange = qMakePair(0,INT_MAX); +int TreeItem::executions = 0; + + // vim: et:ts=4:sw=4:sts=4 diff --git a/tests/auto/xmlpatternssdk/TreeItem.h b/tests/auto/xmlpatternssdk/TreeItem.h index 802b09f..f6a4fa1 100644 --- a/tests/auto/xmlpatternssdk/TreeItem.h +++ b/tests/auto/xmlpatternssdk/TreeItem.h @@ -84,6 +84,9 @@ namespace QPatternistSDK virtual QVariant data(const Qt::ItemDataRole role, int column) const = 0; + static QPair executeRange; + static int executions; + Q_SIGNALS: /** * Emitted whenever this item changed. This is used for keeping diff --git a/tests/auto/xmlpatternsxqts/tst_suitetest.cpp b/tests/auto/xmlpatternsxqts/tst_suitetest.cpp index 4fdb7b5..4785067 100644 --- a/tests/auto/xmlpatternsxqts/tst_suitetest.cpp +++ b/tests/auto/xmlpatternsxqts/tst_suitetest.cpp @@ -35,6 +35,8 @@ #include #include +#include + #include "TestSuite.h" #include "TestSuiteResult.h" #include "XMLWriter.h" @@ -70,6 +72,13 @@ void tst_SuiteTest::runTestSuite() const if(m_abortRun) QSKIP("The test suite is not available, no tests are run."); + QByteArray range = qgetenv("XMLPATTERNSXQTS_TESTRANGE"); + char *endptr; + TreeItem::executeRange.first = strtol(range.constData(), &endptr, 10); + long e = 0; + if (endptr - range.constData() < range.size()) + e = strtol(endptr + 1, &endptr, 10); + TreeItem::executeRange.second = (e == 0 ? INT_MAX : e); QString errMsg; const QFileInfo fi(m_catalogPath); const QUrl catalogPath(QUrl::fromLocalFile(fi.absoluteFilePath())); -- cgit v1.2.1 From ee56885f52b63132bffafad1ccc8830a65d129fa Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 5 Nov 2015 13:42:02 +0100 Subject: Test suite: Streamline code in QPatternistSDK::DebugExpressionFactory. Fix release mode compiler warnings: In member function 'virtual void QPatternistSDK::DebugExpressionFactory::processTemplateRule(const Ptr&, const Ptr&, const QXmlName&, QPatternist::ExpressionFactory::TemplateCompilationStage)': warning: 'title' may be used uninitialized in this function [-Wmaybe-uninitialized] In member function 'virtual void QPatternistSDK::DebugExpressionFactory::processNamedTemplate(const QXmlName&, const Ptr&, QPatternist::ExpressionFactory::TemplateCompilationStage)': warning: 'title' may be used uninitialized in this function [-Wmaybe-uninitialized] by rewriting the code to directly add to a QString. Change-Id: I23781b624e6b3fbc385d8b041a1923d49c291f51 Reviewed-by: Mitch Curtis --- .../auto/xmlpatternssdk/DebugExpressionFactory.cpp | 82 +++++++++------------- 1 file changed, 32 insertions(+), 50 deletions(-) (limited to 'tests') diff --git a/tests/auto/xmlpatternssdk/DebugExpressionFactory.cpp b/tests/auto/xmlpatternssdk/DebugExpressionFactory.cpp index 830b25f..92c4a6a 100644 --- a/tests/auto/xmlpatternssdk/DebugExpressionFactory.cpp +++ b/tests/auto/xmlpatternssdk/DebugExpressionFactory.cpp @@ -179,35 +179,25 @@ void DebugExpressionFactory::processTemplateRule(const Expression::Ptr &body, const QXmlName &mode, const TemplateCompilationStage stage) { - const char * title; - - switch(stage) - { - case TemplateInitial: - { - title = "Initial Build"; - break; - } - case TemplateTypeCheck: - { - title = "Type Check"; - break; - } - case TemplateCompress: - { - title = "Compression"; - break; - } + QString title = QLatin1String("T-Rule "); + + switch (stage) { + case TemplateInitial: + title += QLatin1String("Initial Build"); + break; + case TemplateTypeCheck: + title += QLatin1String("Type Check"); + break; + case TemplateCompress: + title += QLatin1String("Compression"); + break; } + title += QLatin1String(" mode: ") + + Global::namePool()->displayName(mode) + + QLatin1String(" priority: ") + + QString::number(pattern->priority()); - const QString modeName(Global::namePool()->displayName(mode)); - Q_ASSERT(title); - ASTItem *const newChild = new ASTItem(m_ast, QLatin1String("T-Rule ") - + QLatin1String(title) - + QLatin1String(" mode: ") - + modeName - + QLatin1String(" priority: ") - + QString::number(pattern->priority())); + ASTItem *const newChild = new ASTItem(m_ast, title); m_ast->appendChild(newChild); newChild->appendChild(buildASTTree(pattern->matchPattern(), newChild, QPatternist::SequenceType::Ptr())); @@ -218,31 +208,23 @@ void DebugExpressionFactory::processNamedTemplate(const QXmlName &name, const Expression::Ptr &body, const TemplateCompilationStage stage) { - const char * title; - - switch(stage) - { - case TemplateInitial: - { - title = "Named Template Initial Build"; - break; - } - case TemplateTypeCheck: - { - title = "Named Template Type Check"; - break; - } - case TemplateCompress: - { - title = "Named Template Compression"; - break; - } + QString title; + + switch (stage) { + case TemplateInitial: + title += QLatin1String("Named Template Initial Build"); + break; + case TemplateTypeCheck: + title += QLatin1String("Named Template Type Check"); + break; + case TemplateCompress: + title += QLatin1String("Named Template Compression"); + break; } - Q_ASSERT(title); - ASTItem *const newChild = new ASTItem(m_ast, QLatin1String(title) - + QLatin1String(": ") - + Global::namePool()->displayName(name)); + title += QLatin1String(": ") + Global::namePool()->displayName(name); + + ASTItem *const newChild = new ASTItem(m_ast, title); m_ast->appendChild(newChild); newChild->appendChild(buildASTTree(body, newChild, QPatternist::SequenceType::Ptr())); -- cgit v1.2.1 From 8ba610490e2d93526c165584e2f52c7ae8e9edc0 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Thu, 10 Dec 2015 09:06:09 +0100 Subject: Change uses of toAscii to toLatin1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This ammends e19bbdf8. Change-Id: Idebb29cdbb6fb30ac446701ebc415a7944f48421 Reviewed-by: Jan Arve Sæther --- tests/auto/xmlpatternssdk/TestCase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/xmlpatternssdk/TestCase.cpp b/tests/auto/xmlpatternssdk/TestCase.cpp index 9ae86ad..acf9e84 100644 --- a/tests/auto/xmlpatternssdk/TestCase.cpp +++ b/tests/auto/xmlpatternssdk/TestCase.cpp @@ -78,7 +78,7 @@ TestResult::List TestCase::execute(const ExecutionStage stage, return TestResult::List(); } - const QByteArray nm = name().toAscii(); + const QByteArray nm = name().toLatin1(); if(name() == QLatin1String("Constr-cont-document-3")) { -- cgit v1.2.1