[gtest-runner-qt] r17 committed - Completed the parser definition....

4 views
Skip to first unread message

gtest-r...@googlecode.com

unread,
Jul 27, 2010, 7:51:48 PM7/27/10
to gtest-r...@googlegroups.com
Revision: 17
Author: sandychapman
Date: Tue Jul 27 16:50:43 2010
Log: Completed the parser definition.
Hooked up parser to test runner.
Parser now creates test result objects and populates their fields.
Next step is to have them read into the tree!

http://code.google.com/p/gtest-runner-qt/source/detail?r=17

Modified:
/trunk/GTestRunner.pro
/trunk/Makefile
/trunk/Makefile.Debug
/trunk/Makefile.Release
/trunk/include/GTestExecutable.h
/trunk/include/GTestExecutableResults.h
/trunk/src/GTestExecutable.cpp
/trunk/src/GTestExecutableResults.cpp
/trunk/src/GTestParser.cpp

=======================================
--- /trunk/GTestRunner.pro Tue Jul 27 15:12:07 2010
+++ /trunk/GTestRunner.pro Tue Jul 27 16:50:43 2010
@@ -2,14 +2,20 @@
TARGET = GTestRunner
QT += core \
gui
-HEADERS += include/GTestSuite.h \
+HEADERS += include/GTestCollectionResults.h \
+ include/GTestSuiteResults.h \
+ include/GTestResults.h \
+ include/GTestSuite.h \
include/Defines.h \
include/GTestExecutableResults.h \
include/GTest.h \
include/GTestExecutable.h \
include/GTestParser.h \
include/GTestRunner.h
-SOURCES += src/GTestSuite.cpp \
+SOURCES += src/GTestResults.cpp \
+ src/GTestCollectionResults.cpp \
+ src/GTestSuiteResults.cpp \
+ src/GTestSuite.cpp \
src/GTestExecutableResults.cpp \
src/GTest.cpp \
src/GTestExecutable.cpp \
=======================================
--- /trunk/Makefile Tue Jul 27 15:12:07 2010
+++ /trunk/Makefile Tue Jul 27 16:50:43 2010
@@ -1,6 +1,6 @@

#############################################################################
# Makefile for building: GTestRunner
-# Generated by qmake (2.01a) (Qt 4.6.2) on: Tue Jul 27 19:11:00 2010
+# Generated by qmake (2.01a) (Qt 4.6.2) on: Tue Jul 27 20:05:17 2010
# Project: GTestRunner.pro
# Template: app
# Command: /usr/local/Trolltech/Qt-4.6.2/bin/qmake -unix
CONFIG+=debug_and_release -o Makefile GTestRunner.pro
=======================================
--- /trunk/Makefile.Debug Tue Jul 27 15:12:07 2010
+++ /trunk/Makefile.Debug Tue Jul 27 16:50:43 2010
@@ -1,6 +1,6 @@

#############################################################################
# Makefile for building: GTestRunner
-# Generated by qmake (2.01a) (Qt 4.6.2) on: Tue Jul 27 19:11:00 2010
+# Generated by qmake (2.01a) (Qt 4.6.2) on: Tue Jul 27 20:05:17 2010
# Project: GTestRunner.pro
# Template: app

#############################################################################
@@ -42,7 +42,10 @@

####### Files

-SOURCES = src/GTestSuite.cpp \
+SOURCES = src/GTestResults.cpp \
+ src/GTestCollectionResults.cpp \
+ src/GTestSuiteResults.cpp \
+ src/GTestSuite.cpp \
src/GTestExecutableResults.cpp \
src/GTest.cpp \
src/GTestExecutable.cpp \
@@ -52,7 +55,10 @@
debug/moc_GTest.cpp \
debug/moc_GTestExecutable.cpp \
debug/moc_GTestRunner.cpp
-OBJECTS = debug/GTestSuite.o \
+OBJECTS = debug/GTestResults.o \
+ debug/GTestCollectionResults.o \
+ debug/GTestSuiteResults.o \
+ debug/GTestSuite.o \
debug/GTestExecutableResults.o \
debug/GTest.o \
debug/GTestExecutable.o \
@@ -121,7 +127,7 @@

