Skip to content

Commit 08ab764

Browse files
committed
GUITESTS: More flexible test data paths.
Use build-time define to set the path to the source files directory. Which then can be used to format path to the test data. This allows running tests from out-of-source-tree -builds that e.g. QtCreator does.
1 parent 7ae2536 commit 08ab764

6 files changed

Lines changed: 10 additions & 4 deletions

File tree

gui/test/xmlreport/testxmlreport.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ void TestXmlReport::testUnquoteMessage()
3737

3838
void TestXmlReport::testGetVersion1()
3939
{
40-
const QString filepath("../xmlfiles/xmlreport_v1.xml");
40+
const QString filepath(QString(SRCDIR) + "/../xmlfiles/xmlreport_v1.xml");
4141
QCOMPARE(XmlReport::determineVersion(filepath), 1);
4242
}
4343

4444
void TestXmlReport::testGetVersion2()
4545
{
46-
const QString filepath("../xmlfiles/xmlreport_v2.xml");
46+
const QString filepath(QString(SRCDIR) + "/../xmlfiles/xmlreport_v2.xml");
4747
QCOMPARE(XmlReport::determineVersion(filepath), 2);
4848
}
4949

gui/test/xmlreport/xmlreport.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ INCLUDEPATH += .
55
OBJECTS_DIR = ../build
66
MOC_DIR = ../build
77

8+
DEFINES += SRCDIR=\\\"$$PWD\\\"
9+
810
include(../common.pri)
911

1012
# tests

gui/test/xmlreportv1/testxmlreportv1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
void TestXmlReportV1::readXml()
2727
{
28-
const QString filepath("../xmlfiles/xmlreport_v1.xml");
28+
const QString filepath(QString(SRCDIR) + "/../xmlfiles/xmlreport_v1.xml");
2929
XmlReportV1 report(filepath);
3030
QVERIFY(report.Open());
3131
QList<ErrorItem> errors = report.Read();

gui/test/xmlreportv1/xmlreportv1.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ INCLUDEPATH += .
55
OBJECTS_DIR = ../build
66
MOC_DIR = ../build
77

8+
DEFINES += SRCDIR=\\\"$$PWD\\\"
9+
810
include(../common.pri)
911

1012
# tests

gui/test/xmlreportv2/testxmlreportv2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
void TestXmlReportV2::readXml()
2727
{
28-
const QString filepath("../xmlfiles/xmlreport_v2.xml");
28+
const QString filepath(QString(SRCDIR) + "/../xmlfiles/xmlreport_v2.xml");
2929
XmlReportV2 report(filepath);
3030
QVERIFY(report.Open());
3131
QList<ErrorItem> errors = report.Read();

gui/test/xmlreportv2/xmlreportv2.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ MOC_DIR = ../build
77

88
include(../common.pri)
99

10+
DEFINES += SRCDIR=\\\"$$PWD\\\"
11+
1012
# tests
1113
SOURCES += testxmlreportv2.cpp
1214

0 commit comments

Comments
 (0)