diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-08-28 18:08:45 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-08-28 18:08:45 +0200 |
commit | a6adee41b633918146c70080463cd52688218fd1 (patch) | |
tree | 06440e712a93114ccc346c13cebfe8aa5d45bcae | |
parent | 6ad4a629e0a790ad60352a94ea25359f38700b2f (diff) |
Diagnose NULL test.target variable value
-rw-r--r-- | build2/test/script/runner.cxx | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/build2/test/script/runner.cxx b/build2/test/script/runner.cxx index 2daf898..0ceed5b 100644 --- a/build2/test/script/runner.cxx +++ b/build2/test/script/runner.cxx @@ -168,6 +168,22 @@ namespace build2 } } + // Return the value of the test.target variable. + // + static inline const target_triplet& + test_target (const script& s) + { + // @@ Would be nice to use cached value from test::common_data. + // + if (auto r = cast_null<target_triplet> (s.test_target["test.target"])) + return *r; + + // We set it to default value in init() so it can only be NULL if the + // user resets it. + // + fail << "invalid test.target value" << endf; + } + // Transform string according to here-* redirect modifiers from the {/} // set. // @@ -182,10 +198,7 @@ namespace build2 // For targets other than Windows leave the string intact. // - // @@ Would be nice to use cached value from test::common_data. - // - if (cast<target_triplet> (scr.test_target["test.target"]).class_ != - "windows") + if (test_target (scr).class_ != "windows") return s; // Convert forward slashes to Windows path separators (escape for @@ -288,7 +301,7 @@ namespace build2 sp.clean_special (eop); } - // Use diff utility for the comparison. + // Use the diff utility for comparison. // path dp ("diff"); process_path pp (run_search (dp, true)); @@ -297,10 +310,7 @@ namespace build2 // Ignore Windows newline fluff if that's what we are running on. // - // @@ Would be nice to use cached value from test::common_data. - // - if (cast<target_triplet> ( - sp.root->test_target["test.target"]).class_ == "windows") + if (test_target (*sp.root).class_ == "windows") args.push_back ("--strip-trailing-cr"); args.push_back (eop.string ().c_str ()); |