Delete old failures before unzipping

This commit is contained in:
NissimHadar 2018-10-06 16:23:47 -07:00
parent 2bcdb129c0
commit fd6518ec56
7 changed files with 102 additions and 41 deletions

View file

@ -11,12 +11,14 @@
#include <QDirIterator>
#include <QMessageBox>
#include <QProcess>
#include <quazip5/quazip.h>
#include <quazip5/JlCompress.h>
AWSInterface::AWSInterface(QObject* parent) :
QObject(parent) {
AWSInterface::AWSInterface(QObject* parent) : QObject(parent) {
_pythonInterface = new PythonInterface();
_pythonCommand = _pythonInterface->getPythonCommand();
}
void AWSInterface::createWebPageFromResults(const QString& testResults, const QString& workingDirectory) {
@ -32,6 +34,16 @@ void AWSInterface::createWebPageFromResults(const QString& testResults, const QS
}
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 workign directory
QStringList parts =_testResults.split('/');
QString zipFolderName = _workingDirectory + "/" + parts[parts.length() - 1].split('.')[0];
if (QDir(zipFolderName).exists()) {
QDir dir = zipFolderName;
dir.removeRecursively();
}
QDir().mkdir(_workingDirectory);
JlCompress::extractDir(_testResults, _workingDirectory);
}
@ -272,4 +284,14 @@ void AWSInterface::updateAWS() {
stream << "s3.Bucket('hifi-content').put_object(Bucket='hifi-content', Key='nissim/" << _resultsFolder << "/" << HTML_FILENAME << "', Body=data)\n";
file.close();
QProcess* process = new QProcess();
connect(process, &QProcess::started, this, [=]() { _busyWindow.exec(); });
connect(process, SIGNAL(finished(int)), process, SLOT(deleteLater()));
connect(process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), this,
[=](int exitCode, QProcess::ExitStatus exitStatus) { _busyWindow.hide(); });
QStringList parameters = QStringList() << filename ;
process->start(_pythonCommand, parameters);
}

View file

@ -14,6 +14,10 @@
#include <QObject>
#include <QTextStream>
#include "ui/BusyWindow.h"
#include "PythonInterface.h"
class AWSInterface : public QObject {
Q_OBJECT
public:
@ -46,6 +50,11 @@ private:
const QString FAILURE_FOLDER{ "failures" };
const QString HTML_FILENAME{ "TestResults.html" };
BusyWindow _busyWindow;
PythonInterface* _pythonInterface;
QString _pythonCommand;
};
#endif // hifi_AWSInterface_h

View file

@ -0,0 +1,32 @@
//
// PythonInterface.cpp
//
// Created by Nissim Hadar on Oct 6, 2018.
// Copyright 2013 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "PythonInterface.h"
#include <QFile>
#include <QMessageBox>
#include <QProcess>
PythonInterface::PythonInterface() {
if (QProcessEnvironment::systemEnvironment().contains("PYTHON_PATH")) {
QString _pythonPath = QProcessEnvironment::systemEnvironment().value("PYTHON_PATH");
if (!QFile::exists(_pythonPath + "/" + _pythonExe)) {
QMessageBox::critical(0, _pythonExe, QString("Python executable not found in ") + _pythonPath);
}
_pythonCommand = _pythonPath + "/" + _pythonExe;
} else {
QMessageBox::critical(0, "PYTHON_PATH not defined",
"Please set PYTHON_PATH to directory containing the Python executable");
exit(-1);
}
}
QString PythonInterface::getPythonCommand() {
return _pythonCommand;
}

View file

@ -0,0 +1,26 @@
//
// PythonInterface.h
//
// Created by Nissim Hadar on Oct 6, 2018.
// Copyright 2013 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_PythonInterface_h
#define hifi_PythonInterface_h
#include <QString>
class PythonInterface {
public:
PythonInterface();
QString getPythonCommand();
private:
const QString _pythonExe{ "python.exe" };
QString _pythonCommand;
};
#endif // hifi_PythonInterface_h

View file

