add build number to the automated test results

This commit is contained in:
NissimHadar 2018-09-08 21:27:21 -07:00
parent 543c1c9265
commit 4a702ed8d4
6 changed files with 97 additions and 23 deletions

View file

@ -44,7 +44,7 @@ bool Test::createTestResultsFolderPath(const QString& directory) {
return QDir().mkdir(_testResultsFolderPath); return QDir().mkdir(_testResultsFolderPath);
} }
void Test::zipAndDeleteTestResultsFolder() { QString Test::zipAndDeleteTestResultsFolder() {
QString zippedResultsFileName { _testResultsFolderPath + ".zip" }; QString zippedResultsFileName { _testResultsFolderPath + ".zip" };
QFileInfo fileInfo(zippedResultsFileName); QFileInfo fileInfo(zippedResultsFileName);
if (fileInfo.exists()) { if (fileInfo.exists()) {
@ -59,6 +59,8 @@ void Test::zipAndDeleteTestResultsFolder() {
//In all cases, for the next evaluation //In all cases, for the next evaluation
_testResultsFolderPath = ""; _testResultsFolderPath = "";
_index = 1; _index = 1;
return zippedResultsFileName;
} }
bool Test::compareImageLists() { bool Test::compareImageLists() {
@ -264,14 +266,14 @@ void Test::finishTestsEvaluation() {
} }
} }
zipAndDeleteTestResultsFolder(); QString zippedFolderName = zipAndDeleteTestResultsFolder();
if (_exitWhenComplete) { if (_exitWhenComplete) {
exit(0); exit(0);
} }
if (_isRunningInAutomaticTestRun) { if (_isRunningInAutomaticTestRun) {
autoTester->automaticTestRunEvaluationComplete(); autoTester->automaticTestRunEvaluationComplete(zippedFolderName);
} }
} }

View file

@ -86,7 +86,7 @@ public:
void appendTestResultsToFile(const QString& testResultsFolderPath, TestFailure testFailure, QPixmap comparisonImage); void appendTestResultsToFile(const QString& testResultsFolderPath, TestFailure testFailure, QPixmap comparisonImage);
bool createTestResultsFolderPath(const QString& directory); bool createTestResultsFolderPath(const QString& directory);
void zipAndDeleteTestResultsFolder(); QString zipAndDeleteTestResultsFolder();
static bool isAValidDirectory(const QString& pathname); static bool isAValidDirectory(const QString& pathname);
QString extractPathFromTestsDown(const QString& fullPath); QString extractPathFromTestsDown(const QString& fullPath);

View file

