diff options
author | Oliver Reiche <oliver.reiche@huawei.com> | 2022-09-26 11:32:45 +0200 |
---|---|---|
committer | Oliver Reiche <oliver.reiche@huawei.com> | 2022-10-05 15:13:54 +0200 |
commit | 5a4afcee7961bba616ac7e77e8e5ee13ed49c3f9 (patch) | |
tree | 2034bc075178c574b9b977c767e320121476b380 | |
parent | b5b2a07bf5b348e61ddfcf7579607adaad31456d (diff) | |
download | justbuild-5a4afcee7961bba616ac7e77e8e5ee13ed49c3f9.tar.gz |
Test: Add tests for 'env' expression
-rw-r--r-- | test/buildtool/build_engine/expression/expression.test.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/buildtool/build_engine/expression/expression.test.cpp b/test/buildtool/build_engine/expression/expression.test.cpp index a1c434e9..dec3b02f 100644 --- a/test/buildtool/build_engine/expression/expression.test.cpp +++ b/test/buildtool/build_engine/expression/expression.test.cpp @@ -1308,6 +1308,29 @@ TEST_CASE("Expression Evaluation", "[expression]") { // NOLINT CHECK(result == Expression::FromJson(R"("foofoofoofoo")"_json)); } + SECTION("env expression") { + auto env = Configuration{Expression::FromJson( + R"({"foo": "FOO_STRING", "bar": "BAR_STRING"})"_json)}; + + auto expr = Expression::FromJson(R"( + { "type": "env" + , "vars": ["bar", "baz"] + })"_json); + REQUIRE(expr); + auto result = expr.Evaluate(env, fcts); + REQUIRE(result); + REQUIRE(result->IsMap()); + CHECK(result == Expression::FromJson( + R"({"bar": "BAR_STRING", "baz": null})"_json)); + + auto empty = Expression::FromJson(R"({"type": "env"})"_json); + REQUIRE(empty); + auto none = empty.Evaluate(env, fcts); + REQUIRE(none); + REQUIRE(none->IsMap()); + CHECK(none == Expression::kEmptyMap); + } + SECTION("concat_target_name expression") { auto expr = Expression::FromJson(R"( { "type": "concat_target_name" |