@ -41,29 +41,15 @@ TestRailInterface::TestRailInterface() {
_testRailResultsSelectorWindow.setProjectID(INTERFACE_AUTOMATION_PROJECT_ID);
_testRailResultsSelectorWindow.setSuiteID(INTERFACE_SUITE_ID);
_pythonInterface = new PythonInterface();
_pythonCommand = _pythonInterface->getPythonCommand();
}
QString TestRailInterface::getObject(const QString& path) {
return path.right(path.length() - path.lastIndexOf("/") - 1);
}
bool TestRailInterface::setPythonCommand() {
if (QProcessEnvironment::systemEnvironment().contains("PYTHON_PATH")) {
QString _pythonPath = QProcessEnvironment::systemEnvironment().value("PYTHON_PATH");
if (!QFile::exists(_pythonPath + "/" + _pythonExe)) {
QMessageBox::critical(0, _pythonExe, QString("Python executable not found in ") + _pythonPath);
}
_pythonCommand = _pythonPath + "/" + _pythonExe;
return true;
} else {
QMessageBox::critical(0, "PYTHON_PATH not defined",
"Please set PYTHON_PATH to directory containing the Python executable");
return false;
}
return false;
}
// Creates the testrail.py script
// This is the file linked to from http://docs.gurock.com/testrail-api2/bindings-python
void TestRailInterface::createTestRailDotPyScript() {
@ -770,10 +756,6 @@ void TestRailInterface::createTestSuitePython(const QString& testDirectory,
_userGitHub = userGitHub;
_branchGitHub = branchGitHub;
if (!setPythonCommand()) {
return;
}
if (!requestTestRailTestCasesDataFromUser()) {
return;
}
@ -1127,10 +1109,6 @@ void TestRailInterface::getRunsFromTestRail() {
void TestRailInterface::createTestRailRun(const QString& outputDirectory) {
_outputDirectory = outputDirectory;
if (!setPythonCommand()) {
return;
}
if (!requestTestRailRunDataFromUser()) {
return;
}
@ -1145,10 +1123,6 @@ void TestRailInterface::createTestRailRun(const QString& outputDirectory) {
void TestRailInterface::updateTestRailRunResults(const QString& testResults, const QString& tempDirectory) {
_outputDirectory = tempDirectory;
if (!setPythonCommand()) {
return;
}
if (!requestTestRailResultsDataFromUser()) {
return;
}

View file

@ -12,7 +12,6 @@
#define hifi_test_testrail_interface_h
#include "ui/BusyWindow.h"
#include "ui/TestRailTestCasesSelectorWindow.h"
#include "ui/TestRailRunSelectorWindow.h"
#include "ui/TestRailResultsSelectorWindow.h"
@ -22,7 +21,9 @@
#include <QProcess>
#include <QString>
class TestRailInterface : public QObject{
#include "PythonInterface.h"
class TestRailInterface : public QObject {
Q_OBJECT
public:
@ -65,9 +66,7 @@ public:
bool requestTestRailRunDataFromUser();
bool requestTestRailResultsDataFromUser();
void createAddTestCasesPythonScript(const QString& testDirectory,
const QString& userGitHub,
const QString& branchGitHub);
void createAddTestCasesPythonScript(const QString& testDirectory, const QString& userGitHub, const QString& branchGitHub);
void processDirectoryPython(const QString& directory,
QTextStream& stream,
@ -88,7 +87,6 @@ public:
void addRun();
void updateRunWithResults();
bool setPythonCommand();
void extractTestFailuresFromZippedFolder(const QString& testResults, const QString& tempDirectory);
private:
@ -117,9 +115,6 @@ private:
QString _userGitHub;
QString _branchGitHub;
const QString _pythonExe{ "python.exe" };
QString _pythonCommand;
QStringList _releaseNames;
QStringList _sectionNames;
@ -129,6 +124,9 @@ private:
std::vector<int> _runIDs;
QString TEMP_NAME{ "fgadhcUDHSFaidsfh3478JJJFSDFIUSOEIrf" };
PythonInterface* _pythonInterface;
QString _pythonCommand;
};
#endif

View file

@ -36,7 +36,7 @@ AutoTester::AutoTester(QWidget* parent) : QMainWindow(parent) {
_ui.statusLabel->setText("");
_ui.plainTextEdit->setReadOnly(true);
setWindowTitle("Auto Tester - v6.0");
setWindowTitle("Auto Tester - v6.1");
// Coming soon to an auto-tester near you...
//// _helpWindow.textBrowser->setText()