@ -16,7 +16,7 @@
#include "ui/AutoTester.h" #include "ui/AutoTester.h"
extern AutoTester* autoTester; extern AutoTester* autoTester;
TestRunner::TestRunner(QObject *parent) : QObject(parent) { TestRunner::TestRunner(QObject* parent) : QObject(parent) {
} }
void TestRunner::run() { void TestRunner::run() {
@ -30,14 +30,14 @@ void TestRunner::run() {
// This will be restored at the end of the tests // This will be restored at the end of the tests
saveExistingHighFidelityAppDataFolder(); saveExistingHighFidelityAppDataFolder();
// Download the latest High Fidelity installer // Download the latest High Fidelity installer and build XML.
QStringList urls; QStringList urls;
urls << INSTALLER_URL; urls << INSTALLER_URL << BUILD_XML_URL;
QStringList filenames; QStringList filenames;
filenames << INSTALLER_FILENAME; filenames << INSTALLER_FILENAME << BUILD_XML_FILENAME;
autoTester->downloadFiles(urls, _tempFolder, filenames, (void *)this); autoTester->downloadFiles(urls, _tempFolder, filenames, (void*)this);
// `installerDownloadComplete` will run after download has completed // `installerDownloadComplete` will run after download has completed
} }
@ -47,7 +47,7 @@ void TestRunner::installerDownloadComplete() {
killProcesses(); killProcesses();
runInstaller(); runInstaller();
createSnapshotFolder(); createSnapshotFolder();
startLocalServerProcesses(); startLocalServerProcesses();
@ -63,9 +63,9 @@ void TestRunner::runInstaller() {
// Qt cannot start an installation process using QProcess::start (Qt Bug 9761) // Qt cannot start an installation process using QProcess::start (Qt Bug 9761)
// To allow installation, the installer is run using the `system` command // To allow installation, the installer is run using the `system` command
QStringList arguments{ QStringList() << QString("/S") << QString("/D=") + QDir::toNativeSeparators(_installationFolder) }; QStringList arguments{ QStringList() << QString("/S") << QString("/D=") + QDir::toNativeSeparators(_installationFolder) };
QString installerFullPath = _tempFolder + "/" + INSTALLER_FILENAME; QString installerFullPath = _tempFolder + "/" + INSTALLER_FILENAME;
QString commandLine = QString commandLine =
QDir::toNativeSeparators(installerFullPath) + " /S /D=" + QDir::toNativeSeparators(_installationFolder); QDir::toNativeSeparators(installerFullPath) + " /S /D=" + QDir::toNativeSeparators(_installationFolder);
@ -88,7 +88,7 @@ void TestRunner::saveExistingHighFidelityAppDataFolder() {
} }
// Copy an "empty" AppData folder (i.e. no entities) // Copy an "empty" AppData folder (i.e. no entities)
copyFolder(QDir::currentPath() + "/AppDataHighFidelity", _appDataFolder.path()); copyFolder(QDir::currentPath() + "/AppDataHighFidelity", _appDataFolder.path());
} }
void TestRunner::restoreHighFidelityAppDataFolder() { void TestRunner::restoreHighFidelityAppDataFolder() {
@ -106,8 +106,8 @@ void TestRunner::selectTemporaryFolder() {
parent += "/"; parent += "/";
} }
_tempFolder = _tempFolder = QFileDialog::getExistingDirectory(nullptr, "Please select a temporary folder for installation", parent,
QFileDialog::getExistingDirectory(nullptr, "Please select a temporary folder for installation", parent, QFileDialog::ShowDirsOnly); QFileDialog::ShowDirsOnly);
// If user canceled then restore previous selection and return // If user canceled then restore previous selection and return
if (_tempFolder == "") { if (_tempFolder == "") {
@ -168,9 +168,9 @@ void TestRunner::startLocalServerProcesses() {
void TestRunner::runInterfaceWithTestScript() { void TestRunner::runInterfaceWithTestScript() {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
QString commandLine = QString("\"") + QDir::toNativeSeparators(_installationFolder) + QString commandLine = QString("\"") + QDir::toNativeSeparators(_installationFolder) +
"\\interface.exe\" --url hifi://localhost --testScript https://raw.githubusercontent.com/" + _user + "\\interface.exe\" --url hifi://localhost --testScript https://raw.githubusercontent.com/" + _user +
"/hifi_tests/" + _branch + "/tests/testRecursive.js quitWhenFinished --testResultsLocation " + "/hifi_tests/" + _branch + "/tests/testRecursive.js quitWhenFinished --testResultsLocation " +
_snapshotFolder; _snapshotFolder;
system(commandLine.toStdString().c_str()); system(commandLine.toStdString().c_str());
#endif #endif
@ -180,10 +180,78 @@ void TestRunner::evaluateResults() {
autoTester->startTestsEvaluation(false, true, _snapshotFolder, _branch, _user); autoTester->startTestsEvaluation(false, true, _snapshotFolder, _branch, _user);
} }
void TestRunner::automaticTestRunEvaluationComplete() { void TestRunner::automaticTestRunEvaluationComplete(QString zippedFolder) {
addBuildNumberToResults(zippedFolder);
restoreHighFidelityAppDataFolder(); restoreHighFidelityAppDataFolder();
} }
void TestRunner::addBuildNumberToResults(QString zippedFolderName) {
try {
QDomDocument domDocument;
QString filename{ _tempFolder + "/" + BUILD_XML_FILENAME };
QFile file(filename);
if (!file.open(QIODevice::ReadOnly) || !domDocument.setContent(&file)) {
throw QString("Could not open " + filename);
}
QString platformOfInterest;
#ifdef Q_OS_WIN
platformOfInterest = "windows";
#else if Q_OS_MAC
platformOfInterest = "mac";
#endif
QDomElement element = domDocument.documentElement();
// Verify first element is "projects"
if (element.tagName() != "projects") {
throw("File seems to be in wrong format");
}
element = element.firstChild().toElement();
if (element.tagName() != "project") {
throw("File seems to be in wrong format");
}
if (element.attribute("name") != "interface") {
throw("File is not from 'interface' build");
}
// Now loop over the platforms
while (!element.isNull()) {
element = element.firstChild().toElement();
QString sdf = element.tagName();
if (element.tagName() != "platform" || element.attribute("name") != platformOfInterest) {
continue;
}
// Next element should be the build
element = element.firstChild().toElement();
if (element.tagName() != "build") {
throw("File seems to be in wrong format");
}
// Next element should be the version
element = element.firstChild().toElement();
if (element.tagName() != "version") {
throw("File seems to be in wrong format");
}
// Add the build number to the end of the filename
QString build = element.text();
QStringList filenameParts = zippedFolderName.split(".");
QString augmentedFilename = filenameParts[0] + "_" + build + "." + filenameParts[1];
QFile::rename(zippedFolderName, augmentedFilename);
}
} catch (QString errorMessage) {
QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), errorMessage);
exit(-1);
} catch (...) {
QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "unknown error");
exit(-1);
}
}
// Copies a folder recursively // Copies a folder recursively
void TestRunner::copyFolder(const QString& source, const QString& destination) { void TestRunner::copyFolder(const QString& source, const QString& destination) {
try { try {

View file

@ -35,7 +35,8 @@ public:
void startLocalServerProcesses(); void startLocalServerProcesses();
void runInterfaceWithTestScript(); void runInterfaceWithTestScript();
void evaluateResults(); void evaluateResults();
void automaticTestRunEvaluationComplete(); void automaticTestRunEvaluationComplete(QString zippedFolderName);
void addBuildNumberToResults(QString zippedFolderName);
void copyFolder(const QString& source, const QString& destination); void copyFolder(const QString& source, const QString& destination);
@ -56,6 +57,9 @@ private:
const QString INSTALLER_URL{ "http://builds.highfidelity.com/HighFidelity-Beta-latest-dev.exe" }; const QString INSTALLER_URL{ "http://builds.highfidelity.com/HighFidelity-Beta-latest-dev.exe" };
const QString INSTALLER_FILENAME{ "HighFidelity-Beta-latest-dev.exe" }; const QString INSTALLER_FILENAME{ "HighFidelity-Beta-latest-dev.exe" };
const QString BUILD_XML_URL{ "https://highfidelity.com/dev-builds.xml" };
const QString BUILD_XML_FILENAME{ "dev-builds.xml" };
QString _branch; QString _branch;
QString _user; QString _user;
}; };

View file

@ -107,8 +107,8 @@ void AutoTester::on_runNowButton_clicked() {
_testRunner->run(); _testRunner->run();
} }
void AutoTester::automaticTestRunEvaluationComplete() { void AutoTester::automaticTestRunEvaluationComplete(QString zippedFolderName) {
_testRunner->automaticTestRunEvaluationComplete(); _testRunner->automaticTestRunEvaluationComplete(zippedFolderName);
} }
void AutoTester::on_updateTestRailRunResultsButton_clicked() { void AutoTester::on_updateTestRailRunResultsButton_clicked() {

View file

@ -36,7 +36,7 @@ public:
const QString& branch, const QString& branch,
const QString& user); const QString& user);
void automaticTestRunEvaluationComplete(); void automaticTestRunEvaluationComplete(QString zippedFolderName);
void downloadFile(const QUrl& url); void downloadFile(const QUrl& url);
void downloadFiles(const QStringList& URLs, const QString& directoryName, const QStringList& filenames, void *caller); void downloadFiles(const QStringList& URLs, const QString& directoryName, const QStringList& filenames, void *caller);