diff options
author | Peter Hartmann <peter.hartmann@trolltech.com> | 2009-08-07 08:19:11 (GMT) |
---|---|---|
committer | Peter Hartmann <peter.hartmann@trolltech.com> | 2009-08-07 08:22:09 (GMT) |
commit | 43a98b3ddd8d01b8e6453efd49bb6a9064e1ba08 (patch) | |
tree | bd0bab6b6f091be90a57ce938b7bb59812f14214 | |
parent | aed3faca7dafdc697402cfc99dc5e9ad2fcbdd45 (diff) | |
download | Qt-43a98b3ddd8d01b8e6453efd49bb6a9064e1ba08.zip Qt-43a98b3ddd8d01b8e6453efd49bb6a9064e1ba08.tar.gz Qt-43a98b3ddd8d01b8e6453efd49bb6a9064e1ba08.tar.bz2 |
xmlpatterns autotest: make tests work from shadow directory
... by prepending SRCDIR to the loaded files.
Reviewed-by: TrustMe
-rw-r--r-- | tests/auto/xmlpatterns/tst_xmlpatterns.cpp | 134 | ||||
-rw-r--r-- | tests/auto/xmlpatterns/xmlpatterns.pro | 6 |
2 files changed, 73 insertions, 67 deletions
diff --git a/tests/auto/xmlpatterns/tst_xmlpatterns.cpp b/tests/auto/xmlpatterns/tst_xmlpatterns.cpp index 2069d03..26dc280 100644 --- a/tests/auto/xmlpatterns/tst_xmlpatterns.cpp +++ b/tests/auto/xmlpatterns/tst_xmlpatterns.cpp @@ -154,7 +154,7 @@ void tst_XmlPatterns::xquerySupport() const QByteArray rawProducedStderr((process.readAllStandardError())); const QString fixedStderr(QString::fromLocal8Bit(rawProducedStderr).remove(m_filenameInStderr)); - const QString errorFileName(inputFile(QLatin1String("stderrBaselines/") + + const QString errorFileName(inputFile(QLatin1String(SRCDIR "stderrBaselines/") + QString::fromUtf8(QTest::currentDataTag()).remove(m_normalizeTestName) + QLatin1String(".txt"))); @@ -221,7 +221,7 @@ void tst_XmlPatterns::xquerySupport_data() const #endif /* Check one file for existence, to avoid possible false positives. */ - QVERIFY(QFile::exists(inputFile(QLatin1String("queries/onePlusOne.xq")))); + QVERIFY(QFile::exists(inputFile(QLatin1String(SRCDIR "queries/onePlusOne.xq")))); QTest::addColumn<int>("expectedExitCode"); QTest::addColumn<QByteArray>("expectedQueryOutput"); @@ -232,21 +232,21 @@ void tst_XmlPatterns::xquerySupport_data() const QTest::newRow("A simple math query") << 0 << QByteArray("2\n") - << QStringList((QLatin1String("queries/onePlusOne.xq"))) + << QStringList((QLatin1String(SRCDIR "queries/onePlusOne.xq"))) << QString() << QString(); QTest::newRow("An unbound external variable") << 2 << QByteArray() - << QStringList(QLatin1String("queries/externalVariable.xq")) + << QStringList(QLatin1String(SRCDIR "queries/externalVariable.xq")) << QString() << QString(); QTest::newRow("Bind an external variable") << 0 << QByteArray("1 4<e>1</e>true\n") - << (QStringList() << QLatin1String("queries/externalVariable.xq") + << (QStringList() << QLatin1String(SRCDIR "queries/externalVariable.xq") << QLatin1String("-param") << QLatin1String("externalVariable=1")) << QString() @@ -257,21 +257,21 @@ void tst_XmlPatterns::xquerySupport_data() const << QByteArray("1 4<e>1</e>true\n") << (QStringList() << QLatin1String("-param") << QLatin1String("externalVariable=1") - << QLatin1String("queries/externalVariable.xq")) + << QLatin1String(SRCDIR "queries/externalVariable.xq")) << QString() << QString(); QTest::newRow("Use fn:doc") << 0 << QByteArray("<e xmlns=\"http://example.com\" xmlns:p=\"http://example.com/P\" attr=\"1\" p:attr=\"\">\n <?target data?>\n <!-- a comment -->\n <e/>text <f/>text node</e>\n") - << QStringList(QLatin1String("queries/openDocument.xq")) + << QStringList(QLatin1String(SRCDIR "queries/openDocument.xq")) << QString() << QString(); QTest::newRow("Use fn:doc, together with -no-format, last") << 0 << QByteArray("<e xmlns=\"http://example.com\" xmlns:p=\"http://example.com/P\" attr=\"1\" p:attr=\"\"><?target data?><!-- a comment --><e/>text <f/>text node</e>") - << (QStringList() << QLatin1String("queries/openDocument.xq") + << (QStringList() << QLatin1String(SRCDIR "queries/openDocument.xq") << QLatin1String("-no-format")) << QString() << QString(); @@ -280,7 +280,7 @@ void tst_XmlPatterns::xquerySupport_data() const << 0 << QByteArray("<e xmlns=\"http://example.com\" xmlns:p=\"http://example.com/P\" attr=\"1\" p:attr=\"\"><?target data?><!-- a comment --><e/>text <f/>text node</e>") << (QStringList() << QLatin1String("-no-format") - << QLatin1String("queries/openDocument.xq")) + << QLatin1String(SRCDIR "queries/openDocument.xq")) << QString() << QString(); @@ -288,28 +288,28 @@ void tst_XmlPatterns::xquerySupport_data() const QTest::newRow("Make sure query paths are resolved against CWD, not the location of the executable.") << 0 << QByteArray("2\n") - << QStringList(QLatin1String("onePlusOne.xq")) + << QStringList(QLatin1String(SRCDIR "queries/onePlusOne.xq")) << QString::fromLatin1("queries") << QString(); QTest::newRow("Call fn:error()") << 2 << QByteArray() - << QStringList(QLatin1String("queries/errorFunction.xq")) + << QStringList(QLatin1String(SRCDIR "queries/errorFunction.xq")) << QString() << QString(); QTest::newRow("Evaluate a library module") << 2 << QByteArray() - << QStringList(QLatin1String("queries/simpleLibraryModule.xq")) + << QStringList(QLatin1String(SRCDIR "queries/simpleLibraryModule.xq")) << QString() << QString(); QTest::newRow("Trigger a static error.") << 2 << QByteArray() - << QStringList(QLatin1String("queries/staticError.xq")) + << QStringList(QLatin1String(SRCDIR "queries/staticError.xq")) << QString() << QString(); @@ -323,7 +323,7 @@ void tst_XmlPatterns::xquerySupport_data() const QTest::newRow("Open an nonexistent file") << 2 << QByteArray() - << QStringList(QLatin1String("queries/ThisFileDoesNotExist.xq")) + << QStringList(QLatin1String(SRCDIR "queries/ThisFileDoesNotExist.xq")) << QString() << QString(); @@ -332,63 +332,63 @@ void tst_XmlPatterns::xquerySupport_data() const QTest::newRow("XQuery-function message markups") << 2 << QByteArray() - << QStringList(QLatin1String("queries/wrongArity.xq")) + << QStringList(QLatin1String(SRCDIR "queries/wrongArity.xq")) << QString() << QString(); QTest::newRow("XQuery-type message markups") << 2 << QByteArray() - << QStringList(QLatin1String("queries/typeError.xq")) + << QStringList(QLatin1String(SRCDIR "queries/typeError.xq")) << QString() << QString(); QTest::newRow("XQuery-data & XQuery-keyword message markups") << 2 << QByteArray() - << QStringList(QLatin1String("queries/zeroDivision.xq")) + << QStringList(QLatin1String(SRCDIR "queries/zeroDivision.xq")) << QString() << QString(); QTest::newRow("XQuery-uri message markups") << 2 << QByteArray() - << QStringList(QLatin1String("queries/unsupportedCollation.xq")) + << QStringList(QLatin1String(SRCDIR "queries/unsupportedCollation.xq")) << QString() << QString(); QTest::newRow("XQuery-expression message markups") << 2 << QByteArray() - << QStringList(QLatin1String("queries/invalidRegexp.xq")) + << QStringList(QLatin1String(SRCDIR "queries/invalidRegexp.xq")) << QString() << QString(); QTest::newRow("Print a list of available regexp flags(The available flags are formatted in a complex way.)") << 2 << QByteArray() - << QStringList(QLatin1String("queries/invalidRegexpFlag.xq")) + << QStringList(QLatin1String(SRCDIR "queries/invalidRegexpFlag.xq")) << QString() << QString(); QTest::newRow("Trigger an assert in QPatternist::ColorOutput. The query naturally contains an error; XPTY0004.") << 2 << QByteArray() - << QStringList(QLatin1String("queries/flwor.xq")) + << QStringList(QLatin1String(SRCDIR "queries/flwor.xq")) << QString() << QString(); QTest::newRow("Trigger a second assert in QPatternist::ColorOutput. The query naturally contains XPST0003.") << 2 << QByteArray() - << QStringList(QLatin1String("queries/syntaxError.xq")) + << QStringList(QLatin1String(SRCDIR "queries/syntaxError.xq")) << QString() << QString(); QTest::newRow("-param is missing so multiple queries appear") << 2 << QByteArray() - << (QStringList() << QLatin1String("queries/reportGlobals.xq") + << (QStringList() << QLatin1String(SRCDIR "queries/reportGlobals.xq") << QLatin1String("fileToOpen=globals.gccxml")) << QString() << QString(); @@ -403,7 +403,7 @@ void tst_XmlPatterns::xquerySupport_data() const QTest::newRow("Basic use of -output, query first") << 0 << QByteArray("2\n") - << (QStringList() << QLatin1String("queries/onePlusOne.xq") + << (QStringList() << QLatin1String(SRCDIR "queries/onePlusOne.xq") << QLatin1String("-output") << QLatin1String("basicOutput.out")) << QString() @@ -414,22 +414,22 @@ void tst_XmlPatterns::xquerySupport_data() const << QByteArray("<e/>\n") << (QStringList() << QLatin1String("-output") << QLatin1String("basicOutput2.out") - << QLatin1String("queries/oneElement.xq")) + << QLatin1String(SRCDIR "queries/oneElement.xq")) << QString() << QString::fromLatin1("basicOutput2.out"); QTest::newRow("A single query, that does not exist") << 2 << QByteArray() - << (QStringList() << QLatin1String("doesNotExist.xq")) + << (QStringList() << QLatin1String(SRCDIR "doesNotExist.xq")) << QString() << QString(); QTest::newRow("Specify two identical query names") << 2 << QByteArray() - << (QStringList() << QLatin1String("query.xq") - << QLatin1String("query.xq")) + << (QStringList() << QLatin1String(SRCDIR "query.xq") + << QLatin1String(SRCDIR "query.xq")) << QString() << QString(); @@ -459,7 +459,7 @@ void tst_XmlPatterns::xquerySupport_data() const << QByteArray() << (QStringList() << QLatin1String("-output") << filename - << QLatin1String("queries/onePlusOne.xq")) + << QLatin1String(SRCDIR "queries/onePlusOne.xq")) << QString() << filename; } @@ -476,7 +476,7 @@ void tst_XmlPatterns::xquerySupport_data() const << QByteArray("2\n") << (QStringList() << QLatin1String("-output") << outName - << QLatin1String("queries/onePlusOne.xq")) + << QLatin1String(SRCDIR "queries/onePlusOne.xq")) << QString() << outName; } @@ -484,7 +484,7 @@ void tst_XmlPatterns::xquerySupport_data() const QTest::newRow("one query, and a terminating dash at the end") << 0 << QByteArray("2\n") - << (QStringList() << QLatin1String("queries/onePlusOne.xq") + << (QStringList() << QLatin1String(SRCDIR "queries/onePlusOne.xq") << QLatin1String("-")) << QString() << QString(); @@ -493,7 +493,7 @@ void tst_XmlPatterns::xquerySupport_data() const << 0 << QByteArray("2\n") << (QStringList() << QLatin1String("-") - << QLatin1String("queries/onePlusOne.xq")) + << QLatin1String(SRCDIR "queries/onePlusOne.xq")) << QString() << QString(); @@ -580,21 +580,21 @@ void tst_XmlPatterns::xquerySupport_data() const QTest::newRow("Run a query which evaluates to the empty sequence.") << 0 << QByteArray("\n") - << (QStringList() << QLatin1String("queries/emptySequence.xq")) + << (QStringList() << QLatin1String(SRCDIR "queries/emptySequence.xq")) << QString() << QString(); QTest::newRow("Run a query which evaluates to a single document node with no children.") << 0 << QByteArray("\n") - << (QStringList() << QLatin1String("queries/onlyDocumentNode.xq")) + << (QStringList() << QLatin1String(SRCDIR "queries/onlyDocumentNode.xq")) << QString() << QString(); QTest::newRow("Invoke with invalid -param value.") << 1 << QByteArray() - << (QStringList() << QLatin1String("queries/externalVariable.xq") + << (QStringList() << QLatin1String(SRCDIR "queries/externalVariable.xq") << QLatin1String("-param") << QLatin1String("EqualSignIsMissing")) << QString() @@ -603,7 +603,7 @@ void tst_XmlPatterns::xquerySupport_data() const QTest::newRow("Invoke with colon in variable name.") << 1 << QByteArray() - << (QStringList() << QLatin1String("queries/externalVariable.xq") + << (QStringList() << QLatin1String(SRCDIR "queries/externalVariable.xq") << QLatin1String("-param") << QLatin1String("xs:name=value")) << QString() @@ -612,7 +612,7 @@ void tst_XmlPatterns::xquerySupport_data() const QTest::newRow("Invoke with missing name in -param arg.") << 1 << QByteArray() - << (QStringList() << QLatin1String("queries/externalVariable.xq") + << (QStringList() << QLatin1String(SRCDIR "queries/externalVariable.xq") << QLatin1String("-param") << QLatin1String("=value")) << QString() @@ -621,7 +621,7 @@ void tst_XmlPatterns::xquerySupport_data() const QTest::newRow("Invoke with -param that has two adjacent equal signs.") << 0 << QByteArray("START =text END\n") - << (QStringList() << QLatin1String("queries/externalStringVariable.xq") + << (QStringList() << QLatin1String(SRCDIR "queries/externalStringVariable.xq") << QLatin1String("-param") << QLatin1String("externalString==text")) << QString() @@ -630,7 +630,7 @@ void tst_XmlPatterns::xquerySupport_data() const QTest::newRow("Pass in an external variable, but the query doesn't use it.") << 0 << QByteArray("2\n") - << (QStringList() << QLatin1String("queries/onePlusOne.xq") + << (QStringList() << QLatin1String(SRCDIR "queries/onePlusOne.xq") << QLatin1String("-param") << QLatin1String("externalString==text")) << QString() @@ -640,7 +640,7 @@ void tst_XmlPatterns::xquerySupport_data() const QTest::newRow("Invoke with -param that has no value.") << 0 << QByteArray("START END\n") - << (QStringList() << QLatin1String("queries/externalStringVariable.xq") + << (QStringList() << QLatin1String(SRCDIR "queries/externalStringVariable.xq") << QLatin1String("-param") << QLatin1String("externalString=")) << QString() @@ -656,7 +656,7 @@ void tst_XmlPatterns::xquerySupport_data() const QTest::newRow("Use a native path") << 0 << QByteArray("2\n") - << (QStringList() << QDir::toNativeSeparators(QLatin1String("queries/onePlusOne.xq"))) + << (QStringList() << QDir::toNativeSeparators(QLatin1String(SRCDIR "queries/onePlusOne.xq"))) << QString() << QString(); @@ -671,8 +671,8 @@ void tst_XmlPatterns::xquerySupport_data() const QTest::newRow("A valid, existing query, followed by a bogus one") << 1 << QByteArray() - << (QStringList() << QLatin1String("queries/onePlusOne.xq") - << QLatin1String("doesNotExist.xq")) + << (QStringList() << QLatin1String(SRCDIR "queries/onePlusOne.xq") + << QLatin1String(SRCDIR "doesNotExist.xq")) << QString() << QString(); */ @@ -681,8 +681,8 @@ void tst_XmlPatterns::xquerySupport_data() const QTest::newRow("Specify two different query names") << 1 << QByteArray() - << (QStringList() << QLatin1String("query1.xq") - << QLatin1String("query2.xq")) + << (QStringList() << QLatin1String(SRCDIR "query1.xq") + << QLatin1String(SRCDIR "query2.xq")) << QString() << QString(); */ @@ -696,7 +696,7 @@ void tst_XmlPatterns::xquerySupport_data() const QTest::newRow("Use -param twice") << 0 << QByteArray("param1 param2\n") - << (QStringList() << QLatin1String("queries/twoVariables.xq") + << (QStringList() << QLatin1String(SRCDIR "queries/twoVariables.xq") << QLatin1String("-param") << QLatin1String("var1=param1") << QLatin1String("-param") @@ -707,7 +707,7 @@ void tst_XmlPatterns::xquerySupport_data() const QTest::newRow("Use -param thrice") << 0 << QByteArray("param1 param2 third\n") - << (QStringList() << QLatin1String("queries/threeVariables.xq") + << (QStringList() << QLatin1String(SRCDIR "queries/threeVariables.xq") << QLatin1String("-param") << QLatin1String("var1=param1") << QLatin1String("-param") @@ -720,7 +720,7 @@ void tst_XmlPatterns::xquerySupport_data() const QTest::newRow("Specify the same parameter twice, different values") << 1 << QByteArray() - << (QStringList() << QLatin1String("queries/onePlusOne.xq") + << (QStringList() << QLatin1String(SRCDIR "queries/onePlusOne.xq") << QLatin1String("-param") << QLatin1String("duplicated=param1") << QLatin1String("-param") @@ -731,7 +731,7 @@ void tst_XmlPatterns::xquerySupport_data() const QTest::newRow("Specify the same parameter twice, same values") << 1 << QByteArray() - << (QStringList() << QLatin1String("queries/onePlusOne.xq") + << (QStringList() << QLatin1String(SRCDIR "queries/onePlusOne.xq") << QLatin1String("-param") << QLatin1String("duplicated=param1") << QLatin1String("-param") @@ -742,7 +742,7 @@ void tst_XmlPatterns::xquerySupport_data() const QTest::newRow("Open a non-existing collection.") << 2 << QByteArray() - << (QStringList() << QLatin1String("queries/nonexistingCollection.xq")) + << (QStringList() << QLatin1String(SRCDIR "queries/nonexistingCollection.xq")) << QString() << QString(); @@ -804,7 +804,7 @@ void tst_XmlPatterns::stdoutFailure() const //process.setStandardOutputFile(outName); process.setWorkingDirectory(QDir::current().absoluteFilePath(QString())); - process.start(m_command, QStringList("queries/onePlusOne.xq")); + process.start(m_command, QStringList(SRCDIR "queries/onePlusOne.xq")); QCOMPARE(process.exitStatus(), QProcess::NormalExit); QVERIFY(process.waitForFinished()); @@ -865,8 +865,8 @@ void tst_XmlPatterns::xsltSupport_data() const QTest::newRow("Pass in a stylesheet file which contains an XQuery query") << 2 << QByteArray() - << (QStringList() << QLatin1String("stylesheets/queryAsStylesheet.xsl") - << QLatin1String("queries/simpleDocument.xml")) + << (QStringList() << QLatin1String(SRCDIR "stylesheets/queryAsStylesheet.xsl") + << QLatin1String(SRCDIR "queries/simpleDocument.xml")) << QString() << QString(); @@ -883,7 +883,7 @@ void tst_XmlPatterns::xsltSupport_data() const << QByteArray() << (QStringList() << QLatin1String("-initial-template") << QLatin1String("name") - << QLatin1String("queries/onePlusOne.xq")) + << QLatin1String(SRCDIR "queries/onePlusOne.xq")) << QString() << QString(); @@ -918,8 +918,8 @@ void tst_XmlPatterns::xsltSupport_data() const << (QStringList() << QLatin1String("-no-format") << QLatin1String("-initial-template") << QLatin1String("main") - << QLatin1String("stylesheets/namedAndRootTemplate.xsl") - << QLatin1String("stylesheets/documentElement.xml")) + << QLatin1String(SRCDIR "stylesheets/namedAndRootTemplate.xsl") + << QLatin1String(SRCDIR "stylesheets/documentElement.xml")) << QString() << QString(); @@ -929,8 +929,8 @@ void tst_XmlPatterns::xsltSupport_data() const << (QStringList() << QLatin1String("-no-format") << QLatin1String("-initial-template") << QLatin1String("no-template-by-this-name") - << QLatin1String("stylesheets/namedAndRootTemplate.xsl") - << QLatin1String("stylesheets/documentElement.xml")) + << QLatin1String(SRCDIR "stylesheets/namedAndRootTemplate.xsl") + << QLatin1String(SRCDIR "stylesheets/documentElement.xml")) << QString() << QString(); @@ -940,7 +940,7 @@ void tst_XmlPatterns::xsltSupport_data() const << (QStringList() << QLatin1String("-no-format") << QLatin1String("-initial-template") << QLatin1String("main") - << QLatin1String("stylesheets/namedAndRootTemplate.xsl")) + << QLatin1String(SRCDIR "stylesheets/namedAndRootTemplate.xsl")) << QString() << QString(); @@ -950,7 +950,7 @@ void tst_XmlPatterns::xsltSupport_data() const << (QStringList() << QLatin1String("-no-format") << QLatin1String("-initial-template") << QLatin1String("{http://example.com/NS}main") - << QLatin1String("stylesheets/namedAndRootTemplate.xsl")) + << QLatin1String(SRCDIR "stylesheets/namedAndRootTemplate.xsl")) << QString() << QString(); @@ -959,7 +959,7 @@ void tst_XmlPatterns::xsltSupport_data() const << QByteArray("defParam overridedDefaultedParam implicitlyRequiredValue\n") << (QStringList() << QLatin1String("-initial-template") << QLatin1String("main") - << QLatin1String("stylesheets/useParameters.xsl") + << QLatin1String(SRCDIR "stylesheets/useParameters.xsl") << QLatin1String("-param") << QLatin1String("overridedDefaultedParam=overridedDefaultedParam") << QLatin1String("-param") @@ -970,24 +970,24 @@ void tst_XmlPatterns::xsltSupport_data() const QTest::newRow("Use a simplified stylesheet module") << 0 << QByteArray("<output>some text</output>\n") - << (QStringList() << QLatin1String("stylesheets/simplifiedStylesheetModule.xsl") - << QLatin1String("stylesheets/simplifiedStylesheetModule.xml")) + << (QStringList() << QLatin1String(SRCDIR "stylesheets/simplifiedStylesheetModule.xsl") + << QLatin1String(SRCDIR "stylesheets/simplifiedStylesheetModule.xml")) << QString() << QString(); QTest::newRow("Not well-formed stylesheet, causes crash in coloring code.") << 2 << QByteArray() - << (QStringList() << QLatin1String("stylesheets/notWellformed.xsl") - << QLatin1String("queries/simpleDocument.xml")) + << (QStringList() << QLatin1String(SRCDIR "stylesheets/notWellformed.xsl") + << QLatin1String(SRCDIR "queries/simpleDocument.xml")) << QString() << QString(); QTest::newRow("Not well-formed instance document, causes crash in coloring code.") << 2 << QByteArray() - << (QStringList() << QLatin1String("stylesheets/bool070.xsl") - << QLatin1String("stylesheets/bool070.xml")) + << (QStringList() << QLatin1String(SRCDIR "stylesheets/bool070.xsl") + << QLatin1String(SRCDIR "stylesheets/bool070.xml")) << QString() << QString(); diff --git a/tests/auto/xmlpatterns/xmlpatterns.pro b/tests/auto/xmlpatterns/xmlpatterns.pro index 569e23f..01e3b2b 100644 --- a/tests/auto/xmlpatterns/xmlpatterns.pro +++ b/tests/auto/xmlpatterns/xmlpatterns.pro @@ -2,4 +2,10 @@ load(qttest_p4) SOURCES += tst_xmlpatterns.cpp \ ../qxmlquery/TestFundament.cpp +!wince* { +DEFINES += SRCDIR=\\\"$$PWD/\\\" +} else { +DEFINES += SRCDIR=\\\"./\\\" +} + include (../xmlpatterns.pri) |