From a665e728e6af8978c2b3c49c054f13fbd04cf8d8 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Thu, 6 Dec 2018 09:52:21 -0800 Subject: [PATCH] Improved contents of the HTML results. --- tools/nitpick/src/AWSInterface.cpp | 121 ++++++++++++++++------------- tools/nitpick/src/AWSInterface.h | 4 +- 2 files changed, 68 insertions(+), 57 deletions(-) diff --git a/tools/nitpick/src/AWSInterface.cpp b/tools/nitpick/src/AWSInterface.cpp index 034feae7f9..0b93ce44e5 100644 --- a/tools/nitpick/src/AWSInterface.cpp +++ b/tools/nitpick/src/AWSInterface.cpp @@ -103,62 +103,8 @@ void AWSInterface::writeHead(QTextStream& stream) { void AWSInterface::writeBody(QTextStream& stream) { stream << "\t" << "\n"; - writeTitle(stream); - writeTable(stream); - stream << "\t" << "\n"; -} -void AWSInterface::finishHTMLpage(QTextStream& stream) { - stream << "\n"; -} - -void AWSInterface::writeTitle(QTextStream& stream) { - // Separate relevant components from the results name - // The expected format is as follows: `D:/tt/snapshots/TestResults--2018-10-04_11-09-41(PR14128)[DESKTOP-PMKNLSQ].zip` - QStringList tokens = _testResults.split('/'); - - // date_buildorPR_hostName will be 2018-10-03_15-35-28(9433)[DESKTOP-PMKNLSQ] - QString date_buildorPR_hostName = tokens[tokens.length() - 1].split("--")[1].split(".")[0]; - - QString buildorPR = date_buildorPR_hostName.split('(')[1].split(')')[0]; - QString hostName = date_buildorPR_hostName.split('[')[1].split(']')[0]; - - QStringList dateList = date_buildorPR_hostName.split('(')[0].split('_')[0].split('-'); - QString year = dateList[0]; - QString month = dateList[1]; - QString day = dateList[2]; - - QStringList timeList = date_buildorPR_hostName.split('(')[0].split('_')[1].split('-'); - QString hour = timeList[0]; - QString minute = timeList[1]; - QString second = timeList[2]; - - const QString months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; - - stream << "\t" << "\t" << "\n"; - stream << "\t" << "\t" << "

Failures for "; - stream << months[month.toInt() - 1] << " " << day << ", " << year << ", "; - stream << hour << ":" << minute << ":" << second << ", "; - - if (buildorPR.left(2) == "PR") { - stream << "PR " << buildorPR.right(buildorPR.length() - 2) << ", "; - } else { - stream << "build " << buildorPR << ", "; - } - - stream << "run on " << hostName << "

\n"; -} - -void AWSInterface::writeTable(QTextStream& stream) { - QString previousTestName{ "" }; - - // Loop over all entries in directory. This is done in stages, as the names are not in the order of the tests - // The first stage reads the directory names into a list - // The second stage renames the tests by removing everything up to "--tests." - // The third stage renames the directories - // The fourth and lasts stage creates the HTML entries - // - // Note that failures are processed first, then successes + // The results are read here as they are used both in the title (for the summary) and for table QStringList originalNamesFailures; QStringList originalNamesSuccesses; QDirIterator it1(_workingDirectory); @@ -185,6 +131,71 @@ void AWSInterface::writeTable(QTextStream& stream) { } } + writeTitle(stream, originalNamesFailures, originalNamesSuccesses); + writeTable(stream, originalNamesFailures, originalNamesSuccesses); + stream << "\t" << "\n"; +} + +void AWSInterface::finishHTMLpage(QTextStream& stream) { + stream << "\n"; +} + +void AWSInterface::writeTitle(QTextStream& stream, const QStringList& originalNamesFailures, const QStringList& originalNamesSuccesses) { + // Separate relevant components from the results name + // The expected format is as follows: `D:/tt/snapshots/TestResults--2018-10-04_11-09-41(PR14128)[DESKTOP-PMKNLSQ].zip` + QStringList tokens = _testResults.split('/'); + + // date_buildorPR_hostName will be 2018-10-03_15-35-28(9433)[DESKTOP-PMKNLSQ] + QString date_buildorPR_hostName = tokens[tokens.length() - 1].split("--")[1].split(".")[0]; + + QString buildorPR = date_buildorPR_hostName.split('(')[1].split(')')[0]; + QString hostName = date_buildorPR_hostName.split('[')[1].split(']')[0]; + + QStringList dateList = date_buildorPR_hostName.split('(')[0].split('_')[0].split('-'); + QString year = dateList[0]; + QString month = dateList[1]; + QString day = dateList[2]; + + QStringList timeList = date_buildorPR_hostName.split('(')[0].split('_')[1].split('-'); + QString hour = timeList[0]; + QString minute = timeList[1]; + QString second = timeList[2]; + + const QString months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; + + stream << "\t" << "\t" << "\n"; + stream << "\t" << "\t" << "

Results for "; + stream << months[month.toInt() - 1] << " " << day << ", " << year << ", "; + stream << hour << ":" << minute << ":" << second << ", "; + + if (buildorPR.left(2) == "PR") { + stream << "PR " << buildorPR.right(buildorPR.length() - 2) << ", "; + } else { + stream << "build " << buildorPR << ", "; + } + + stream << "run on " << hostName << "

\n"; + + int numberOfFailures = originalNamesFailures.length(); + int numberOfSuccesses = originalNamesSuccesses.length(); + + stream << "

" << QString::number(numberOfFailures) << " failed, out of a total of " << QString::number(numberOfSuccesses) << " tests

\n"; + + stream << "\t" << "\t" << "\n"; + stream << "\t" << "\t" << "

The following tests failed:

"; +} + +void AWSInterface::writeTable(QTextStream& stream, const QStringList& originalNamesFailures, const QStringList& originalNamesSuccesses) { + QString previousTestName{ "" }; + + // Loop over all entries in directory. This is done in stages, as the names are not in the order of the tests + // The first stage reads the directory names into a list + // The second stage renames the tests by removing everything up to "--tests." + // The third stage renames the directories + // The fourth and lasts stage creates the HTML entries + // + // Note that failures are processed first, then successes + QStringList newNamesFailures; for (int i = 0; i < originalNamesFailures.length(); ++i) { newNamesFailures.append(originalNamesFailures[i].split("--tests.")[1]); diff --git a/tools/nitpick/src/AWSInterface.h b/tools/nitpick/src/AWSInterface.h index 43d2240c19..fda250b115 100644 --- a/tools/nitpick/src/AWSInterface.h +++ b/tools/nitpick/src/AWSInterface.h @@ -38,8 +38,8 @@ public: void writeBody(QTextStream& stream); void finishHTMLpage(QTextStream& stream); - void writeTitle(QTextStream& stream); - void writeTable(QTextStream& stream); + void writeTitle(QTextStream& stream, const QStringList& originalNamesFailures, const QStringList& originalNamesSuccesses); + void writeTable(QTextStream& stream, const QStringList& originalNamesFailures, const QStringList& originalNamesSuccesses); void openTable(QTextStream& stream, const QString& testResult, const bool isFailure); void closeTable(QTextStream& stream);