Running all night.

This commit is contained in:
NissimHadar 2018-09-13 22:59:54 -07:00
parent 35eb019524
commit 46b00535c8
2 changed files with 43 additions and 25 deletions

View file

@ -33,11 +33,8 @@ TestRunner::TestRunner(std::vector<QCheckBox*> dayCheckboxes,
_timeEdits = timeEdits; _timeEdits = timeEdits;
_workingFolderLabel = workingFolderLabel; _workingFolderLabel = workingFolderLabel;
thread = new QThread(); installerThread = new QThread();
} interfaceThread = new QThread();
TestRunner::~TestRunner() {
disconnect(_timer, SIGNAL(timeout()), this, SLOT(checkTime()));
} }
void TestRunner::setWorkingFolder() { void TestRunner::setWorkingFolder() {
@ -95,11 +92,11 @@ void TestRunner::run() {
} }
void TestRunner::installerDownloadComplete() { void TestRunner::installerDownloadComplete() {
appendLog(QString("Test started at ") + QString::number(_testStartDateTime.time().hour()) + ":" + appendLog(QString("Tests started at ") + QString::number(_testStartDateTime.time().hour()) + ":" +
QString("%1").arg(_testStartDateTime.time().minute(), 2, 10, QChar('0')) + ", on " + QString("%1").arg(_testStartDateTime.time().minute(), 2, 10, QChar('0')) + ", on " +
_testStartDateTime.date().toString("ddd, MMM d, yyyy")); _testStartDateTime.date().toString("ddd, MMM d, yyyy"));
updateStatusLabel("Installing"); updateStatusLabel("Installing");
// Kill any existing processes that would interfere with installation // Kill any existing processes that would interfere with installation
killProcesses(); killProcesses();
@ -118,30 +115,25 @@ void TestRunner::runInstaller() {
QString commandLine = QString commandLine =
QDir::toNativeSeparators(installerFullPath) + " /S /D=" + QDir::toNativeSeparators(_installationFolder); QDir::toNativeSeparators(installerFullPath) + " /S /D=" + QDir::toNativeSeparators(_installationFolder);
worker = new Worker(commandLine); worker = new Worker(commandLine);
worker->moveToThread(thread);
connect(worker, SIGNAL(error(QString)), this, SLOT(errorString(QString))); worker->moveToThread(installerThread);
connect(thread, SIGNAL(started()), worker, SLOT(process())); connect(installerThread, SIGNAL(started()), worker, SLOT(process()));
connect(worker, SIGNAL(finished()), this, SLOT(installationComplete())); connect(worker, SIGNAL(finished()), this, SLOT(installationComplete()));
connect(worker, SIGNAL(finished()), thread, SLOT(quit())); installerThread->start();
connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater()));
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
thread->start();
} }
void TestRunner::installationComplete() { void TestRunner::installationComplete() {
disconnect(installerThread, SIGNAL(started()), worker, SLOT(process()));
disconnect(worker, SIGNAL(finished()), this, SLOT(installationComplete()));
delete worker;
createSnapshotFolder(); createSnapshotFolder();
updateStatusLabel("Running tests"); updateStatusLabel("Running tests");
startLocalServerProcesses(); startLocalServerProcesses();
runInterfaceWithTestScript(); runInterfaceWithTestScript();
killProcesses();
evaluateResults();
// The High Fidelity AppData folder will be restored after evaluation has completed
} }
void TestRunner::saveExistingHighFidelityAppDataFolder() { void TestRunner::saveExistingHighFidelityAppDataFolder() {
@ -247,14 +239,29 @@ void TestRunner::startLocalServerProcesses() {
} }
void TestRunner::runInterfaceWithTestScript() { void TestRunner::runInterfaceWithTestScript() {
#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()); worker = new Worker(commandLine);
#endif
worker->moveToThread(interfaceThread);
connect(interfaceThread, SIGNAL(started()), worker, SLOT(process()));
connect(worker, SIGNAL(finished()), this, SLOT(interfaceExecutionComplete()));
interfaceThread->start();
}
void TestRunner::interfaceExecutionComplete() {
disconnect(interfaceThread, SIGNAL(started()), worker, SLOT(process()));
disconnect(worker, SIGNAL(finished()), this, SLOT(interfaceExecutionComplete()));
delete worker;
killProcesses();
evaluateResults();
// The High Fidelity AppData folder will be restored after evaluation has completed
} }
void TestRunner::evaluateResults() { void TestRunner::evaluateResults() {
@ -267,6 +274,13 @@ void TestRunner::automaticTestRunEvaluationComplete(QString zippedFolder) {
restoreHighFidelityAppDataFolder(); restoreHighFidelityAppDataFolder();
updateStatusLabel("Testing complete"); updateStatusLabel("Testing complete");
QDateTime currentDateTime = QDateTime::currentDateTime();
appendLog(QString("Tests completed at ") + QString::number(currentDateTime.time().hour()) + ":" +
QString("%1").arg(currentDateTime.time().minute(), 2, 10, QChar('0')) + ", on " +
currentDateTime.date().toString("ddd, MMM d, yyyy"));
_automatedTestIsRunning = false; _automatedTestIsRunning = false;
} }

View file

@ -29,7 +29,6 @@ public:
std::vector<QTimeEdit*> timeEdits, std::vector<QTimeEdit*> timeEdits,
QLabel* workingFolderLabel, QLabel* workingFolderLabel,
QObject* parent = 0); QObject* parent = 0);
~TestRunner();
void setWorkingFolder(); void setWorkingFolder();
@ -42,9 +41,12 @@ public:
void restoreHighFidelityAppDataFolder(); void restoreHighFidelityAppDataFolder();
void createSnapshotFolder(); void createSnapshotFolder();
void killProcesses(); void killProcesses();
void startLocalServerProcesses(); void startLocalServerProcesses();
void runInterfaceWithTestScript(); void runInterfaceWithTestScript();
void evaluateResults(); void evaluateResults();
void automaticTestRunEvaluationComplete(QString zippedFolderName); void automaticTestRunEvaluationComplete(QString zippedFolderName);
void addBuildNumberToResults(QString zippedFolderName); void addBuildNumberToResults(QString zippedFolderName);
@ -57,6 +59,7 @@ public:
private slots: private slots:
void checkTime(); void checkTime();
void installationComplete(); void installationComplete();
void interfaceExecutionComplete();
private: private:
bool _automatedTestIsRunning{ false }; bool _automatedTestIsRunning{ false };
@ -91,7 +94,8 @@ private:
QDateTime _testStartDateTime; QDateTime _testStartDateTime;
QThread* thread; QThread* installerThread;
QThread* interfaceThread;
Worker* worker; Worker* worker;
}; };