mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 01:00:44 +02:00
Ready for testing.
This commit is contained in:
parent
dff98f462f
commit
b2fb7a737b
3 changed files with 65 additions and 100 deletions
|
@ -40,7 +40,7 @@ Nitpick::Nitpick(QWidget* parent) : QMainWindow(parent) {
|
||||||
|
|
||||||
_ui.plainTextEdit->setReadOnly(true);
|
_ui.plainTextEdit->setReadOnly(true);
|
||||||
|
|
||||||
setWindowTitle("Nitpick - v2.0.1");
|
setWindowTitle("Nitpick - v2.1.0");
|
||||||
}
|
}
|
||||||
|
|
||||||
Nitpick::~Nitpick() {
|
Nitpick::~Nitpick() {
|
||||||
|
|
|
@ -758,47 +758,66 @@ void Test::createAllRecursiveScripts() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createAllRecursiveScripts(_testsRootDirectory);
|
||||||
createRecursiveScript(_testsRootDirectory, false);
|
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");
|
QMessageBox::information(0, "Success", "Scripts have been created");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Test::createRecursiveScript(const QString& topLevelDirectory, bool interactiveMode) {
|
void Test::createAllRecursiveScripts(const QString& directory) {
|
||||||
const QString recursiveTestsScriptName("testRecursive.js");
|
QDirIterator it(directory, QDirIterator::Subdirectories);
|
||||||
const QString recursiveTestsFilename(topLevelDirectory + "/" + recursiveTestsScriptName);
|
|
||||||
|
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);
|
QFile recursiveTestsFile(recursiveTestsFilename);
|
||||||
if (!recursiveTestsFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
if (!recursiveTestsFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__),
|
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);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
@ -812,72 +831,16 @@ void Test::createRecursiveScript(const QString& topLevelDirectory, bool interact
|
||||||
QString user = nitpick->getSelectedUser();
|
QString user = nitpick->getSelectedUser();
|
||||||
|
|
||||||
textStream << "PATH_TO_THE_REPO_PATH_UTILS_FILE = \"https://raw.githubusercontent.com/" + user + "/hifi_tests/" + branch +
|
textStream << "PATH_TO_THE_REPO_PATH_UTILS_FILE = \"https://raw.githubusercontent.com/" + user + "/hifi_tests/" + branch +
|
||||||
"/tests/utils/branchUtils.js\";"
|
"/tests/utils/branchUtils.js\";"
|
||||||
<< endl;
|
<< endl;
|
||||||
textStream << "Script.include(PATH_TO_THE_REPO_PATH_UTILS_FILE);" << endl;
|
textStream << "Script.include(PATH_TO_THE_REPO_PATH_UTILS_FILE);" << endl << endl;
|
||||||
textStream << "var nitpick = createNitpick(Script.resolvePath(\".\"));" << endl << endl;
|
|
||||||
|
|
||||||
textStream << "var testsRootPath = nitpick.getTestsRootPath();" << endl << endl;
|
textStream << "if (typeof nitpick === 'undefined') var nitpick = createNitpick(Script.resolvePath(\".\"));" << endl;
|
||||||
|
textStream << "if (typeof testsRootPath === 'undefined') 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 << "nitpick.enableRecursive();" << endl;
|
textStream << "nitpick.enableRecursive();" << endl;
|
||||||
textStream << "nitpick.enableAuto();" << endl << 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
|
// Now include the test scripts
|
||||||
for (int i = 0; i < directories.length(); ++i) {
|
for (int i = 0; i < directories.length(); ++i) {
|
||||||
includeTest(textStream, directories.at(i));
|
includeTest(textStream, directories.at(i));
|
||||||
|
@ -928,7 +891,6 @@ void Test::createTestsOutline() {
|
||||||
QString directory = it.next();
|
QString directory = it.next();
|
||||||
|
|
||||||
// Only process directories
|
// Only process directories
|
||||||
QDir dir;
|
|
||||||
if (!isAValidDirectory(directory)) {
|
if (!isAValidDirectory(directory)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,9 +72,11 @@ public:
|
||||||
|
|
||||||
void updateTestRailRunResult();
|
void updateTestRailRunResult();
|
||||||
|
|
||||||
void createRecursiveScript();
|
|
||||||
void createAllRecursiveScripts();
|
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 compareImageLists();
|
||||||
int checkTextResults();
|
int checkTextResults();
|
||||||
|
@ -109,7 +111,8 @@ private:
|
||||||
bool _isRunningFromCommandLine{ false };
|
bool _isRunningFromCommandLine{ false };
|
||||||
bool _isRunningInAutomaticTestRun{ 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_FOLDER { "TestResults" };
|
||||||
const QString TEST_RESULTS_FILENAME { "TestResults.txt" };
|
const QString TEST_RESULTS_FILENAME { "TestResults.txt" };
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue