Minor refactor in batch test 92/165892/31
authorRadoslaw Cybulski <r.cybulski@partner.samsung.com>
Thu, 4 Jan 2018 15:55:28 +0000 (16:55 +0100)
committerRadoslaw Cybulski <r.cybulski@partner.samsung.com>
Tue, 23 Jan 2018 11:37:24 +0000 (12:37 +0100)
Adds code, that catches and prints exception, when executing
test of batch mode.

Change-Id: Ief383770d574ee9aa0337fd05d6806dff47d646c

tests/no-ui-scenarios/BatchExecTests.cpp

index 9b46e07..8e69b5e 100644 (file)
@@ -139,7 +139,17 @@ TEST(TestExec, simpleParser)
        };
        TestExecutor exec(std::move(vars));
        EvaluationContext ec { exec };
-       ASSERT_NO_THROW(result->evaluate(ec));
+       try {
+               result->evaluate(ec);
+       } catch (EvaluationFailure e) {
+               std::ostringstream os;
+               if (e.hasLocation())
+                       os << e.location().toString() << ": ";
+               os << e.message();
+               FAIL() << os.str();
+       } catch (...) {
+               FAIL() << "unknown exception";
+       }
        ASSERT_TRUE(!result2.empty());
        ASSERT_EQ(result2, "1,qwe,rty,true");
 }
@@ -160,6 +170,12 @@ protected:
                auto tokens = lexTest(error, "test", txt);
                ASSERT_TRUE(error.empty()) << error;
 
+               // {
+               //      size_t index = 0;
+               //      for(auto &t : tokens)
+               //              std::cout << t.location().toString() << ": " << (index++) << " '" << t.text() << "' " << toString(t.type()) << "\n";
+               // }
+
                std::vector<std::string> errors;
                auto result = parseTokens(errors, tokens);
 
@@ -171,7 +187,7 @@ protected:
 
                // {
                //      std::ostringstream tmp;
-               //      result->debug(tmp, 0);
+               //      result->printSelfInfo(tmp, 0);
                //      std::cout << tmp.str();
                // }