aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/test/script
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-11-08 00:17:47 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2019-11-11 18:41:06 +0300
commit07e0d37aba5cd72ff2d53eda654a4d5466e38627 (patch)
tree80ab6452b0fc489833fb911926ca872e51ec1575 /libbuild2/test/script
parent5935476651cd063a53d08ec33b04513a7a8127e3 (diff)
Use path_name for `-` to stdin/stdout translation
Diffstat (limited to 'libbuild2/test/script')
-rw-r--r--libbuild2/test/script/lexer.hxx2
-rw-r--r--libbuild2/test/script/lexer.test.cxx2
-rw-r--r--libbuild2/test/script/parser.cxx31
-rw-r--r--libbuild2/test/script/parser.hxx2
-rw-r--r--libbuild2/test/script/runner.cxx2
-rw-r--r--libbuild2/test/script/script.hxx4
6 files changed, 26 insertions, 17 deletions
diff --git a/libbuild2/test/script/lexer.hxx b/libbuild2/test/script/lexer.hxx
index 4083161..1b26224 100644
--- a/libbuild2/test/script/lexer.hxx
+++ b/libbuild2/test/script/lexer.hxx
@@ -48,7 +48,7 @@ namespace build2
// Note that neither the name nor escape arguments are copied.
//
lexer (istream& is,
- const path& name,
+ const path_name& name,
lexer_mode m,
const char* escapes = nullptr)
: base_lexer (is, name, 1 /* line */,
diff --git a/libbuild2/test/script/lexer.test.cxx b/libbuild2/test/script/lexer.test.cxx
index fc26acc..f6610e2 100644
--- a/libbuild2/test/script/lexer.test.cxx
+++ b/libbuild2/test/script/lexer.test.cxx
@@ -53,7 +53,7 @@ namespace build2
m == lexer_mode::description_line ||
m == lexer_mode::variable);
- path in ("<stdin>"); // @@ PATH_NAME TODO
+ path_name in ("<stdin>");
lexer l (cin, in, u ? lexer_mode::command_line : m);
if (u)
l.mode (m);
diff --git a/libbuild2/test/script/parser.cxx b/libbuild2/test/script/parser.cxx
index d5e437b..376d68f 100644
--- a/libbuild2/test/script/parser.cxx
+++ b/libbuild2/test/script/parser.cxx
@@ -54,7 +54,8 @@ namespace build2
void parser::
pre_parse (istream& is, script& s)
{
- path_ = &*s.paths_.insert (s.script_target.path ()).first;
+ path_ = &*s.paths_.insert (
+ path_name_value (s.script_target.path ())).first;
pre_parse_ = true;
@@ -78,7 +79,7 @@ namespace build2
// Start location of the implied script group is the beginning of
// the file. End location -- end of the file.
//
- group_->start_loc_ = location (path_, 1, 1);
+ group_->start_loc_ = location (*path_, 1, 1);
token t (pre_parse_scope_body ());
@@ -1007,29 +1008,37 @@ namespace build2
// It may be tempting to use relative paths in diagnostics but it
// most likely will be misguided.
//
- auto enter_path = [this] (string n) -> const path&
+ auto enter_path = [this] (string n) -> const path_name_value&
{
path p (move (n));
if (p.relative ())
- p = path_->directory () / p;
+ {
+ // There is always the testscript path (path_ refers to an
+ // object in the script::paths_ set).
+ //
+ assert (path_->path != nullptr);
+
+ p = path_->path->directory () / p;
+ }
p.normalize ();
- return *script_->paths_.insert (move (p)).first;
+ return *script_->paths_.insert (path_name_value (move (p))).first;
};
- const path& p (enter_path (move (n)));
+ const path_name_value& pn (enter_path (move (n)));
+ const path& p (*pn.path);
if (include_set_->insert (p).second || !once)
{
try
{
ifdstream ifs (p);
- lexer l (ifs, p, lexer_mode::command_line);
+ lexer l (ifs, pn, lexer_mode::command_line);
- const path* op (path_);
- path_ = &p;
+ const path_name* op (path_);
+ path_ = &pn;
lexer* ol (lexer_);
set_lexer (&l);
@@ -2303,7 +2312,7 @@ namespace build2
//
istringstream is (s);
- path in ("<string>"); // @@ PATH_NAME TODO
+ path_name in ("<string>");
lexer lex (is, in,
lexer_mode::command_expansion,
"\'\"\\");
@@ -3432,7 +3441,7 @@ namespace build2
value&& rhs,
const string& attributes,
token_type kind,
- const path& name)
+ const path_name& name)
{
path_ = &name;
diff --git a/libbuild2/test/script/parser.hxx b/libbuild2/test/script/parser.hxx
index c8a1408..7dcd70d 100644
--- a/libbuild2/test/script/parser.hxx
+++ b/libbuild2/test/script/parser.hxx
@@ -48,7 +48,7 @@ namespace build2
value&& rhs,
const string& attributes,
token_type assign_kind,
- const path& name); // For diagnostics.
+ const path_name&); // For diagnostics.
// Recursive descent parser.
//
diff --git a/libbuild2/test/script/runner.cxx b/libbuild2/test/script/runner.cxx
index e56dc41..181c5ce 100644
--- a/libbuild2/test/script/runner.cxx
+++ b/libbuild2/test/script/runner.cxx
@@ -1134,7 +1134,7 @@ namespace build2
value (move (ns)),
*ats,
token_type::assign,
- path ("<attributes>")); // @@ PATH_NAME TODO
+ path_name ("<attributes>"));
}
}
catch (const io_error& e)
diff --git a/libbuild2/test/script/script.hxx b/libbuild2/test/script/script.hxx
index 30bc6e8..f4ef32a 100644
--- a/libbuild2/test/script/script.hxx
+++ b/libbuild2/test/script/script.hxx
@@ -546,9 +546,9 @@ namespace build2
friend class parser;
// Testscript file paths. Specifically, replay_token::file points to
- // these paths.
+ // these path names.
//
- std::set<path> paths_;
+ std::set<path_name_value> paths_;
};
}
}