diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2024-05-21 12:22:16 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2024-05-21 12:22:16 +0200 |
commit | e416c54b985832c25f0e7861a3c295303ffb9da1 (patch) | |
tree | 3e377e9e46a67718e4bf6764b51f661710bfae39 | |
parent | af8046d5bcf2aec918b1802a7719a09ce0111662 (diff) |
Use new thread-specific current working directory in testscript implementation
In particular, this makes sure functions like $path.complete() work correctly
from testscripts.
-rw-r--r-- | libbuild2/test/script/parser.cxx | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libbuild2/test/script/parser.cxx b/libbuild2/test/script/parser.cxx index b712c21..337b162 100644 --- a/libbuild2/test/script/parser.cxx +++ b/libbuild2/test/script/parser.cxx @@ -1609,6 +1609,17 @@ namespace build2 { runner_->enter (*scope_, scope_->start_loc_); + // Set thread-specific current directory override. In particular, this + // makes sure functions like $path.complete() work correctly. + // + auto wdg = make_guard ( + [old = path_traits::thread_current_directory ()] () + { + path_traits::thread_current_directory (old); + }); + + path_traits::thread_current_directory (&scope_->work_dir.path->string ()); + // Note that we rely on "small function object" optimization for the // exec_*() lambdas. // |