| Index: tools/gn/test_with_scope.cc
|
| diff --git a/tools/gn/test_with_scope.cc b/tools/gn/test_with_scope.cc
|
| index 32d5dd675850bcf54886b0289b086360306a655b..0ddd4636be4299de4a1972edf7214bbdc45f7046 100644
|
| --- a/tools/gn/test_with_scope.cc
|
| +++ b/tools/gn/test_with_scope.cc
|
| @@ -24,6 +24,7 @@ TestWithScope::TestWithScope()
|
| settings_.set_default_toolchain_label(toolchain_.label());
|
|
|
| SetupToolchain(&toolchain_);
|
| + scope_.set_item_collector(&items_);
|
| }
|
|
|
| TestWithScope::~TestWithScope() {
|
| @@ -37,6 +38,28 @@ Label TestWithScope::ParseLabel(const std::string& str) const {
|
| return result;
|
| }
|
|
|
| +bool TestWithScope::ExecuteSnippet(const std::string& str, Err* err) {
|
| + TestParseInput input(str);
|
| + if (input.has_error()) {
|
| + *err = input.parse_err();
|
| + return false;
|
| + }
|
| +
|
| + size_t first_item = items_.size();
|
| + input.parsed()->Execute(&scope_, err);
|
| + if (err->has_error())
|
| + return false;
|
| +
|
| + for (size_t i = first_item; i < items_.size(); ++i) {
|
| + CHECK(items_[i]->AsTarget() != nullptr)
|
| + << "Only targets are supported in ExecuteSnippet()";
|
| + items_[i]->AsTarget()->SetToolchain(&toolchain_);
|
| + if (!items_[i]->OnResolved(err))
|
| + return false;
|
| + }
|
| + return true;
|
| +}
|
| +
|
| // static
|
| void TestWithScope::SetupToolchain(Toolchain* toolchain) {
|
| Err err;
|
|
|