From de9be96acd62e732baa3d28f9867bfe4afd9d412 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Mon, 20 Aug 2018 08:36:10 -0700 Subject: [PATCH] Deal correctly with missing test.js --- tools/auto-tester/src/Test.cpp | 22 ++++++++++++++-------- tools/auto-tester/src/Test.h | 4 ++-- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/tools/auto-tester/src/Test.cpp b/tools/auto-tester/src/Test.cpp index ee4dc5fc88..49ea3172e0 100644 --- a/tools/auto-tester/src/Test.cpp +++ b/tools/auto-tester/src/Test.cpp @@ -484,8 +484,10 @@ void Test::createAllFilesSetup() { // The folder selected must contain a script named "test.js", the file produced is named "test.md" void Test::createMDFile() { createFileSetup(); - createMDFile(_testDirectory); - QMessageBox::information(0, "Success", "MD file has been created"); + + if (createMDFile(_testDirectory)) { + QMessageBox::information(0, "Success", "MD file has been created"); + } } void Test::createAllMDFiles() { @@ -518,13 +520,13 @@ void Test::createAllMDFiles() { QMessageBox::information(0, "Success", "MD files have been created"); } -void Test::createMDFile(const QString& directory) { +bool Test::createMDFile(const QString& directory) { // Verify folder contains test.js file QString testFileName(directory + "/" + TEST_FILENAME); QFileInfo testFileInfo(testFileName); if (!testFileInfo.exists()) { QMessageBox::critical(0, "Error", "Could not find file: " + TEST_FILENAME); - return; + return false; } ExtractedText testScriptLines = getTestScriptLines(testFileName); @@ -564,12 +566,15 @@ void Test::createMDFile(const QString& directory) { } mdFile.close(); + return true; } void Test::createTestAutoScript() { createFileSetup(); - createTestAutoScript(_testDirectory); - QMessageBox::information(0, "Success", "'autoTester.js` script has been created"); + + if (createTestAutoScript(_testDirectory)) { + QMessageBox::information(0, "Success", "'autoTester.js` script has been created"); + } } void Test::createAllTestAutoScripts() { @@ -602,13 +607,13 @@ void Test::createAllTestAutoScripts() { QMessageBox::information(0, "Success", "'autoTester.js' scripts have been created"); } -void Test::createTestAutoScript(const QString& directory) { +bool Test::createTestAutoScript(const QString& directory) { // Verify folder contains test.js file QString testFileName(directory + "/" + TEST_FILENAME); QFileInfo testFileInfo(testFileName); if (!testFileInfo.exists()) { QMessageBox::critical(0, "Error", "Could not find file: " + TEST_FILENAME); - return; + return false; } QString testAutoScriptFilename(directory + "/" + "testAuto.js"); @@ -628,6 +633,7 @@ void Test::createTestAutoScript(const QString& directory) { stream << "Script.include('./test.js?raw=true');\n"; testAutoScriptFile.close(); + return true; } // Creates a single script in a user-selected folder. diff --git a/tools/auto-tester/src/Test.h b/tools/auto-tester/src/Test.h index 57e6ccd90f..09363b17ee 100644 --- a/tools/auto-tester/src/Test.h +++ b/tools/auto-tester/src/Test.h @@ -55,11 +55,11 @@ public: void createMDFile(); void createAllMDFiles(); - void createMDFile(const QString& directory); + bool createMDFile(const QString& directory); void createTestAutoScript(); void createAllTestAutoScripts(); - void createTestAutoScript(const QString& directory); + bool createTestAutoScript(const QString& directory); void createTestRailTestCases(); void createTestRailRun();