dist:
@$(CHK_DIR_EXISTS) debug/GTestRunner1.0.0 || $(MKDIR)
debug/GTestRunner1.0.0
- $(COPY_FILE) --parents $(SOURCES) $(DIST) debug/GTestRunner1.0.0/ &&
$(COPY_FILE) --parents include/GTestSuite.h include/Defines.h
include/GTestExecutableResults.h include/GTest.h include/GTestExecutable.h
include/GTestParser.h include/GTestRunner.h debug/GTestRunner1.0.0/ &&
$(COPY_FILE) --parents src/GTestSuite.cpp src/GTestExecutableResults.cpp
src/GTest.cpp src/GTestExecutable.cpp main.cpp src/GTestParser.cpp
src/GTestRunner.cpp debug/GTestRunner1.0.0/ && (cd `dirname
debug/GTestRunner1.0.0` && $(TAR) GTestRunner1.0.0.tar GTestRunner1.0.0 &&
$(COMPRESS) GTestRunner1.0.0.tar) && $(MOVE) `dirname
debug/GTestRunner1.0.0`/GTestRunner1.0.0.tar.gz . && $(DEL_FILE) -r
debug/GTestRunner1.0.0
+ $(COPY_FILE) --parents $(SOURCES) $(DIST) debug/GTestRunner1.0.0/ &&
$(COPY_FILE) --parents include/GTestCollectionResults.h
include/GTestSuiteResults.h include/GTestResults.h include/GTestSuite.h
include/Defines.h include/GTestExecutableResults.h include/GTest.h
include/GTestExecutable.h include/GTestParser.h include/GTestRunner.h
debug/GTestRunner1.0.0/ && $(COPY_FILE) --parents src/GTestResults.cpp
src/GTestCollectionResults.cpp src/GTestSuiteResults.cpp src/GTestSuite.cpp
src/GTestExecutableResults.cpp src/GTest.cpp src/GTestExecutable.cpp
main.cpp src/GTestParser.cpp src/GTestRunner.cpp debug/GTestRunner1.0.0/ &&
(cd `dirname debug/GTestRunner1.0.0` && $(TAR) GTestRunner1.0.0.tar
GTestRunner1.0.0 && $(COMPRESS) GTestRunner1.0.0.tar) && $(MOVE) `dirname
debug/GTestRunner1.0.0`/GTestRunner1.0.0.tar.gz . && $(DEL_FILE) -r
debug/GTestRunner1.0.0


clean:compiler_clean
@@ -150,10 +156,14 @@
debug/moc_GTest.cpp: include/GTest.h
/usr/local/Trolltech/Qt-4.6.2/bin/moc $(DEFINES) $(INCPATH)
include/GTest.h -o debug/moc_GTest.cpp

-debug/moc_GTestExecutable.cpp: include/GTestExecutable.h
+debug/moc_GTestExecutable.cpp: include/GTestSuite.h \
+ include/GTest.h \
+ include/GTestExecutable.h
/usr/local/Trolltech/Qt-4.6.2/bin/moc $(DEFINES) $(INCPATH)
include/GTestExecutable.h -o debug/moc_GTestExecutable.cpp

debug/moc_GTestRunner.cpp: include/GTestExecutable.h \
+ include/GTestSuite.h \
+ include/GTest.h \
include/GTestRunner.h
/usr/local/Trolltech/Qt-4.6.2/bin/moc $(DEFINES) $(INCPATH)
include/GTestRunner.h -o debug/moc_GTestRunner.cpp

@@ -176,6 +186,15 @@

####### Compile

+debug/GTestResults.o: src/GTestResults.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/GTestResults.o
src/GTestResults.cpp
+
+debug/GTestCollectionResults.o: src/GTestCollectionResults.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/GTestCollectionResults.o
src/GTestCollectionResults.cpp
+
+debug/GTestSuiteResults.o: src/GTestSuiteResults.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/GTestSuiteResults.o
src/GTestSuiteResults.cpp
+
debug/GTestSuite.o: src/GTestSuite.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/GTestSuite.o src/GTestSuite.cpp

=======================================
--- /trunk/Makefile.Release Tue Jul 27 15:12:07 2010
+++ /trunk/Makefile.Release Tue Jul 27 16:50:43 2010
@@ -1,6 +1,6 @@

#############################################################################
# Makefile for building: GTestRunner
-# Generated by qmake (2.01a) (Qt 4.6.2) on: Tue Jul 27 19:11:00 2010
+# Generated by qmake (2.01a) (Qt 4.6.2) on: Tue Jul 27 20:05:17 2010
# Project: GTestRunner.pro
# Template: app

#############################################################################
@@ -42,7 +42,10 @@

####### Files

