mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-10 14:16:24 +02:00
Merge pull request #12857 from NissimHadar/addMDtoAutoTester
Added recursive creation of MD files.
This commit is contained in:
commit
0857bf06b6
5 changed files with 168 additions and 19 deletions
|
@ -304,7 +304,7 @@ void Test::createRecursiveScript() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method creates a `testRecursive.js` script in every sub-folder.
|
// This method creates a `testRecursive.js` script in every sub-folder.
|
||||||
void Test::createRecursiveScriptsRecursively() {
|
void Test::createAllRecursiveScripts() {
|
||||||
// Select folder to start recursing from
|
// Select folder to start recursing from
|
||||||
QString topLevelDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select the root folder for the recursive scripts", ".", QFileDialog::ShowDirsOnly);
|
QString topLevelDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select the root folder for the recursive scripts", ".", QFileDialog::ShowDirsOnly);
|
||||||
if (topLevelDirectory == "") {
|
if (topLevelDirectory == "") {
|
||||||
|
@ -559,6 +559,44 @@ void Test::createMDFile() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createMDFile(testDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Test::createAllMDFiles() {
|
||||||
|
// Select folder to start recursing from
|
||||||
|
QString topLevelDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select the root folder for the MD files", ".", QFileDialog::ShowDirsOnly);
|
||||||
|
if (topLevelDirectory == "") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// First test if top-level folder has a test.js file
|
||||||
|
const QString testPathname{ topLevelDirectory + "/" + TEST_FILENAME };
|
||||||
|
QFileInfo fileInfo(testPathname);
|
||||||
|
if (fileInfo.exists()) {
|
||||||
|
createMDFile(topLevelDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
QDirIterator it(topLevelDirectory.toStdString().c_str(), QDirIterator::Subdirectories);
|
||||||
|
while (it.hasNext()) {
|
||||||
|
QString directory = it.next();
|
||||||
|
|
||||||
|
// Only process directories
|
||||||
|
QDir dir;
|
||||||
|
if (!isAValidDirectory(directory)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString testPathname{ directory + "/" + TEST_FILENAME };
|
||||||
|
QFileInfo fileInfo(testPathname);
|
||||||
|
if (fileInfo.exists()) {
|
||||||
|
createMDFile(directory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
messageBox.information(0, "Success", "MD files have been created");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Test::createMDFile(QString testDirectory) {
|
||||||
// Verify folder contains test.js file
|
// Verify folder contains test.js file
|
||||||
QString testFileName(testDirectory + "/" + TEST_FILENAME);
|
QString testFileName(testDirectory + "/" + TEST_FILENAME);
|
||||||
QFileInfo testFileInfo(testFileName);
|
QFileInfo testFileInfo(testFileName);
|
||||||
|
@ -639,8 +677,8 @@ void Test::createMDFile() {
|
||||||
|
|
||||||
int snapShotIndex { 0 };
|
int snapShotIndex { 0 };
|
||||||
for (size_t i = 0; i < testScriptLines.stepList.size(); ++i) {
|
for (size_t i = 0; i < testScriptLines.stepList.size(); ++i) {
|
||||||
stream << "### Step " << QString::number(i) << "\n";
|
stream << "### Step " << QString::number(i + 1) << "\n";
|
||||||
stream << "- " << testScriptLines.stepList[i + 1]->text << "\n";
|
stream << "- " << testScriptLines.stepList[i]->text << "\n";
|
||||||
if (testScriptLines.stepList[i]->takeSnapshot) {
|
if (testScriptLines.stepList[i]->takeSnapshot) {
|
||||||
stream << "- .rightJustified(5, '0') << ".png)\n";
|
stream << "- .rightJustified(5, '0') << ".png)\n";
|
||||||
++snapShotIndex;
|
++snapShotIndex;
|
||||||
|
@ -650,6 +688,77 @@ void Test::createMDFile() {
|
||||||
mdFile.close();
|
mdFile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Test::createTestsOutline() {
|
||||||
|
QString testsRootDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select the tests root folder", ".", QFileDialog::ShowDirsOnly);
|
||||||
|
if (testsRootDirectory == "") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString testsOutlineFilename { "testsOutline.md" };
|
||||||
|
QString mdFilename(testsRootDirectory + "/" + testsOutlineFilename);
|
||||||
|
QFile mdFile(mdFilename);
|
||||||
|
if (!mdFile.open(QIODevice::WriteOnly)) {
|
||||||
|
messageBox.critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Failed to create file " + mdFilename);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
QTextStream stream(&mdFile);
|
||||||
|
|
||||||
|
//Test title
|
||||||
|
stream << "# Outline of all tests\n";
|
||||||
|
stream << "Directories with an appended (*) have an automatic test\n\n";
|
||||||
|
|
||||||
|
// We need to know our current depth, as this isn't given by QDirIterator
|
||||||
|
int rootDepth { testsRootDirectory.count('/') };
|
||||||
|
|
||||||
|
// Each test is shown as the folder name linking to the matching GitHub URL, and the path to the associated test.md file
|
||||||
|
QDirIterator it(testsRootDirectory.toStdString().c_str(), QDirIterator::Subdirectories);
|
||||||
|
while (it.hasNext()) {
|
||||||
|
QString directory = it.next();
|
||||||
|
|
||||||
|
// Only process directories
|
||||||
|
QDir dir;
|
||||||
|
if (!isAValidDirectory(directory)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ignore the utils directory
|
||||||
|
if (directory.right(5) == "utils") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The prefix is the MarkDown prefix needed for correct indentation
|
||||||
|
// It consists of 2 spaces for each level of indentation, folled by a dash sign
|
||||||
|
int currentDepth = directory.count('/') - rootDepth;
|
||||||
|
QString prefix = QString(" ").repeated(2 * currentDepth - 1) + " - ";
|
||||||
|
|
||||||
|
// The directory name appears after the last slash (we are assured there is at least 1).
|
||||||
|
QString directoryName = directory.right(directory.length() - directory.lastIndexOf("/") - 1);
|
||||||
|
|
||||||
|
// autoTester is run on a clone of the repository. We use relative paths, so we can use both local disk and GitHub
|
||||||
|
// For a test in "D:/GitHub/hifi_tests/tests/content/entity/zone/ambientLightInheritance" the
|
||||||
|
// GitHub URL is "./content/entity/zone/ambientLightInheritance?raw=true"
|
||||||
|
QString partialPath = directory.right(directory.length() - (directory.lastIndexOf("/tests/") + QString("/tests").length() + 1));
|
||||||
|
QString url = "./" + partialPath;
|
||||||
|
|
||||||
|
stream << prefix << "[" << directoryName << "](" << url << "?raw=true" << ")";
|
||||||
|
QFileInfo fileInfo1(directory + "/test.md");
|
||||||
|
if (fileInfo1.exists()) {
|
||||||
|
stream << " [(test description)](" << url << "/test.md)";
|
||||||
|
}
|
||||||
|
|
||||||
|
QFileInfo fileInfo2(directory + "/" + TEST_FILENAME);
|
||||||
|
if (fileInfo2.exists()) {
|
||||||
|
stream << " (*)";
|
||||||
|
}
|
||||||
|
stream << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
mdFile.close();
|
||||||
|
|
||||||
|
messageBox.information(0, "Success", "Test outline file " + testsOutlineFilename + " has been created");
|
||||||
|
}
|
||||||
|
|
||||||
void Test::copyJPGtoPNG(QString sourceJPGFullFilename, QString destinationPNGFullFilename) {
|
void Test::copyJPGtoPNG(QString sourceJPGFullFilename, QString destinationPNGFullFilename) {
|
||||||
QFile::remove(destinationPNGFullFilename);
|
QFile::remove(destinationPNGFullFilename);
|
||||||
|
|
||||||
|
|
|
@ -45,11 +45,15 @@ public:
|
||||||
void finishTestsEvaluation(bool interactiveMode, QProgressBar* progressBar);
|
void finishTestsEvaluation(bool interactiveMode, QProgressBar* progressBar);
|
||||||
|
|
||||||
void createRecursiveScript();
|
void createRecursiveScript();
|
||||||
void createRecursiveScriptsRecursively();
|
void createAllRecursiveScripts();
|
||||||
void createRecursiveScript(QString topLevelDirectory, bool interactiveMode);
|
void createRecursiveScript(QString topLevelDirectory, bool interactiveMode);
|
||||||
|
|
||||||
void createTest();
|
void createTest();
|
||||||
void createMDFile();
|
void createMDFile();
|
||||||
|
void createAllMDFiles();
|
||||||
|
void createMDFile(QString topLevelDirectory);
|
||||||
|
|
||||||
|
void createTestsOutline();
|
||||||
|
|
||||||
bool compareImageLists(bool isInteractiveMode, QProgressBar* progressBar);
|
bool compareImageLists(bool isInteractiveMode, QProgressBar* progressBar);
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,8 @@ void AutoTester::on_createRecursiveScriptButton_clicked() {
|
||||||
test->createRecursiveScript();
|
test->createRecursiveScript();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoTester::on_createRecursiveScriptsRecursivelyButton_clicked() {
|
void AutoTester::on_createAllRecursiveScriptsButton_clicked() {
|
||||||
test->createRecursiveScriptsRecursively();
|
test->createAllRecursiveScripts();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoTester::on_createTestButton_clicked() {
|
void AutoTester::on_createTestButton_clicked() {
|
||||||
|
@ -37,7 +37,15 @@ void AutoTester::on_createTestButton_clicked() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoTester::on_createMDFileButton_clicked() {
|
void AutoTester::on_createMDFileButton_clicked() {
|
||||||
test->createMDFile();
|
test->createMDFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AutoTester::on_createAllMDFilesButton_clicked() {
|
||||||
|
test->createAllMDFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AutoTester::on_createTestsOutlineButton_clicked() {
|
||||||
|
test->createTestsOutline();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoTester::on_closeButton_clicked() {
|
void AutoTester::on_closeButton_clicked() {
|
||||||
|
|
|
@ -28,10 +28,12 @@ public:
|
||||||
private slots:
|
private slots:
|
||||||
void on_evaluateTestsButton_clicked();
|
void on_evaluateTestsButton_clicked();
|
||||||
void on_createRecursiveScriptButton_clicked();
|
void on_createRecursiveScriptButton_clicked();
|
||||||
void on_createRecursiveScriptsRecursivelyButton_clicked();
|
void on_createAllRecursiveScriptsButton_clicked();
|
||||||
void on_createTestButton_clicked();
|
void on_createTestButton_clicked();
|
||||||
void on_createMDFileButton_clicked();
|
void on_createMDFileButton_clicked();
|
||||||
void on_closeButton_clicked();
|
void on_createAllMDFilesButton_clicked();
|
||||||
|
void on_createTestsOutlineButton_clicked();
|
||||||
|
void on_closeButton_clicked();
|
||||||
|
|
||||||
void saveImage(int index);
|
void saveImage(int index);
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
<widget class="QPushButton" name="closeButton">
|
<widget class="QPushButton" name="closeButton">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>360</x>
|
||||||
<y>420</y>
|
<y>400</y>
|
||||||
<width>220</width>
|
<width>220</width>
|
||||||
<height>40</height>
|
<height>40</height>
|
||||||
</rect>
|
</rect>
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>20</x>
|
||||||
<y>255</y>
|
<y>285</y>
|
||||||
<width>220</width>
|
<width>220</width>
|
||||||
<height>40</height>
|
<height>40</height>
|
||||||
</rect>
|
</rect>
|
||||||
|
@ -57,7 +57,7 @@
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>360</x>
|
<x>360</x>
|
||||||
<y>75</y>
|
<y>35</y>
|
||||||
<width>220</width>
|
<width>220</width>
|
||||||
<height>40</height>
|
<height>40</height>
|
||||||
</rect>
|
</rect>
|
||||||
|
@ -70,7 +70,7 @@
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>23</x>
|
<x>23</x>
|
||||||
<y>220</y>
|
<y>250</y>
|
||||||
<width>131</width>
|
<width>131</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
|
@ -86,7 +86,7 @@
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>20</x>
|
||||||
<y>310</y>
|
<y>340</y>
|
||||||
<width>255</width>
|
<width>255</width>
|
||||||
<height>23</height>
|
<height>23</height>
|
||||||
</rect>
|
</rect>
|
||||||
|
@ -99,20 +99,20 @@
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>360</x>
|
<x>360</x>
|
||||||
<y>140</y>
|
<y>100</y>
|
||||||
<width>220</width>
|
<width>220</width>
|
||||||
<height>40</height>
|
<height>40</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Create Recursive Scripts Recursively</string>
|
<string>Create all Recursive Scripts</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QPushButton" name="createMDFileButton">
|
<widget class="QPushButton" name="createMDFileButton">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>20</x>
|
||||||
<y>90</y>
|
<y>80</y>
|
||||||
<width>220</width>
|
<width>220</width>
|
||||||
<height>40</height>
|
<height>40</height>
|
||||||
</rect>
|
</rect>
|
||||||
|
@ -121,6 +121,32 @@
|
||||||
<string>Create MD file</string>
|
<string>Create MD file</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QPushButton" name="createAllMDFilesButton">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>20</x>
|
||||||
|
<y>130</y>
|
||||||
|
<width>220</width>
|
||||||
|
<height>40</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Create all MD files</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton" name="createTestsOutlineButton">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>20</x>
|
||||||
|
<y>180</y>
|
||||||
|
<width>220</width>
|
||||||
|
<height>40</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Create Tests Outline</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenuBar" name="menuBar">
|
<widget class="QMenuBar" name="menuBar">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
|
|
Loading…
Reference in a new issue