mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 06:17:38 +02:00
add build number to the automated test results
This commit is contained in:
parent
543c1c9265
commit
4a702ed8d4
6 changed files with 97 additions and 23 deletions
|
@ -44,7 +44,7 @@ bool Test::createTestResultsFolderPath(const QString& directory) {
|
|||
return QDir().mkdir(_testResultsFolderPath);
|
||||
}
|
||||
|
||||
void Test::zipAndDeleteTestResultsFolder() {
|
||||
QString Test::zipAndDeleteTestResultsFolder() {
|
||||
QString zippedResultsFileName { _testResultsFolderPath + ".zip" };
|
||||
QFileInfo fileInfo(zippedResultsFileName);
|
||||
if (fileInfo.exists()) {
|
||||
|
@ -59,6 +59,8 @@ void Test::zipAndDeleteTestResultsFolder() {
|
|||
//In all cases, for the next evaluation
|
||||
_testResultsFolderPath = "";
|
||||
_index = 1;
|
||||
|
||||
return zippedResultsFileName;
|
||||
}
|
||||
|
||||
bool Test::compareImageLists() {
|
||||
|
@ -264,14 +266,14 @@ void Test::finishTestsEvaluation() {
|
|||
}
|
||||
}
|
||||
|
||||
zipAndDeleteTestResultsFolder();
|
||||
QString zippedFolderName = zipAndDeleteTestResultsFolder();
|
||||
|
||||
if (_exitWhenComplete) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (_isRunningInAutomaticTestRun) {
|
||||
autoTester->automaticTestRunEvaluationComplete();
|
||||
autoTester->automaticTestRunEvaluationComplete(zippedFolderName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ public:
|
|||
void appendTestResultsToFile(const QString& testResultsFolderPath, TestFailure testFailure, QPixmap comparisonImage);
|
||||
|
||||
bool createTestResultsFolderPath(const QString& directory);
|
||||
void zipAndDeleteTestResultsFolder();
|
||||
QString zipAndDeleteTestResultsFolder();
|
||||
|
||||
static bool isAValidDirectory(const QString& pathname);
|
||||
QString extractPathFromTestsDown(const QString& fullPath);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "ui/AutoTester.h"
|
||||
extern AutoTester* autoTester;
|
||||
|
||||
TestRunner::TestRunner(QObject *parent) : QObject(parent) {
|
||||
TestRunner::TestRunner(QObject* parent) : QObject(parent) {
|
||||
}
|
||||
|
||||
void TestRunner::run() {
|
||||
|
@ -30,14 +30,14 @@ void TestRunner::run() {
|
|||
// This will be restored at the end of the tests
|
||||
saveExistingHighFidelityAppDataFolder();
|
||||
|
||||
// Download the latest High Fidelity installer
|
||||
// Download the latest High Fidelity installer and build XML.
|
||||
QStringList urls;
|
||||
urls << INSTALLER_URL;
|
||||
urls << INSTALLER_URL << BUILD_XML_URL;
|
||||
|
||||
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
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ void TestRunner::installerDownloadComplete() {
|
|||
killProcesses();
|
||||
|
||||
runInstaller();
|
||||
|
||||
|
||||
createSnapshotFolder();
|
||||
|
||||
startLocalServerProcesses();
|
||||
|
@ -63,9 +63,9 @@ void TestRunner::runInstaller() {
|
|||
// Qt cannot start an installation process using QProcess::start (Qt Bug 9761)
|
||||
// To allow installation, the installer is run using the `system` command
|
||||
QStringList arguments{ QStringList() << QString("/S") << QString("/D=") + QDir::toNativeSeparators(_installationFolder) };
|
||||
|
||||
|
||||
QString installerFullPath = _tempFolder + "/" + INSTALLER_FILENAME;
|
||||
|
||||
|
||||
QString commandLine =
|
||||
QDir::toNativeSeparators(installerFullPath) + " /S /D=" + QDir::toNativeSeparators(_installationFolder);
|
||||
|
||||
|
@ -88,7 +88,7 @@ void TestRunner::saveExistingHighFidelityAppDataFolder() {
|
|||
}
|
||||
|
||||
// Copy an "empty" AppData folder (i.e. no entities)
|
||||
copyFolder(QDir::currentPath() + "/AppDataHighFidelity", _appDataFolder.path());
|
||||
copyFolder(QDir::currentPath() + "/AppDataHighFidelity", _appDataFolder.path());
|
||||
}
|
||||
|
||||
void TestRunner::restoreHighFidelityAppDataFolder() {
|
||||
|
@ -106,8 +106,8 @@ void TestRunner::selectTemporaryFolder() {
|
|||
parent += "/";
|
||||
}
|
||||
|
||||
_tempFolder =
|
||||
QFileDialog::getExistingDirectory(nullptr, "Please select a temporary folder for installation", parent, QFileDialog::ShowDirsOnly);
|
||||
_tempFolder = QFileDialog::getExistingDirectory(nullptr, "Please select a temporary folder for installation", parent,
|
||||
QFileDialog::ShowDirsOnly);
|
||||
|
||||
// If user canceled then restore previous selection and return
|
||||
if (_tempFolder == "") {
|
||||
|
@ -168,9 +168,9 @@ void TestRunner::startLocalServerProcesses() {
|
|||
void TestRunner::runInterfaceWithTestScript() {
|
||||
#ifdef Q_OS_WIN
|
||||
QString commandLine = QString("\"") + QDir::toNativeSeparators(_installationFolder) +
|
||||
"\\interface.exe\" --url hifi://localhost --testScript https://raw.githubusercontent.com/" + _user +
|
||||
"/hifi_tests/" + _branch + "/tests/testRecursive.js quitWhenFinished --testResultsLocation " +
|
||||
_snapshotFolder;
|
||||
"\\interface.exe\" --url hifi://localhost --testScript https://raw.githubusercontent.com/" + _user +
|
||||
"/hifi_tests/" + _branch + "/tests/testRecursive.js quitWhenFinished --testResultsLocation " +
|
||||
_snapshotFolder;
|
||||
|
||||
system(commandLine.toStdString().c_str());
|
||||
#endif
|
||||
|
@ -180,10 +180,78 @@ void TestRunner::evaluateResults() {
|
|||
autoTester->startTestsEvaluation(false, true, _snapshotFolder, _branch, _user);
|
||||
}
|
||||
|
||||
void TestRunner::automaticTestRunEvaluationComplete() {
|
||||
void TestRunner::automaticTestRunEvaluationComplete(QString zippedFolder) {
|
||||
addBuildNumberToResults(zippedFolder);
|
||||
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
|
||||
void TestRunner::copyFolder(const QString& source, const QString& destination) {
|
||||
try {
|
||||
|
|
|
@ -35,7 +35,8 @@ public:
|
|||
void startLocalServerProcesses();
|
||||
void runInterfaceWithTestScript();
|
||||
void evaluateResults();
|
||||
void automaticTestRunEvaluationComplete();
|
||||
void automaticTestRunEvaluationComplete(QString zippedFolderName);
|
||||
void addBuildNumberToResults(QString zippedFolderName);
|
||||
|
||||
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_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 _user;
|
||||
};
|
||||
|
|
|
@ -107,8 +107,8 @@ void AutoTester::on_runNowButton_clicked() {
|
|||
_testRunner->run();
|
||||
}
|
||||
|
||||
void AutoTester::automaticTestRunEvaluationComplete() {
|
||||
_testRunner->automaticTestRunEvaluationComplete();
|
||||
void AutoTester::automaticTestRunEvaluationComplete(QString zippedFolderName) {
|
||||
_testRunner->automaticTestRunEvaluationComplete(zippedFolderName);
|
||||
}
|
||||
|
||||
void AutoTester::on_updateTestRailRunResultsButton_clicked() {
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
const QString& branch,
|
||||
const QString& user);
|
||||
|
||||
void automaticTestRunEvaluationComplete();
|
||||
void automaticTestRunEvaluationComplete(QString zippedFolderName);
|
||||
|
||||
void downloadFile(const QUrl& url);
|
||||
void downloadFiles(const QStringList& URLs, const QString& directoryName, const QStringList& filenames, void *caller);
|
||||
|
|
Loading…
Reference in a new issue