Renamed folder. Removed useless 'mkdir'.

This commit is contained in:
NissimHadar 2018-11-01 07:49:36 -07:00
parent 1c7c0dd0a0
commit 6121d7022c
3 changed files with 39 additions and 22 deletions

View file

@ -22,11 +22,11 @@ AWSInterface::AWSInterface(QObject* parent) : QObject(parent) {
}
void AWSInterface::createWebPageFromResults(const QString& testResults,
const QString& workingDirectory,
const QString& snapshotDirectory,
QCheckBox* updateAWSCheckBox,
QLineEdit* urlLineEdit) {
_testResults = testResults;
_workingDirectory = workingDirectory;
_snapshotDirectory = snapshotDirectory;
_urlLineEdit = urlLineEdit;
_urlLineEdit->setEnabled(false);
@ -44,14 +44,13 @@ void AWSInterface::extractTestFailuresFromZippedFolder() {
// the folder will be called `TestResults--2018-10-02_16-54-11(9426)[DESKTOP-PMKNLSQ]`
// and, this folder will be in the workign directory
QStringList parts =_testResults.split('/');
QString zipFolderName = _workingDirectory + "/" + parts[parts.length() - 1].split('.')[0];
QString zipFolderName = _snapshotDirectory + "/" + parts[parts.length() - 1].split('.')[0];
if (QDir(zipFolderName).exists()) {
QDir dir = zipFolderName;
dir.removeRecursively();
}
QDir().mkdir(_workingDirectory);
JlCompress::extractDir(_testResults, _workingDirectory);
JlCompress::extractDir(_testResults, _snapshotDirectory);
}
void AWSInterface::createHTMLFile() {
@ -61,7 +60,7 @@ void AWSInterface::createHTMLFile() {
QString filename = pathComponents[pathComponents.length() - 1];
_resultsFolder = filename.left(filename.length() - 4);
QString resultsPath = _workingDirectory + "/" + _resultsFolder + "/";
QString resultsPath = _snapshotDirectory + "/" + _resultsFolder + "/";
QDir().mkdir(resultsPath);
_htmlFilename = resultsPath + HTML_FILENAME;
@ -157,7 +156,7 @@ void AWSInterface::writeTable(QTextStream& stream) {
// Note that failures are processed first, then successes
QStringList originalNamesFailures;
QStringList originalNamesSuccesses;
QDirIterator it1(_workingDirectory.toStdString().c_str());
QDirIterator it1(_snapshotDirectory.toStdString().c_str());
while (it1.hasNext()) {
QString nextDirectory = it1.next();
@ -191,10 +190,10 @@ void AWSInterface::writeTable(QTextStream& stream) {
newNamesSuccesses.append(originalNamesSuccesses[i].split("--tests.")[1]);
}
_htmlFailuresFolder = _workingDirectory + "/" + _resultsFolder + "/" + FAILURES_FOLDER;
_htmlFailuresFolder = _snapshotDirectory + "/" + _resultsFolder + "/" + FAILURES_FOLDER;
QDir().mkdir(_htmlFailuresFolder);
_htmlSuccessesFolder = _workingDirectory + "/" + _resultsFolder + "/" + SUCCESSES_FOLDER;
_htmlSuccessesFolder = _snapshotDirectory + "/" + _resultsFolder + "/" + SUCCESSES_FOLDER;
QDir().mkdir(_htmlSuccessesFolder);
for (int i = 0; i < newNamesFailures.length(); ++i) {
@ -321,7 +320,7 @@ void AWSInterface::createEntry(int index, const QString& testResult, QTextStream
}
void AWSInterface::updateAWS() {
QString filename = _workingDirectory + "/updateAWS.py";
QString filename = _snapshotDirectory + "/updateAWS.py";
if (QFile::exists(filename)) {
QFile::remove(filename);
}
@ -352,14 +351,23 @@ void AWSInterface::updateAWS() {
QStringList parts = nextDirectory.split('/');
QString filename = parts[parts.length() - 3] + "/" + parts[parts.length() - 2] + "/" + parts[parts.length() - 1];
stream << "data = open('" << _workingDirectory << "/" << filename << "/" << "Actual Image.png" << "', 'rb')\n";
stream << "data = open('" << _snapshotDirectory << "/" << filename << "/"
<< "Actual Image.png"
<< "', 'rb')\n";
stream << "s3.Bucket('hifi-content').put_object(Bucket='" << AWS_BUCKET << "', Key='" << filename << "/" << "Actual Image.png" << "', Body=data)\n\n";
stream << "data = open('" << _workingDirectory << "/" << filename << "/" << "Expected Image.png" << "', 'rb')\n";
stream << "data = open('" << _snapshotDirectory << "/" << filename << "/"
<< "Expected Image.png"
<< "', 'rb')\n";
stream << "s3.Bucket('hifi-content').put_object(Bucket='" << AWS_BUCKET << "', Key='" << filename << "/" << "Expected Image.png" << "', Body=data)\n\n";
if (QFile::exists(_htmlFailuresFolder + "/" + parts[parts.length() - 1] + "/Difference Image.png")) {
stream << "data = open('" << _workingDirectory << "/" << filename << "/" << "Difference Image.png" << "', 'rb')\n";
stream << "data = open('" << _snapshotDirectory << "/" << filename << "/"
<< "Difference Image.png"
<< "', 'rb')\n";
stream << "s3.Bucket('hifi-content').put_object(Bucket='" << AWS_BUCKET << "', Key='" << filename << "/" << "Difference Image.png" << "', Body=data)\n\n";
}
}
@ -378,19 +386,28 @@ void AWSInterface::updateAWS() {
QStringList parts = nextDirectory.split('/');
QString filename = parts[parts.length() - 3] + "/" + parts[parts.length() - 2] + "/" + parts[parts.length() - 1];
stream << "data = open('" << _workingDirectory << "/" << filename << "/" << "Actual Image.png" << "', 'rb')\n";
stream << "data = open('" << _snapshotDirectory << "/" << filename << "/"
<< "Actual Image.png"
<< "', 'rb')\n";
stream << "s3.Bucket('hifi-content').put_object(Bucket='" << AWS_BUCKET << "', Key='" << filename << "/" << "Actual Image.png" << "', Body=data)\n\n";
stream << "data = open('" << _workingDirectory << "/" << filename << "/" << "Expected Image.png" << "', 'rb')\n";
stream << "data = open('" << _snapshotDirectory << "/" << filename << "/"
<< "Expected Image.png"
<< "', 'rb')\n";
stream << "s3.Bucket('hifi-content').put_object(Bucket='" << AWS_BUCKET << "', Key='" << filename << "/" << "Expected Image.png" << "', Body=data)\n\n";
if (QFile::exists(_htmlSuccessesFolder + "/" + parts[parts.length() - 1] + "/Difference Image.png")) {
stream << "data = open('" << _workingDirectory << "/" << filename << "/" << "Difference Image.png" << "', 'rb')\n";
stream << "data = open('" << _snapshotDirectory << "/" << filename << "/"
<< "Difference Image.png"
<< "', 'rb')\n";
stream << "s3.Bucket('hifi-content').put_object(Bucket='" << AWS_BUCKET << "', Key='" << filename << "/" << "Difference Image.png" << "', Body=data)\n\n";
}
}
stream << "data = open('" << _workingDirectory << "/" << _resultsFolder << "/" << HTML_FILENAME << "', 'rb')\n";
stream << "data = open('" << _snapshotDirectory << "/" << _resultsFolder << "/" << HTML_FILENAME << "', 'rb')\n";
stream << "s3.Bucket('hifi-content').put_object(Bucket='" << AWS_BUCKET << "', Key='" << _resultsFolder << "/"
<< HTML_FILENAME << "', Body=data, ContentType='text/html')\n";

View file

@ -26,7 +26,7 @@ public:
explicit AWSInterface(QObject* parent = 0);
void createWebPageFromResults(const QString& testResults,
const QString& workingDirectory,
const QString& testDirectory,
QCheckBox* updateAWSCheckBox,
QLineEdit* urlLineEdit);
@ -49,7 +49,7 @@ public:
private:
QString _testResults;
QString _workingDirectory;
QString _snapshotDirectory;
QString _resultsFolder;
QString _htmlFailuresFolder;
QString _htmlSuccessesFolder;

View file

@ -1052,11 +1052,11 @@ void Test::createWebPage(QCheckBox* updateAWSCheckBox, QLineEdit* urlLineEdit) {
return;
}
QString tempDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select a folder to store temporary files in",
QString snapshotDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select a folder to store temporary files in",
nullptr, QFileDialog::ShowDirsOnly);
if (tempDirectory.isNull()) {
if (snapshotDirectory.isNull()) {
return;
}
_awsInterface.createWebPageFromResults(testResults, tempDirectory, updateAWSCheckBox, urlLineEdit);
_awsInterface.createWebPageFromResults(testResults, snapshotDirectory, updateAWSCheckBox, urlLineEdit);
}