From 8205a652a4616aea84f24ff31235ea9941f47db6 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 7 Mar 2017 10:24:02 +0200 Subject: Specify config.test.output variable --- build2/test/common | 8 ++++++++ build2/test/init.cxx | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) (limited to 'build2/test') diff --git a/build2/test/common b/build2/test/common index 44c7bf8..8e4235b 100644 --- a/build2/test/common +++ b/build2/test/common @@ -14,8 +14,16 @@ namespace build2 { namespace test { + enum class output_before {fail, warn, clean}; + enum class output_after {clean, keep}; + struct common { + // The config.test.output values. + // + output_before before; + output_after after; + // The config.test query interface. // const names* test_ = nullptr; // The config.test value if any. diff --git a/build2/test/init.cxx b/build2/test/init.cxx index fd8db99..a367206 100644 --- a/build2/test/init.cxx +++ b/build2/test/init.cxx @@ -48,6 +48,11 @@ namespace build2 // vp.insert ("config.test", true); + // Test working directory before/after cleanup (see Testscript spec for + // semantics). + // + vp.insert ("config.test.output", true); + // Note: none are overridable. // // The test variable is a name which can be a path (with the @@ -130,6 +135,36 @@ namespace build2 m.root_ = s; } + // config.test.output + // + if (lookup l = config::omitted (rs, "config.test.output").first) + { + const name_pair& p (cast (l)); + + // If second half is empty, then first is the after value. + // + const name& a (p.second.empty () ? p.first : p.second); // after + const name& b (p.second.empty () ? p.second : p.first); // before + + // Parse and validate. + // + if (!b.simple ()) + fail << "invalid config.test.output before value '" << b << "'"; + + if (!a.simple ()) + fail << "invalid config.test.output after value '" << a << "'"; + + if (a.value == "clean") m.after = output_after::clean; + else if (a.value == "keep") m.after = output_after::keep; + else fail << "invalid config.test.output after value '" << a << "'"; + + if (b.value == "fail") m.before = output_before::fail; + else if (b.value == "warn") m.before = output_before::warn; + else if (b.value == "clean") m.before = output_before::clean; + else if (b.value == "") m.before = output_before::clean; + else fail << "invalid config.test.output before value '" << b << "'"; + } + //@@ TODO: Need ability to specify extra diff options (e.g., // --strip-trailing-cr, now hardcoded). // -- cgit v1.1