mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 12:17:45 +02:00
Completed recursive creation of recursive scripts.
This commit is contained in:
parent
9bd7f31ff3
commit
b47b512ab9
2 changed files with 54 additions and 6 deletions
|
@ -311,6 +311,52 @@ void Test::createRecursiveScript() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createRecursiveScript(topLevelDirectory, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This method creates a `testRecursive.js` script in every sub-folder.
|
||||||
|
void Test::createRecursiveScriptsRecursively() {
|
||||||
|
// Select folder to start recursing from
|
||||||
|
QString topLevelDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select the root folder for the recursive scripts", ".", QFileDialog::ShowDirsOnly);
|
||||||
|
if (topLevelDirectory == "") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
createRecursiveScript(topLevelDirectory, false);
|
||||||
|
|
||||||
|
QDirIterator it(topLevelDirectory.toStdString().c_str(), QDirIterator::Subdirectories);
|
||||||
|
while (it.hasNext()) {
|
||||||
|
QString directory = it.next();
|
||||||
|
|
||||||
|
// Only process directories
|
||||||
|
QDir dir();
|
||||||
|
if (!isAValidDirectory(directory)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only process directories that have sub-directories
|
||||||
|
bool hasNoSubDirectories{ true };
|
||||||
|
QDirIterator it2(directory.toStdString().c_str(), QDirIterator::Subdirectories);
|
||||||
|
while (it2.hasNext()) {
|
||||||
|
QString directory2 = it2.next();
|
||||||
|
|
||||||
|
// Only process directories
|
||||||
|
QDir dir();
|
||||||
|
if (isAValidDirectory(directory2)) {
|
||||||
|
hasNoSubDirectories = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasNoSubDirectories) {
|
||||||
|
createRecursiveScript(directory, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
messageBox.information(0, "Success", "Scripts have been created");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Test::createRecursiveScript(QString topLevelDirectory, bool interactiveMode) {
|
||||||
const QString recursiveTestsFilename("testRecursive.js");
|
const QString recursiveTestsFilename("testRecursive.js");
|
||||||
QFile allTestsFilename(topLevelDirectory + "/" + recursiveTestsFilename);
|
QFile allTestsFilename(topLevelDirectory + "/" + recursiveTestsFilename);
|
||||||
if (!allTestsFilename.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
if (!allTestsFilename.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
|
@ -350,7 +396,7 @@ void Test::createRecursiveScript() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString testPathname{ directory + "/" + TEST_FILENAME };
|
const QString testPathname { directory + "/" + TEST_FILENAME };
|
||||||
QFileInfo fileInfo(testPathname);
|
QFileInfo fileInfo(testPathname);
|
||||||
if (fileInfo.exists()) {
|
if (fileInfo.exists()) {
|
||||||
// Current folder contains a test
|
// Current folder contains a test
|
||||||
|
@ -360,7 +406,7 @@ void Test::createRecursiveScript() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (testPathnames.length() <= 0) {
|
if (interactiveMode && testPathnames.length() <= 0) {
|
||||||
messageBox.information(0, "Failure", "No \"" + TEST_FILENAME + "\" files found");
|
messageBox.information(0, "Failure", "No \"" + TEST_FILENAME + "\" files found");
|
||||||
allTestsFilename.close();
|
allTestsFilename.close();
|
||||||
return;
|
return;
|
||||||
|
@ -370,10 +416,10 @@ void Test::createRecursiveScript() {
|
||||||
textStream << "autoTester.runRecursive();" << endl;
|
textStream << "autoTester.runRecursive();" << endl;
|
||||||
|
|
||||||
allTestsFilename.close();
|
allTestsFilename.close();
|
||||||
messageBox.information(0, "Success", "Script has been created");
|
|
||||||
}
|
if (interactiveMode) {
|
||||||
|
messageBox.information(0, "Success", "Script has been created");
|
||||||
void Test::createRecursiveScriptsRecursively() {
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Test::createTest() {
|
void Test::createTest() {
|
||||||
|
|
|
@ -28,6 +28,8 @@ public:
|
||||||
|
|
||||||
void createRecursiveScript();
|
void createRecursiveScript();
|
||||||
void createRecursiveScriptsRecursively();
|
void createRecursiveScriptsRecursively();
|
||||||
|
void createRecursiveScript(QString topLevelDirectory, bool interactiveMode);
|
||||||
|
|
||||||
void createTest();
|
void createTest();
|
||||||
void deleteOldSnapshots();
|
void deleteOldSnapshots();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue