mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 15:43:50 +02:00
Set user and branch, and request temporary folder at the beginning.
Kill processes BEFORE running the downloaded installerDownloadComplete Copy an empty, but valid, AppData/High Fidelity folder. Remove previous snapshots.
This commit is contained in:
parent
c4182a8146
commit
8a2292ce07
2 changed files with 76 additions and 19 deletions
|
@ -20,9 +20,17 @@ TestRunner::TestRunner(QObject *parent) : QObject(parent) {
|
|||
}
|
||||
|
||||
void TestRunner::run() {
|
||||
saveExistingHighFidelityAppDataFolder();
|
||||
// Initial setup
|
||||
_branch = autoTester->getSelectedBranch();
|
||||
_user = autoTester->getSelectedUser();
|
||||
|
||||
// Everything will be written to this folder
|
||||
selectTemporaryFolder();
|
||||
|
||||
// This will be restored at the end of the tests
|
||||
saveExistingHighFidelityAppDataFolder();
|
||||
|
||||
// Download the latest High Fidelity installer
|
||||
QStringList urls;
|
||||
urls << INSTALLER_URL;
|
||||
|
||||
|
@ -31,19 +39,23 @@ void TestRunner::run() {
|
|||
|
||||
autoTester->downloadFiles(urls, _tempFolder, filenames, (void *)this);
|
||||
|
||||
// After download has finished, `installerDownloadComplete` will run after download complete
|
||||
// `installerDownloadComplete` will run after download has completed
|
||||
}
|
||||
|
||||
void TestRunner::installerDownloadComplete() {
|
||||
runInstaller();
|
||||
createSnapshotFolder();
|
||||
// Kill any existing processes that would interfere with installation
|
||||
killProcesses();
|
||||
|
||||
runInstaller();
|
||||
|
||||
createSnapshotFolder();
|
||||
|
||||
startLocalServerProcesses();
|
||||
runInterfaceWithTestScript();
|
||||
killProcesses();
|
||||
|
||||
evaluateResults();
|
||||
|
||||
killProcesses();
|
||||
restoreHighFidelityAppDataFolder();
|
||||
}
|
||||
|
||||
|
@ -76,11 +88,13 @@ void TestRunner::saveExistingHighFidelityAppDataFolder() {
|
|||
// The original folder is saved in a unique name
|
||||
_savedAppDataFolder = dataDirectory + "/" + UNIQUE_FOLDER_NAME;
|
||||
_appDataFolder.rename(_appDataFolder.path(), _savedAppDataFolder.path());
|
||||
|
||||
// Copy an "empty" AppData folder (i.e. no entities)
|
||||
copyFolder(QDir::currentPath() + "/AppDataHighFidelity", _appDataFolder.path());
|
||||
}
|
||||
|
||||
void TestRunner::restoreHighFidelityAppDataFolder() {
|
||||
QDir().rmdir(_appDataFolder.path());
|
||||
|
||||
_appDataFolder.removeRecursively();
|
||||
_appDataFolder.rename(_savedAppDataFolder.path(), _appDataFolder.path());
|
||||
}
|
||||
|
||||
|
@ -103,7 +117,21 @@ void TestRunner::selectTemporaryFolder() {
|
|||
|
||||
void TestRunner::createSnapshotFolder() {
|
||||
_snapshotFolder = _tempFolder + "/" + SNAPSHOT_FOLDER_NAME;
|
||||
QDir().mkdir(_snapshotFolder);
|
||||
|
||||
// Just delete all PNGs from the folder if it already exists
|
||||
if (QDir(_snapshotFolder).exists()) {
|
||||
// Note that we cannot use just a `png` filter, as the filenames include periods
|
||||
QDirIterator it(_snapshotFolder.toStdString().c_str());
|
||||
while (it.hasNext()) {
|
||||
QString filename = it.next();
|
||||
if (filename.right(4) == ".png") {
|
||||
QFile::remove(filename);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
QDir().mkdir(_snapshotFolder);
|
||||
}
|
||||
}
|
||||
|
||||
void TestRunner::killProcesses() {
|
||||
|
@ -120,15 +148,13 @@ void TestRunner::killProcessByName(QString processName) {
|
|||
}
|
||||
|
||||
void TestRunner::startLocalServerProcesses() {
|
||||
QDir::setCurrent(_tempFolder);
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
QString commandLine;
|
||||
|
||||
commandLine = "start \"domain-server.exe\" domain-server.exe";
|
||||
commandLine = "start \"domain-server.exe\" " + QDir::toNativeSeparators(_tempFolder) + "\\domain-server.exe";
|
||||
system(commandLine.toStdString().c_str());
|
||||
|
||||
commandLine = "start \"assignment-client.exe\" assignment-client.exe -n 6";
|
||||
commandLine = "start \"assignment-client.exe\" " + QDir::toNativeSeparators(_tempFolder) + "\\assignment-client.exe -n 6";
|
||||
system(commandLine.toStdString().c_str());
|
||||
#endif
|
||||
// Give server processes time to stabilize
|
||||
|
@ -136,14 +162,11 @@ void TestRunner::startLocalServerProcesses() {
|
|||
}
|
||||
|
||||
void TestRunner::runInterfaceWithTestScript() {
|
||||
QDir::setCurrent(_tempFolder);
|
||||
_branch = autoTester->getSelectedBranch();
|
||||
_user = autoTester->getSelectedUser();
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
QString commandLine = "interface.exe --url hifi://localhost --testScript https://raw.githubusercontent.com/" + _user +
|
||||
"/hifi_tests/" + _branch + "/tests/testRecursive.js quitWhenFinished --testResultsLocation " +
|
||||
_snapshotFolder;
|
||||
QString commandLine = QDir::toNativeSeparators(_tempFolder) +
|
||||
"\\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
|
||||
|
@ -152,3 +175,35 @@ void TestRunner::runInterfaceWithTestScript() {
|
|||
void TestRunner::evaluateResults() {
|
||||
autoTester->runFromCommandLine(_snapshotFolder, _branch, _user);
|
||||
}
|
||||
|
||||
// Copies a folder recursively
|
||||
void TestRunner::copyFolder(const QString& source, const QString& destination) {
|
||||
try {
|
||||
if (!QFileInfo(source).isDir()) {
|
||||
// just a file copy
|
||||
QFile::copy(source, destination);
|
||||
} else {
|
||||
QDir destinationDir(destination);
|
||||
if (!destinationDir.cdUp()) {
|
||||
throw("'source '" + source + "'seems to be a root folder");
|
||||
}
|
||||
|
||||
if (!destinationDir.mkdir(QFileInfo(destination).fileName())) {
|
||||
throw("Could not create destination folder '" + destination + "'");
|
||||
}
|
||||
|
||||
QStringList fileNames =
|
||||
QDir(source).entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System);
|
||||
|
||||
foreach (const QString& fileName, fileNames) {
|
||||
copyFolder(QString(source + "/" + fileName), QString(destination + "/" + fileName));
|
||||
}
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
}
|
|
@ -36,6 +36,8 @@ public:
|
|||
void runInterfaceWithTestScript();
|
||||
void evaluateResults();
|
||||
|
||||
void copyFolder(const QString& source, const QString& destination);
|
||||
|
||||
private:
|
||||
QDir _appDataFolder;
|
||||
QDir _savedAppDataFolder;
|
||||
|
|
Loading…
Reference in a new issue