aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-10-13 15:50:16 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-04 08:29:23 +0200
commit8caa111ec27dc21973b764d9892e7100f4bd2628 (patch)
treeedf31f67a28173698b2cfc5e30bfbcf922d04f4b
parent5381b25c51475c0c7a2f39e9f6efa623f621ef3e (diff)
Add testscript runner interface and implementation stub
-rw-r--r--build2/buildfile1
-rw-r--r--build2/test/script/parser10
-rw-r--r--build2/test/script/parser.cxx26
-rw-r--r--build2/test/script/runner36
-rw-r--r--build2/test/script/runner.cxx22
5 files changed, 85 insertions, 10 deletions
diff --git a/build2/buildfile b/build2/buildfile
index 6e71856..28d9b38 100644
--- a/build2/buildfile
+++ b/build2/buildfile
@@ -77,6 +77,7 @@ exe{b}: \
test/{hxx cxx}{ rule } \
test/script/{hxx cxx}{ lexer } \
test/script/{hxx cxx}{ parser } \
+test/script/{hxx cxx}{ runner } \
test/script/{hxx cxx}{ script } \
$libs
diff --git a/build2/test/script/parser b/build2/test/script/parser
index 0ba4710..55dc003 100644
--- a/build2/test/script/parser
+++ b/build2/test/script/parser
@@ -21,14 +21,19 @@ namespace build2
namespace script
{
class lexer;
+ class runner;
class parser: protected build2::parser
{
public:
// Issue diagnostics and throw failed in case of an error.
//
- script
- parse (istream&, const path& name, target& test, target& script);
+ void
+ parse (istream&,
+ const path& name,
+ target& test,
+ target& script,
+ runner&);
// Recursive descent parser.
//
@@ -60,6 +65,7 @@ namespace build2
lexer* lexer_;
script* script_;
+ runner* runner_;
};
}
}
diff --git a/build2/test/script/parser.cxx b/build2/test/script/parser.cxx
index ce867b3..b99ab09 100644
--- a/build2/test/script/parser.cxx
+++ b/build2/test/script/parser.cxx
@@ -5,6 +5,7 @@
#include <build2/test/script/parser>
#include <build2/test/script/lexer>
+#include <build2/test/script/runner>
using namespace std;
@@ -16,8 +17,12 @@ namespace build2
{
using type = token_type;
- script parser::
- parse (istream& is, const path& p, target& test_t, target& script_t)
+ void parser::
+ parse (istream& is,
+ const path& p,
+ target& test_t,
+ target& script_t,
+ runner& r)
{
path_ = &p;
@@ -25,8 +30,10 @@ namespace build2
lexer_ = &l;
base_parser::lexer_ = &l;
- script r (test_t, script_t);
- script_ = &r;
+ script s (test_t, script_t);
+ script_ = &s;
+
+ runner_ = &r;
token t (type::eos, false, 0, 0);
type tt;
@@ -36,8 +43,6 @@ namespace build2
if (tt != type::eos)
fail (t) << "unexpected " << t;
-
- return r;
}
void parser::
@@ -498,8 +503,7 @@ namespace build2
expire_mode (); // Done parsing test-line.
// Parse here-document fragments in the order they were mentioned on
- // the command line. The end marker is temporarily stored as the
- // redirect's value.
+ // the command line.
//
if (!hd.empty ())
{
@@ -509,11 +513,17 @@ namespace build2
mode (lexer_mode::here_line);
next (t, tt);
+ // The end marker is temporarily stored as the redirect's value.
+ //
for (redirect& r: hd)
r.value = parse_here_document (t, tt, r.value);
expire_mode ();
}
+
+ // Now that we have all the pieces, run the test.
+ //
+ runner_->run (ts);
}
command_exit parser::
diff --git a/build2/test/script/runner b/build2/test/script/runner
new file mode 100644
index 0000000..74913c8
--- /dev/null
+++ b/build2/test/script/runner
@@ -0,0 +1,36 @@
+// file : build2/test/script/runner -*- C++ -*-
+// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+#ifndef BUILD2_TEST_SCRIPT_RUNNER
+#define BUILD2_TEST_SCRIPT_RUNNER
+
+#include <build2/types>
+#include <build2/utility>
+
+#include <build2/test/script/script>
+
+namespace build2
+{
+ namespace test
+ {
+ namespace script
+ {
+ class runner
+ {
+ public:
+ virtual void
+ run (const test&) = 0;
+ };
+
+ class concurrent_runner: public runner
+ {
+ public:
+ virtual void
+ run (const test&) override;
+ };
+ }
+ }
+}
+
+#endif // BUILD2_TEST_SCRIPT_RUNNER
diff --git a/build2/test/script/runner.cxx b/build2/test/script/runner.cxx
new file mode 100644
index 0000000..3789281
--- /dev/null
+++ b/build2/test/script/runner.cxx
@@ -0,0 +1,22 @@
+// file : build2/test/script/runner.cxx -*- C++ -*-
+// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+#include <build2/test/script/runner>
+
+using namespace std;
+
+namespace build2
+{
+ namespace test
+ {
+ namespace script
+ {
+ void concurrent_runner::
+ run (const test&)
+ {
+ assert (false); // @@ TODO
+ }
+ }
+ }
+}