-SOURCES = src/GTestSuite.cpp \
+SOURCES = src/GTestResults.cpp \
+ src/GTestCollectionResults.cpp \
+ src/GTestSuiteResults.cpp \
+ src/GTestSuite.cpp \
src/GTestExecutableResults.cpp \
src/GTest.cpp \
src/GTestExecutable.cpp \
@@ -52,7 +55,10 @@
release/moc_GTest.cpp \
release/moc_GTestExecutable.cpp \
release/moc_GTestRunner.cpp
-OBJECTS = release/GTestSuite.o \
+OBJECTS = release/GTestResults.o \
+ release/GTestCollectionResults.o \
+ release/GTestSuiteResults.o \
+ release/GTestSuite.o \
release/GTestExecutableResults.o \
release/GTest.o \
release/GTestExecutable.o \
@@ -121,7 +127,7 @@

dist:
@$(CHK_DIR_EXISTS) release/GTestRunner1.0.0 || $(MKDIR)
release/GTestRunner1.0.0
- $(COPY_FILE) --parents $(SOURCES) $(DIST) release/GTestRunner1.0.0/ &&
$(COPY_FILE) --parents include/GTestSuite.h include/Defines.h
include/GTestExecutableResults.h include/GTest.h include/GTestExecutable.h
include/GTestParser.h include/GTestRunner.h release/GTestRunner1.0.0/ &&
$(COPY_FILE) --parents src/GTestSuite.cpp src/GTestExecutableResults.cpp
src/GTest.cpp src/GTestExecutable.cpp main.cpp src/GTestParser.cpp
src/GTestRunner.cpp release/GTestRunner1.0.0/ && (cd `dirname
release/GTestRunner1.0.0` && $(TAR) GTestRunner1.0.0.tar GTestRunner1.0.0
&& $(COMPRESS) GTestRunner1.0.0.tar) && $(MOVE) `dirname
release/GTestRunner1.0.0`/GTestRunner1.0.0.tar.gz . && $(DEL_FILE) -r
release/GTestRunner1.0.0
+ $(COPY_FILE) --parents $(SOURCES) $(DIST) release/GTestRunner1.0.0/ &&
$(COPY_FILE) --parents include/GTestCollectionResults.h
include/GTestSuiteResults.h include/GTestResults.h include/GTestSuite.h
include/Defines.h include/GTestExecutableResults.h include/GTest.h
include/GTestExecutable.h include/GTestParser.h include/GTestRunner.h
release/GTestRunner1.0.0/ && $(COPY_FILE) --parents src/GTestResults.cpp
src/GTestCollectionResults.cpp src/GTestSuiteResults.cpp src/GTestSuite.cpp
src/GTestExecutableResults.cpp src/GTest.cpp src/GTestExecutable.cpp
main.cpp src/GTestParser.cpp src/GTestRunner.cpp release/GTestRunner1.0.0/
&& (cd `dirname release/GTestRunner1.0.0` && $(TAR) GTestRunner1.0.0.tar
GTestRunner1.0.0 && $(COMPRESS) GTestRunner1.0.0.tar) && $(MOVE) `dirname
release/GTestRunner1.0.0`/GTestRunner1.0.0.tar.gz . && $(DEL_FILE) -r
release/GTestRunner1.0.0


clean:compiler_clean
@@ -150,10 +156,14 @@
release/moc_GTest.cpp: include/GTest.h
/usr/local/Trolltech/Qt-4.6.2/bin/moc $(DEFINES) $(INCPATH)
include/GTest.h -o release/moc_GTest.cpp

-release/moc_GTestExecutable.cpp: include/GTestExecutable.h
+release/moc_GTestExecutable.cpp: include/GTestSuite.h \
+ include/GTest.h \
+ include/GTestExecutable.h
/usr/local/Trolltech/Qt-4.6.2/bin/moc $(DEFINES) $(INCPATH)
include/GTestExecutable.h -o release/moc_GTestExecutable.cpp

release/moc_GTestRunner.cpp: include/GTestExecutable.h \
+ include/GTestSuite.h \
+ include/GTest.h \
include/GTestRunner.h
/usr/local/Trolltech/Qt-4.6.2/bin/moc $(DEFINES) $(INCPATH)
include/GTestRunner.h -o release/moc_GTestRunner.cpp

@@ -176,6 +186,15 @@

####### Compile

+release/GTestResults.o: src/GTestResults.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/GTestResults.o
src/GTestResults.cpp
+
+release/GTestCollectionResults.o: src/GTestCollectionResults.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/GTestCollectionResults.o
src/GTestCollectionResults.cpp
+
+release/GTestSuiteResults.o: src/GTestSuiteResults.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/GTestSuiteResults.o
src/GTestSuiteResults.cpp
+
release/GTestSuite.o: src/GTestSuite.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/GTestSuite.o
src/GTestSuite.cpp

=======================================
--- /trunk/include/GTestExecutable.h Tue Jul 27 15:12:07 2010
+++ /trunk/include/GTestExecutable.h Tue Jul 27 16:50:43 2010
@@ -53,7 +53,6 @@
QProcess::ExitStatus exitStatus;
int exitCode;

