Added testing! call kraken like so ./kraken --test ../path/to/test/name_of_test_without_extention This will make kraken compile and run name_of_test_without_extention.krak and compare the output it generates on stdout to name_of_test_without_extention.expected_results. If they pass, then it records the pass, if not, it records the failure and saves the intermediate files generated. It has revealed some bugs which I will fix in upcoming commits.

This commit is contained in:
Nathan Braswell
2014-05-20 22:21:07 -04:00
parent 39f945940d
commit 2566cbb67c
26 changed files with 430 additions and 2 deletions

View File

@@ -16,16 +16,34 @@
#include "CGenerator.h"
#include "util.h"
#include "Tester.h"
int main(int argc, char* argv[]) {
std::vector<std::string> includePaths;
includePaths.push_back(""); //Local
if (argc == 2 && std::string(argv[1]) == "--test") {
if (argc >= 2 && std::string(argv[1]) == "--test") {
StringReader::test();
RegEx::test();
Lexer::test();
//std::cout << strSlice("123", 0, -1) << std::endl;
if (argc >= 3) {
std::string testResults, line;
int passed = 0, failed = 0;
Tester test(argv[0], "../krakenGrammer.kgm");
for (int i = 2; i < argc; i++) {
bool result = test.run(argv[i]);
if (result)
line = std::string(argv[i]) + "\t\tpassed!\n", passed++;
else
line = std::string(argv[i]) + "\t\tFAILED!\n", failed++;
std::cout << line << std::endl;
testResults += line;
}
std::cout << "===========Done Testing===========" << std::endl;
std::cout << testResults << std::endl;
std::cout << "Test results: " << passed << "/" << passed+failed << std::endl;
}
return 0;
}
std::string krakenDir = argv[0];