diff --git a/tools/nitpick/src/Nitpick.cpp b/tools/nitpick/src/Nitpick.cpp
index 78ed0ca0af..fa53730ce0 100644
--- a/tools/nitpick/src/Nitpick.cpp
+++ b/tools/nitpick/src/Nitpick.cpp
@@ -40,7 +40,7 @@ Nitpick::Nitpick(QWidget* parent) : QMainWindow(parent) {
_ui.plainTextEdit->setReadOnly(true);
- setWindowTitle("Nitpick - v2.0.1");
+ setWindowTitle("Nitpick - v2.1.0");
}
Nitpick::~Nitpick() {
diff --git a/tools/nitpick/src/Test.cpp b/tools/nitpick/src/Test.cpp
index 2e62296146..20d5ad89a6 100644
--- a/tools/nitpick/src/Test.cpp
+++ b/tools/nitpick/src/Test.cpp
@@ -758,47 +758,66 @@ void Test::createAllRecursiveScripts() {
return;
}
+ createAllRecursiveScripts(_testsRootDirectory);
createRecursiveScript(_testsRootDirectory, false);
-
- QDirIterator it(_testsRootDirectory, 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, 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);
- }
- }
-
QMessageBox::information(0, "Success", "Scripts have been created");
}
-void Test::createRecursiveScript(const QString& topLevelDirectory, bool interactiveMode) {
- const QString recursiveTestsScriptName("testRecursive.js");
- const QString recursiveTestsFilename(topLevelDirectory + "/" + recursiveTestsScriptName);
+void Test::createAllRecursiveScripts(const QString& directory) {
+ QDirIterator it(directory, QDirIterator::Subdirectories);
+
+ while (it.hasNext()) {
+ QString nextDirectory = it.next();
+ if (isAValidDirectory(nextDirectory)) {
+ createAllRecursiveScripts(nextDirectory);
+ createRecursiveScript(nextDirectory, false);
+ }
+ }
+}
+
+void Test::createRecursiveScript(const QString& directory, bool interactiveMode) {
+ // If folder contains a test, then we are at a leaf
+ const QString testPathname{ directory + "/" + TEST_FILENAME };
+ if (QFileInfo(testPathname).exists()) {
+ return;
+ }
+
+ // Directories are included in reverse order. The nitpick scripts use a stack mechanism,
+ // so this ensures that the tests run in alphabetical order (a convenience when debugging)
+ QStringList directories;
+ QDirIterator it(directory);
+ while (it.hasNext()) {
+ QString subDirectory = it.next();
+
+ // Only process directories
+ if (!isAValidDirectory(subDirectory)) {
+ continue;
+ }
+
+ const QString testPathname{ subDirectory + "/" + TEST_FILENAME };
+ if (QFileInfo(testPathname).exists()) {
+ // Current folder contains a test script
+ directories.push_front(testPathname);
+ }
+
+ const QString testRecursivePathname{ subDirectory + "/" + TEST_RECURSIVE_FILENAME };
+ if (QFileInfo(testRecursivePathname).exists()) {
+ // Current folder contains a recursive script
+ directories.push_front(testRecursivePathname);
+ }
+ }
+
+ // If 'directories' is empty, this means that this recursive script has no tests to call, so it is redundant
+ if (directories.length() == 0) {
+ return;
+ }
+
+ // Open the recursive script file
+ const QString recursiveTestsFilename(directory + "/" + TEST_RECURSIVE_FILENAME);
QFile recursiveTestsFile(recursiveTestsFilename);
if (!recursiveTestsFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__),
- "Failed to create \"" + recursiveTestsScriptName + "\" in directory \"" + topLevelDirectory + "\"");
+ "Failed to create \"" + TEST_RECURSIVE_FILENAME + "\" in directory \"" + directory + "\"");
exit(-1);
}
@@ -812,79 +831,26 @@ void Test::createRecursiveScript(const QString& topLevelDirectory, bool interact
QString user = nitpick->getSelectedUser();
textStream << "PATH_TO_THE_REPO_PATH_UTILS_FILE = \"https://raw.githubusercontent.com/" + user + "/hifi_tests/" + branch +
- "/tests/utils/branchUtils.js\";"
- << endl;
- textStream << "Script.include(PATH_TO_THE_REPO_PATH_UTILS_FILE);" << endl;
- textStream << "var nitpick = createNitpick(Script.resolvePath(\".\"));" << endl << endl;
+ "/tests/utils/branchUtils.js\";"
+ << endl;
+ textStream << "Script.include(PATH_TO_THE_REPO_PATH_UTILS_FILE);" << endl << endl;
- textStream << "var testsRootPath = nitpick.getTestsRootPath();" << endl << endl;
-
- // Wait 10 seconds before starting
- textStream << "if (typeof Test !== 'undefined') {" << endl;
- textStream << " Test.wait(10000);" << endl;
- textStream << "};" << endl << endl;
+ textStream << "if (typeof nitpick === 'undefined') nitpick = createNitpick(Script.resolvePath(\".\"));" << endl;
+ textStream << "if (typeof testsRootPath === 'undefined') testsRootPath = nitpick.getTestsRootPath();" << endl << endl;
textStream << "nitpick.enableRecursive();" << endl;
textStream << "nitpick.enableAuto();" << endl << endl;
- // This is used to verify that the recursive test contains at least one test
- bool testFound{ false };
-
- // Directories are included in reverse order. The nitpick scripts use a stack mechanism,
- // so this ensures that the tests run in alphabetical order (a convenience when debugging)
- QStringList directories;
-
- // First test if top-level folder has a test.js file
- const QString testPathname{ topLevelDirectory + "/" + TEST_FILENAME };
- QFileInfo fileInfo(testPathname);
- if (fileInfo.exists()) {
- // Current folder contains a test
- directories.push_front(testPathname);
-
- testFound = true;
- }
-
- QDirIterator it(topLevelDirectory, QDirIterator::Subdirectories);
- while (it.hasNext()) {
- QString directory = it.next();
-
- // Only process directories
- QDir dir(directory);
- if (!isAValidDirectory(directory)) {
- continue;
- }
-
- const QString testPathname{ directory + "/" + TEST_FILENAME };
- QFileInfo fileInfo(testPathname);
- if (fileInfo.exists()) {
- // Current folder contains a test
- directories.push_front(testPathname);
-
- testFound = true;
- }
- }
-
- if (interactiveMode && !testFound) {
- QMessageBox::information(0, "Failure", "No \"" + TEST_FILENAME + "\" files found");
- recursiveTestsFile.close();
- return;
- }
-
- // If 'directories' is empty, this means that this recursive script has no tests to call, so it is redundant
- // The script will be closed and deleted
- if (directories.length() == 0) {
- recursiveTestsFile.close();
- QFile::remove(recursiveTestsFilename);
- return;
- }
-
// Now include the test scripts
for (int i = 0; i < directories.length(); ++i) {
includeTest(textStream, directories.at(i));
}
textStream << endl;
- textStream << "nitpick.runRecursive();" << endl;
+ textStream << "if (typeof runningRecursive === 'undefined') {" << endl;
+ textStream << " runningRecursive = true;" << endl;
+ textStream << " nitpick.runRecursive();" << endl;
+ textStream << "}" << endl << endl;
recursiveTestsFile.close();
}
@@ -928,7 +894,6 @@ void Test::createTestsOutline() {
QString directory = it.next();
// Only process directories
- QDir dir;
if (!isAValidDirectory(directory)) {
continue;
}
diff --git a/tools/nitpick/src/Test.h b/tools/nitpick/src/Test.h
index aafd2f5711..842e4bdb48 100644
--- a/tools/nitpick/src/Test.h
+++ b/tools/nitpick/src/Test.h
@@ -72,9 +72,11 @@ public:
void updateTestRailRunResult();
- void createRecursiveScript();
void createAllRecursiveScripts();
- void createRecursiveScript(const QString& topLevelDirectory, bool interactiveMode);
+ void createAllRecursiveScripts(const QString& directory);
+
+ void createRecursiveScript();
+ void createRecursiveScript(const QString& directory, bool interactiveMode);
int compareImageLists();
int checkTextResults();
@@ -109,7 +111,8 @@ private:
bool _isRunningFromCommandLine{ false };
bool _isRunningInAutomaticTestRun{ false };
- const QString TEST_FILENAME { "test.js" };
+ const QString TEST_FILENAME{ "test.js" };
+ const QString TEST_RECURSIVE_FILENAME{ "testRecursive.js" };
const QString TEST_RESULTS_FOLDER { "TestResults" };
const QString TEST_RESULTS_FILENAME { "TestResults.txt" };
diff --git a/tools/nitpick/ui/Nitpick.ui b/tools/nitpick/ui/Nitpick.ui
index 319452233f..16aaa9594d 100644
--- a/tools/nitpick/ui/Nitpick.ui
+++ b/tools/nitpick/ui/Nitpick.ui
@@ -43,7 +43,7 @@
- 3
+ 0
@@ -85,7 +85,7 @@
- Create all MD files
+ Create all MD files
@@ -124,7 +124,7 @@
- Create all Recursive Scripts
+ Create all Recursive Scripts