- void setupExecutable();
void runExecutable(QStringList args);
void readExecutableOutput(QBuffer& standardChannel);

=======================================
--- /trunk/include/GTestExecutableResults.h Tue Jul 27 15:12:07 2010
+++ /trunk/include/GTestExecutableResults.h Tue Jul 27 16:50:43 2010
@@ -17,56 +17,26 @@
#ifndef GTESTEXECUTABLERESULTS_H_
#define GTESTEXECUTABLERESULTS_H_

+#include <QList>
#include <QString>

#include "Defines.h"
-
-class GTestExecutableResults {
+#include "GTestCollectionResults.h"
+#include "GTestSuiteResults.h"
+
+class GTestExecutableResults : public GTestCollectionResults {

private:
- QString exeName;
- uint numTests;
- uint numFailures;
- uint numErrors;
- uint totalTime;
+ QList<GTestSuiteResults*> suiteResultsList;

public:
GTestExecutableResults(QString name);
- void setTestRunCount(uint count);
- void setTestFailureCount(uint count);
- void setTestErrorCount(uint count);
- void setTestTotalTime(uint count);
- uint getTestRunCount();
- uint getTestFailureCount();
- uint getTestErrorCount();
- uint getTestTotalTime();
+ void addTestSuiteResults(GTestSuiteResults* testSuiteResults);

};

-inline void GTestExecutableResults::setTestRunCount(uint count) {
- numTests = count;
-}
-
-inline void GTestExecutableResults::setTestFailureCount(uint count) {
- numFailures = count;
-}
-
-inline void GTestExecutableResults::setTestErrorCount(uint count) {
- numErrors = count;
-}
-
-inline void GTestExecutableResults::setTestTotalTime(uint count) {
- totalTime = count;
-}
-
-inline uint GTestExecutableResults::getTestRunCount() { return numTests; }
-
-inline uint GTestExecutableResults::getTestFailureCount() { return
numFailures; }
-
-inline uint GTestExecutableResults::getTestErrorCount() { return
numErrors; }
-
-inline uint GTestExecutableResults::getTestTotalTime() { return totalTime;
}
-
-inline QString GTestExecutableResults::getTestName() { return exeName; }
+inline void GTestExecutableResults::addTestSuiteResults(GTestSuiteResults*
testSuiteResults) {
+ suiteResultsList.append(testSuiteResults);
+}

#endif /* GTESTEXECUTABLERESULTS_H_ */
=======================================
--- /trunk/src/GTestExecutable.cpp Tue Jul 27 15:12:07 2010
+++ /trunk/src/GTestExecutable.cpp Tue Jul 27 16:50:43 2010
@@ -15,6 +15,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * */

#include "GTestExecutable.h"
+#include "GTestParser.h"

#include <QDebug>
#include <QFile>
@@ -44,7 +45,11 @@
//or run a test will block until we're done with what we're
//doing here.
processLock.lock();
- setupExecutable();
+ gtest = new QProcess();
+ QObject::connect(gtest, SIGNAL(readyReadStandardOutput()),
+ this, SLOT(standardOutputAvailable()));
+ QObject::connect(gtest, SIGNAL(finished(int, QProcess::ExitStatus)),
+ this, SLOT(executableFinished(int, QProcess::ExitStatus)));
QObject::connect(gtest, SIGNAL(finished(int, QProcess::ExitStatus)),
this, SLOT(parseListing(int, QProcess::ExitStatus)));
gtest->start(filePath, QStringList() << "--gtest_list_tests");
@@ -75,30 +80,27 @@
//or run a test will block until we're done with what we're
//doing here.
processLock.lock();
- setupExecutable();
+ gtest = new QProcess();
+ QObject::connect(gtest, SIGNAL(readyReadStandardOutput()),
+ this, SLOT(standardOutputAvailable()));
QObject::connect(gtest, SIGNAL(finished(int, QProcess::ExitStatus)),
this, SLOT(parseTestResults(int, QProcess::ExitStatus)));
- gtest->start(filePath, QStringList() << "--gtest_output=xml");
+ gtest->start(filePath, QStringList()
<< "--gtest_output=xml:./test_detail_1337.xml");
//unlock the processLock in the parseTestResults slot
}

