Adds assert function in batch mode 30/166330/31
authorRadoslaw Cybulski <r.cybulski@partner.samsung.com>
Mon, 8 Jan 2018 12:11:08 +0000 (13:11 +0100)
committerRadoslaw Cybulski <r.cybulski@partner.samsung.com>
Tue, 23 Jan 2018 13:52:13 +0000 (14:52 +0100)
Adds assert function, which expects boolean argument.
If the argument is false, then an exception is raised and
batch mode will end with failure.

Change-Id: Id7f6114623cdff0f1962099b3b79e96066be5bf6

src/batch/BatchRunner.cpp

index c883e2e..f1ef3a9 100644 (file)
@@ -244,6 +244,12 @@ struct TestExecutor : ExecutorInterface {
                                return convert(pt);
                        }
                };
+               variables["assert"] = detail::UserFunctionType<bool> {
+                       [&](EvaluationContext & ec, bool condition) -> EvaluationValue {
+                               if (!condition) throw EvaluationFailure{} << "assertion failed";
+                               return {};
+                       }
+               };
                variables["wait_for_application"] = detail::UserFunctionType<std::string> {
                        [&](EvaluationContext & ec, std::string name) -> EvaluationValue {
                                auto h = contextInfo.lock();