@@ -26,9 +26,18 @@ XmlJoiner::~XmlJoiner()
26
26
void XmlJoiner::processFolder (const QString folder)
27
27
{
28
28
QDir xmlDir (folder);
29
+ if (xmlDir.exists () == false )
30
+ throw std::logic_error (" processFolder - folder doesn't exist" );
31
+
29
32
QStringList extensions (" *.xml" );
30
- foreach (const QString &file, xmlDir.entryList (extensions,
31
- QDir::Files | QDir::NoDotAndDotDot, QDir::Name))
33
+ QStringList xmlFiles = xmlDir.entryList (extensions,
34
+ QDir::Files | QDir::NoDotAndDotDot,
35
+ QDir::Name);
36
+
37
+ if (xmlFiles.empty ())
38
+ throw std::logic_error (" processFolder - folder doesn't contain xml files" );
39
+
40
+ foreach (const QString &file, xmlFiles)
32
41
{
33
42
processFile (xmlDir.absoluteFilePath (file));
34
43
}
@@ -40,11 +49,10 @@ void XmlJoiner::processFile(const QString absolutePath)
40
49
41
50
if (!file.open (QIODevice::ReadOnly | QIODevice::Text))
42
51
{
43
- throw std::runtime_error ( " Error opening file " + absolutePath.toStdString ());
52
+ throw std::logic_error ( " ProcessFile - Error opening file " + absolutePath.toStdString ());
44
53
}
45
54
46
55
QXmlStreamReader xml (&file);
47
-
48
56
while (!xml.atEnd () && !xml.hasError ())
49
57
{
50
58
QXmlStreamReader::TokenType token = xml.readNext ();
@@ -64,7 +72,8 @@ void XmlJoiner::processFile(const QString absolutePath)
64
72
65
73
if (xml.hasError ())
66
74
{
67
- throw std::runtime_error (" Error parsing the xml file " + absolutePath.toStdString ());
75
+ throw std::logic_error (" ProcessFile - Error parsing the xml file " +
76
+ absolutePath.toStdString ());
68
77
}
69
78
}
70
79
@@ -83,17 +92,11 @@ void XmlJoiner::processTestCaseAttrs(const QXmlStreamAttributes attrs)
83
92
84
93
if (attrs.hasAttribute (" status" )) // google tests case
85
94
{
86
- if (attrs.value (" status" ) != " run" )
87
- {
88
- valid = attrs.value (" status" ).toString ();
89
- }
95
+ // / \todo do specific stuff with google test xml file
90
96
}
91
97
else if (attrs.hasAttribute (" result" )) // qt tests case
92
98
{
93
- if (attrs.value (" result" ) != " pass" )
94
- {
95
- valid = attrs.value (" result" ).toString ();
96
- }
99
+ // / \todo do specific stuff with qtest xml file
97
100
}
98
101
99
102
TestSuite *suite = _suites.back ();
@@ -104,13 +107,8 @@ void XmlJoiner::processTestCaseAttrs(const QXmlStreamAttributes attrs)
104
107
void XmlJoiner::writeOutput (const QString pathFile)
105
108
{
106
109
QFile outFile (pathFile);
107
-
108
110
if (!outFile.open (QIODevice::WriteOnly | QIODevice::Text))
109
- {
110
- qDebug () << " Error opening output file for writing" ;
111
- // / \todo throw exception and delete debug message
112
- exit (-1 );
113
- }
111
+ throw std::logic_error (" writeOutput - Invalid output file for writting the combined XML" );
114
112
115
113
QXmlStreamWriter xmlOut (&outFile);
116
114
outputXmlHeader (xmlOut);
0 commit comments