-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to run test scripts (will use for script-based testing later)
- Loading branch information
sam
committed
May 30, 2018
1 parent
b3387cb
commit f496af6
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "test/functionaltestrunner.h" | ||
|
||
#include <cassert> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "common/util.h" | ||
#include "script/scriptrunner.h" | ||
|
||
namespace geometrize | ||
{ | ||
|
||
namespace test | ||
{ | ||
|
||
void runSelfTests(const std::string& testScriptsDirectory) | ||
{ | ||
if(!geometrize::util::directoryExists(testScriptsDirectory)) { | ||
assert(0 && "Given test scripts directory does not exist"); | ||
return; | ||
} | ||
|
||
const std::vector<std::string> testScripts{geometrize::util::getScriptsForPath(testScriptsDirectory)}; | ||
|
||
if(testScripts.empty()) { | ||
assert(0 && "Did not find any test scripts in the given test directory"); | ||
return; | ||
} | ||
|
||
for(const auto& scriptPath : testScripts) { | ||
const std::string scriptCode = geometrize::util::readFileAsString(scriptPath); | ||
if(scriptCode.empty()) { | ||
assert(0 && "Failed to read script file or it was empty"); | ||
} | ||
geometrize::script::runScript(scriptCode); | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
namespace geometrize | ||
{ | ||
|
||
namespace test | ||
{ | ||
|
||
void runSelfTests(const std::string& testScriptsDirectory); | ||
|
||
} | ||
|
||
} |