1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "tools/gn/test_with_scope.h"
8 #include "tools/gn/parser.h"
9 #include "tools/gn/tokenizer.h"
11 TestWithScope::TestWithScope()
13 settings_(&build_settings_
, std::string()),
14 toolchain_(&settings_
, Label(SourceDir("//toolchain/"), "default")),
16 build_settings_
.SetBuildDir(SourceDir("//out/Debug/"));
17 build_settings_
.set_print_callback(
18 base::Bind(&TestWithScope::AppendPrintOutput
, base::Unretained(this)));
20 settings_
.set_toolchain_label(toolchain_
.label());
21 settings_
.set_default_toolchain_label(toolchain_
.label());
24 TestWithScope::~TestWithScope() {
27 void TestWithScope::AppendPrintOutput(const std::string
& str
) {
28 print_output_
.append(str
);
31 TestParseInput::TestParseInput(const std::string
& input
)
32 : input_file_(SourceFile("//test")) {
33 input_file_
.SetContents(input
);
35 tokens_
= Tokenizer::Tokenize(&input_file_
, &parse_err_
);
36 if (!parse_err_
.has_error())
37 parsed_
= Parser::Parse(tokens_
, &parse_err_
);
40 TestParseInput::~TestParseInput() {