From 2206f556c30e59cbcd0fc57516d04791292a38ba Mon Sep 17 00:00:00 2001 From: mrexodia Date: Sun, 5 Jun 2016 13:00:55 +0200 Subject: [PATCH] ready for testing automation --- cparser/main.cpp | 24 ++++++++++++++++++++---- cparser/tests/stringlit_error.bt | 1 + 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/cparser/main.cpp b/cparser/main.cpp index d3c6325..9e914ce 100644 --- a/cparser/main.cpp +++ b/cparser/main.cpp @@ -494,8 +494,7 @@ bool TestLexer(const string & filename) actual += line; })) { - printf("lex error in \"%s\": %s\n", filename.c_str(), lexer.Error.c_str()); - return false; + actual += StringUtils::sprintf("lex error in \"%s\": %s\n", filename.c_str(), lexer.Error.c_str()); } actual = StringUtils::Trim(actual); string expected; @@ -522,7 +521,6 @@ void RunLexerTests() bool DebugLexer(const string & filename) { - printf("Debugging \"%s\"\n", filename.c_str()); Lexer lexer; if (!lexer.ReadInputFile("tests\\" + filename)) { @@ -537,9 +535,27 @@ bool DebugLexer(const string & filename) return true; } +void GenerateExpected(const string & filename) +{ + Lexer lexer; + if (!lexer.ReadInputFile("tests\\" + filename)) + { + printf("failed to read \"%s\"\n", filename.c_str()); + return; + } + string actual; + if (!lexer.TestLex([&](const string & line) + { + actual += line; + })) + { + actual += StringUtils::sprintf("lex error in \"%s\": %s\n", filename.c_str(), lexer.Error.c_str()); + } + FileHelper::WriteAllText("tests\\expected\\" + filename + ".lextest", actual); +} + int main() { - DebugLexer(testFiles[82]); RunLexerTests(); system("pause"); return 0; diff --git a/cparser/tests/stringlit_error.bt b/cparser/tests/stringlit_error.bt index e69de29..a173626 100644 --- a/cparser/tests/stringlit_error.bt +++ b/cparser/tests/stringlit_error.bt @@ -0,0 +1 @@ +string test = "this is a test