Added selection of branch from the command line.

This commit is contained in:
NissimHadar 2018-06-13 19:29:09 -07:00
parent ee675b0f1c
commit 9ca27468f6
6 changed files with 106 additions and 27 deletions

View file

@ -25,6 +25,10 @@ extern AutoTester* autoTester;
Test::Test() { Test::Test() {
mismatchWindow.setModal(true); mismatchWindow.setModal(true);
if (autoTester) {
autoTester->loadBranchCombo(GIT_HUB_BRANCHES);
}
} }
bool Test::createTestResultsFolderPath(const QString& directory) { bool Test::createTestResultsFolderPath(const QString& directory) {
@ -177,7 +181,7 @@ void Test::appendTestResultsToFile(const QString& testResultsFolderPath, TestFai
comparisonImage.save(failureFolderPath + "/" + "Difference Image.png"); comparisonImage.save(failureFolderPath + "/" + "Difference Image.png");
} }
void Test::startTestsEvaluation(const QString& testFolder) { void Test::startTestsEvaluation(const QString& testFolder, const QString& branchFromCommandLine) {
if (testFolder.isNull()) { if (testFolder.isNull()) {
// Get list of JPEG images in folder, sorted by name // Get list of JPEG images in folder, sorted by name
QString previousSelection = snapshotDirectory; QString previousSelection = snapshotDirectory;
@ -225,6 +229,8 @@ void Test::startTestsEvaluation(const QString& testFolder) {
expectedImagesFilenames.clear(); expectedImagesFilenames.clear();
expectedImagesFullFilenames.clear(); expectedImagesFullFilenames.clear();
QString branch = (branchFromCommandLine.isNull()) ? autoTester->getSelectedBranch() : branchFromCommandLine ;
foreach(QString currentFilename, sortedTestResultsFilenames) { foreach(QString currentFilename, sortedTestResultsFilenames) {
QString fullCurrentFilename = snapshotDirectory + "/" + currentFilename; QString fullCurrentFilename = snapshotDirectory + "/" + currentFilename;
if (isInSnapshotFilenameFormat("png", currentFilename)) { if (isInSnapshotFilenameFormat("png", currentFilename)) {
@ -237,7 +243,7 @@ void Test::startTestsEvaluation(const QString& testFolder) {
QString expectedImageFilenameTail = currentFilename.left(currentFilename.length() - 4).right(NUM_DIGITS); QString expectedImageFilenameTail = currentFilename.left(currentFilename.length() - 4).right(NUM_DIGITS);
QString expectedImageStoredFilename = EXPECTED_IMAGE_PREFIX + expectedImageFilenameTail + ".png"; QString expectedImageStoredFilename = EXPECTED_IMAGE_PREFIX + expectedImageFilenameTail + ".png";
QString imageURLString("https://raw.githubusercontent.com/" + GIT_HUB_USER + "/hifi_tests/" + GIT_HUB_BRANCH + "/" + QString imageURLString("https://raw.githubusercontent.com/" + GIT_HUB_USER + "/hifi_tests/" + branch + "/" +
expectedImagePartialSourceDirectory + "/" + expectedImageStoredFilename); expectedImagePartialSourceDirectory + "/" + expectedImageStoredFilename);
expectedImagesURLs << imageURLString; expectedImagesURLs << imageURLString;
@ -406,7 +412,9 @@ void Test::createRecursiveScript(const QString& topLevelDirectory, bool interact
textStream << "user = \"" + GIT_HUB_USER + "/\";" << endl; textStream << "user = \"" + GIT_HUB_USER + "/\";" << endl;
textStream << "repository = \"" + GIT_HUB_REPOSITORY + "/\";" << endl; textStream << "repository = \"" + GIT_HUB_REPOSITORY + "/\";" << endl;
textStream << "branch = \"" + GIT_HUB_BRANCH + "/\";" << endl << endl;
QString branch = autoTester->getSelectedBranch();
textStream << "branch = \"" + branch + "/\";" << endl << endl;
// Wait 10 seconds before starting // Wait 10 seconds before starting
textStream << "Test.wait(10000);" << endl << endl; textStream << "Test.wait(10000);" << endl << endl;

View file

@ -37,7 +37,7 @@ class Test {
public: public:
Test(); Test();
void startTestsEvaluation(const QString& testFolder = QString()); void startTestsEvaluation(const QString& testFolder = QString(), const QString& branchFromCommandLine = QString());
void finishTestsEvaluation(bool isRunningFromCommandline, bool interactiveMode, QProgressBar* progressBar); void finishTestsEvaluation(bool isRunningFromCommandline, bool interactiveMode, QProgressBar* progressBar);
void createRecursiveScript(); void createRecursiveScript();
@ -106,7 +106,9 @@ private:
// Used for accessing GitHub // Used for accessing GitHub
const QString GIT_HUB_USER{ "highfidelity" }; const QString GIT_HUB_USER{ "highfidelity" };
const QString GIT_HUB_REPOSITORY{ "hifi_tests" }; const QString GIT_HUB_REPOSITORY{ "hifi_tests" };
const QString GIT_HUB_BRANCH{ "master" };
// The branch is user-selected
const QStringList GIT_HUB_BRANCHES{ "master", "RC69" };
const QString DATETIME_FORMAT{ "yyyy-MM-dd_hh-mm-ss" }; const QString DATETIME_FORMAT{ "yyyy-MM-dd_hh-mm-ss" };

View file

@ -10,23 +10,49 @@
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
#include "ui/AutoTester.h" #include "ui/AutoTester.h"
#include <iostream>
AutoTester* autoTester; AutoTester* autoTester;
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
// Only parameter is "--testFolder" // If no parameters then run in interactive mode
// Parameter --testFolder <folder containing the test images>
// Parameter --branch <branch on GitHub>
// default is "master"
//
QString testFolder; QString testFolder;
if (argc == 3) { QString branch;
if (QString(argv[1]) == "--testFolder") { if (argc > 2) {
testFolder = QString(argv[2]); for (int i = 1; i < argc - 1; ++i)
if (QString(argv[i]) == "--testFolder") {
++i;
if (i < argc) {
testFolder = QString(argv[i]);
} else {
std::cout << "Missing parameter after --testFolder" << endl;
exit(-1);
}
} else if (QString(argv[i]) == "--branch") {
++i;
if (i < argc) {
branch = QString(argv[i]);
} else {
std::cout << "Missing parameter after --branch" << endl;
exit(-1);
}
} else {
std::cout << "Unknown parameter" << endl;
exit(-1);
} }
} }
QApplication application(argc, argv); QApplication application(argc, argv);
autoTester = new AutoTester(); autoTester = new AutoTester();
autoTester->setup();
if (!testFolder.isNull()) { if (!testFolder.isNull()) {
autoTester->runFromCommandLine(testFolder); autoTester->runFromCommandLine(testFolder, branch);
} else { } else {
autoTester->show(); autoTester->show();
} }

View file

@ -29,13 +29,15 @@ AutoTester::AutoTester(QWidget *parent) : QMainWindow(parent) {
ui.hideTaskbarButton->setVisible(false); ui.hideTaskbarButton->setVisible(false);
ui.showTaskbarButton->setVisible(false); ui.showTaskbarButton->setVisible(false);
#endif #endif
}
void AutoTester::setup() {
test = new Test(); test = new Test();
} }
void AutoTester::runFromCommandLine(const QString& testFolder) { void AutoTester::runFromCommandLine(const QString& testFolder, const QString& branch) {
isRunningFromCommandline = true; isRunningFromCommandline = true;
test->startTestsEvaluation(testFolder); test->startTestsEvaluation(testFolder, branch);
} }
void AutoTester::on_evaluateTestsButton_clicked() { void AutoTester::on_evaluateTestsButton_clicked() {
@ -150,3 +152,11 @@ void AutoTester::saveImage(int index) {
void AutoTester::about() { void AutoTester::about() {
QMessageBox::information(0, "About", QString("Built ") + __DATE__ + " : " + __TIME__); QMessageBox::information(0, "About", QString("Built ") + __DATE__ + " : " + __TIME__);
} }
void AutoTester::loadBranchCombo(const QStringList& items) {
ui.branchComboBox->addItems(items);
}
QString AutoTester::getSelectedBranch() {
return ui.branchComboBox->currentText();
}

View file

@ -23,11 +23,16 @@ class AutoTester : public QMainWindow {
public: public:
AutoTester(QWidget *parent = Q_NULLPTR); AutoTester(QWidget *parent = Q_NULLPTR);
void runFromCommandLine(const QString& testFolder); void setup();
void runFromCommandLine(const QString& testFolder, const QString& branch);
void downloadImage(const QUrl& url); void downloadImage(const QUrl& url);
void downloadImages(const QStringList& URLs, const QString& directoryName, const QStringList& filenames); void downloadImages(const QStringList& URLs, const QString& directoryName, const QStringList& filenames);
void loadBranchCombo(const QStringList& items);
QString getSelectedBranch();
private slots: private slots:
void on_evaluateTestsButton_clicked(); void on_evaluateTestsButton_clicked();
void on_createRecursiveScriptButton_clicked(); void on_createRecursiveScriptButton_clicked();

View file

@ -43,8 +43,8 @@
<widget class="QPushButton" name="evaluateTestsButton"> <widget class="QPushButton" name="evaluateTestsButton">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>20</x> <x>340</x>
<y>285</y> <y>275</y>
<width>220</width> <width>220</width>
<height>40</height> <height>40</height>
</rect> </rect>
@ -56,8 +56,8 @@
<widget class="QPushButton" name="createRecursiveScriptButton"> <widget class="QPushButton" name="createRecursiveScriptButton">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>360</x> <x>340</x>
<y>35</y> <y>95</y>
<width>220</width> <width>220</width>
<height>40</height> <height>40</height>
</rect> </rect>
@ -69,8 +69,8 @@
<widget class="QCheckBox" name="checkBoxInteractiveMode"> <widget class="QCheckBox" name="checkBoxInteractiveMode">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>23</x> <x>343</x>
<y>250</y> <y>240</y>
<width>131</width> <width>131</width>
<height>20</height> <height>20</height>
</rect> </rect>
@ -85,8 +85,8 @@
<widget class="QProgressBar" name="progressBar"> <widget class="QProgressBar" name="progressBar">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>20</x> <x>340</x>
<y>340</y> <y>330</y>
<width>255</width> <width>255</width>
<height>23</height> <height>23</height>
</rect> </rect>
@ -98,8 +98,8 @@
<widget class="QPushButton" name="createAllRecursiveScriptsButton"> <widget class="QPushButton" name="createAllRecursiveScriptsButton">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>360</x> <x>340</x>
<y>100</y> <y>160</y>
<width>220</width> <width>220</width>
<height>40</height> <height>40</height>
</rect> </rect>
@ -150,8 +150,8 @@
<widget class="QPushButton" name="showTaskbarButton"> <widget class="QPushButton" name="showTaskbarButton">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>490</x> <x>10</x>
<y>280</y> <y>410</y>
<width>91</width> <width>91</width>
<height>40</height> <height>40</height>
</rect> </rect>
@ -163,8 +163,8 @@
<widget class="QPushButton" name="hideTaskbarButton"> <widget class="QPushButton" name="hideTaskbarButton">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>490</x> <x>10</x>
<y>230</y> <y>360</y>
<width>91</width> <width>91</width>
<height>40</height> <height>40</height>
</rect> </rect>
@ -173,6 +173,34 @@
<string>Hide Taskbar</string> <string>Hide Taskbar</string>
</property> </property>
</widget> </widget>
<widget class="QComboBox" name="branchComboBox">
<property name="geometry">
<rect>
<x>428</x>
<y>41</y>
<width>131</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>340</x>
<y>30</y>
<width>81</width>
<height>51</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>GitHub Branch</string>
</property>
</widget>
</widget> </widget>
<widget class="QMenuBar" name="menuBar"> <widget class="QMenuBar" name="menuBar">
<property name="geometry"> <property name="geometry">