void GTestExecutable::parseTestResults(int exitCode, QProcess::ExitStatus
exitStatus) {
+ QObject::disconnect(gtest, SIGNAL(finished(int, QProcess::ExitStatus)),
+ this, SLOT(parseTestResults(int, QProcess::ExitStatus)));
processLock.unlock();
if(exitStatus != QProcess::NormalExit)
return;
-
+ QFile xmlFile("./test_detail_1337.xml");
+ GTestParser parser(&xmlFile);
+ parser.parse();
+ executableFinished(exitCode, exitStatus);
emit testResultsReady(this);
}
-
-void GTestExecutable::setupExecutable() {
- //Should we check and see if gtest is non-zero?
- //if(gtest != 0) {}
- gtest = new QProcess();
- QObject::connect(gtest, SIGNAL(readyReadStandardOutput()),
- this, SLOT(standardOutputAvailable()));
- QObject::connect(gtest, SIGNAL(finished(int, QProcess::ExitStatus)),
- this, SLOT(executableFinished(int, QProcess::ExitStatus)));
-}

void GTestExecutable::standardOutputAvailable() {
qDebug() << "std output available...";
=======================================
--- /trunk/src/GTestExecutableResults.cpp Mon Jul 26 15:58:53 2010
+++ /trunk/src/GTestExecutableResults.cpp Tue Jul 27 16:50:43 2010
@@ -17,5 +17,5 @@
#include "GTestExecutableResults.h"

GTestExecutableResults::GTestExecutableResults(QString name)
-: exeName(name)
+: GTestCollectionResults(name)
{}
=======================================
--- /trunk/src/GTestParser.cpp Mon Jul 26 15:58:53 2010
+++ /trunk/src/GTestParser.cpp Tue Jul 27 16:50:43 2010
@@ -14,6 +14,7 @@
* Boston, MA 02111-1307
USA *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * */

+#include <QDebug>
#include <QXmlStreamAttributes>
#include <QXmlStreamReader>

@@ -25,23 +26,46 @@
{}

void GTestParser::parse() {
+ xmlSource->open(QIODevice::ReadOnly);
+ xmlSource->seek(0);
QXmlStreamReader xmlStream(xmlSource);
QXmlStreamAttributes attributes;
- GTestExecutableResults *testResults;
+ GTestExecutableResults* testExeResults;
+ GTestSuiteResults* testSuiteResults;
+ GTestResults* testResults;
while(!xmlStream.atEnd()) {
- while(!xmlStream.readNextStartElement());
+ qDebug() << xmlStream.text();
+ while(!xmlStream.readNextStartElement() && !xmlStream.hasError()
&& !xmlStream.atEnd()) {
+ qDebug() << xmlStream.text();
+ }
+ qDebug() << xmlStream.text();
attributes = xmlStream.attributes();
- if(xmlStream.name() == "testcase")
- ;
+ if(xmlStream.name() == "testcase") {
+ testResults = new GTestResults(attributes.value("name").toString());
+
testResults->setRunningTime(attributes.value("time").toString().toUInt());
+ testResults->setStatus(attributes.value("status").toString());
+ while((xmlStream.readNext(), xmlStream.name()) == "failure") {
+ attributes = xmlStream.attributes();
+ testResults->addFailureMessage(attributes.value("message").toString());
+ }
+ }
else if(xmlStream.name() == "testsuite") {
-
+ testSuiteResults = new
GTestSuiteResults(attributes.value("name").toString());
+
testSuiteResults->setTestRunCount(attributes.value("tests").toString().toUInt());
+
testSuiteResults->setTestFailureCount(attributes.value("failures").toString().toUInt());
+
testSuiteResults->setTestErrorCount(attributes.value("errors").toString().toUInt());
+
testSuiteResults->setTestTotalTime(attributes.value("time").toString().toUInt());
+ testExeResults->addTestSuiteResults(testSuiteResults);
}
else if(xmlStream.name() == "testsuites") {
- testResults = new
GTestExecutableResults(attributes.value("name").toString());
-
testResults->setTestRunCount(attributes.value("tests").toString().toUInt());
-
testResults->setTestFailureCount(attributes.value("failures").toString().toUInt());
-
testResults->setTestErrorCount(attributes.value("errors").toString().toUInt());
-
testResults->setTestTotalTime(attributes.value("time").toString().toUInt());
+ testExeResults = new
GTestExecutableResults(attributes.value("name").toString());
+
testExeResults->setTestRunCount(attributes.value("tests").toString().toUInt());
+
testExeResults->setTestFailureCount(attributes.value("failures").toString().toUInt());
+
testExeResults->setTestErrorCount(attributes.value("errors").toString().toUInt());
+
testExeResults->setTestTotalTime(attributes.value("time").toString().toUInt());
+ }
+ if(xmlStream.hasError()) {
+ qDebug() << xmlStream.errorString();
}
}
}

Reply all
Reply to author
Forward
0 new messages