Filenames are sorted in memory.

This commit is contained in:
NissimHadar 2018-12-01 18:41:44 -08:00
parent 6491ea23eb
commit 508a658752

View file

@ -27,7 +27,7 @@ void AWSInterface::createWebPageFromResults(const QString& testResults,
QLineEdit* urlLineEdit) {
_testResults = testResults;
_workingDirectory = workingDirectory;
_urlLineEdit = urlLineEdit;
_urlLineEdit->setEnabled(false);
@ -43,7 +43,7 @@ void AWSInterface::extractTestFailuresFromZippedFolder() {
// For a test results zip file called `D:/tt/TestResults--2018-10-02_16-54-11(9426)[DESKTOP-PMKNLSQ].zip`
// the folder will be called `TestResults--2018-10-02_16-54-11(9426)[DESKTOP-PMKNLSQ]`
// and, this folder will be in the working directory
QStringList parts =_testResults.split('/');
QStringList parts = _testResults.split('/');
QString zipFolderName = _workingDirectory + "/" + parts[parts.length() - 1].split('.')[0];
if (QDir(zipFolderName).exists()) {
QDir dir = zipFolderName;
@ -116,7 +116,7 @@ void AWSInterface::writeTitle(QTextStream& stream) {
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];
QString hostName = date_buildorPR_hostName.split('[')[1].split(']')[0];
QStringList dateList = date_buildorPR_hostName.split('(')[0].split('_')[0].split('-');
QString year = dateList[0];
@ -189,7 +189,7 @@ void AWSInterface::writeTable(QTextStream& stream) {
for (int i = 0; i < originalNamesSuccesses.length(); ++i) {
newNamesSuccesses.append(originalNamesSuccesses[i].split("--tests.")[1]);
}
_htmlFailuresFolder = _workingDirectory + "/" + _resultsFolder + "/" + FAILURES_FOLDER;
QDir().mkdir(_htmlFailuresFolder);
@ -204,7 +204,11 @@ void AWSInterface::writeTable(QTextStream& stream) {
QDir().rename(originalNamesSuccesses[i], _htmlSuccessesFolder + "/" + newNamesSuccesses[i]);
}
// Mac does not read folders in lexicographic order, so this step is divided into 2
// Each test consists of the test name and its index.
QDirIterator it2(_htmlFailuresFolder);
QStringList folderNames;
while (it2.hasNext()) {
QString nextDirectory = it2.next();
@ -214,10 +218,17 @@ void AWSInterface::writeTable(QTextStream& stream) {
}
QStringList pathComponents = nextDirectory.split('/');
QString filename = pathComponents[pathComponents.length() - 1];
int splitIndex = filename.lastIndexOf(".");
QString testName = filename.left(splitIndex).replace(".", " / ");
QString testNumber = filename.right(filename.length() - (splitIndex + 1));
QString folderName = pathComponents[pathComponents.length() - 1];
folderNames << folderName;
}
folderNames.sort();
for (const auto& folderName : folderNames) {
int splitIndex = folderName.lastIndexOf(".");
QString testName = folderName.left(splitIndex).replace('.', " / ");
int testNumber = folderName.right(folderName.length() - (splitIndex + 1)).toInt();
// The failures are ordered lexicographically, so we know that we can rely on the testName changing to create a new table
if (testName != previousTestName) {
@ -232,7 +243,7 @@ void AWSInterface::writeTable(QTextStream& stream) {
openTable(stream);
}
createEntry(testNumber.toInt(), filename, stream, true);
createEntry(testNumber, folderName, stream, true);
}
closeTable(stream);
@ -290,7 +301,7 @@ void AWSInterface::closeTable(QTextStream& stream) {
void AWSInterface::createEntry(int index, const QString& testResult, QTextStream& stream, const bool isFailure) {
stream << "\t\t\t<tr>\n";
stream << "\t\t\t\t<td><h1>" << QString::number(index) << "</h1></td>\n";
// For a test named `D:/t/fgadhcUDHSFaidsfh3478JJJFSDFIUSOEIrf/Failure_1--tests.engine.interaction.pick.collision.many.00000`
// we need `Failure_1--tests.engine.interaction.pick.collision.many.00000`
QStringList resultNameComponents = testResult.split('/');
@ -302,11 +313,11 @@ void AWSInterface::createEntry(int index, const QString& testResult, QTextStream
folder = FAILURES_FOLDER;
differenceFileFound = QFile::exists(_htmlFailuresFolder + "/" + resultName + "/Difference Image.png");
} else {
folder = SUCCESSES_FOLDER;
folder = SUCCESSES_FOLDER;
differenceFileFound = QFile::exists(_htmlSuccessesFolder + "/" + resultName + "/Difference Image.png");
}
stream << "\t\t\t\t<td><img src=\"./" << folder << "/" << resultName << "/Actual Image.png\" width = \"576\" height = \"324\" ></td>\n";
stream << "\t\t\t\t<td><img src=\"./" << folder << "/" << resultName << "/Expected Image.png\" width = \"576\" height = \"324\" ></td>\n";
@ -345,7 +356,7 @@ void AWSInterface::updateAWS() {
if (nextDirectory.right(1) == ".") {
continue;
}
// nextDirectory looks like `D:/t/TestResults--2018-10-02_16-54-11(9426)[DESKTOP-PMKNLSQ]/failures/engine.render.effect.bloom.00000`
// We need to concatenate the last 3 components, to get `TestResults--2018-10-02_16-54-11(9426)[DESKTOP-PMKNLSQ]/failures/engine.render.effect.bloom.00000`
QStringList parts = nextDirectory.split('/');
@ -426,10 +437,10 @@ void AWSInterface::updateAWS() {
[=](int exitCode, QProcess::ExitStatus exitStatus) { _busyWindow.hide(); });
#ifdef Q_OS_WIN
QStringList parameters = QStringList() << filename ;
QStringList parameters = QStringList() << filename;
process->start(_pythonCommand, parameters);
#elif defined Q_OS_MAC
QStringList parameters = QStringList() << "-c" << _pythonCommand + " " + filename;
QStringList parameters = QStringList() << "-c" << _pythonCommand + " " + filename;
process->start("sh", parameters);
#endif
}
}