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. 4 5 #include "tools/gn/test_with_scope.h" 6 7 #include "base/bind.h" 8 #include "tools/gn/parser.h" 9 #include "tools/gn/tokenizer.h" 10 11 TestWithScope::TestWithScope() 12 : build_settings_(), 13 settings_(&build_settings_, std::string()), 14 toolchain_(&settings_, Label(SourceDir("//toolchain/"), "default")), 15 scope_(&settings_) { 16 build_settings_.SetBuildDir(SourceDir("//out/Debug/")); 17 build_settings_.set_print_callback( 18 base::Bind(&TestWithScope::AppendPrintOutput, base::Unretained(this))); 19 20 settings_.set_toolchain_label(toolchain_.label()); 21 settings_.set_default_toolchain_label(toolchain_.label()); 22 } 23 24 TestWithScope::~TestWithScope() { 25 } 26 27 void TestWithScope::AppendPrintOutput(const std::string& str) { 28 print_output_.append(str); 29 } 30 31 TestParseInput::TestParseInput(const std::string& input) 32 : input_file_(SourceFile("//test")) { 33 input_file_.SetContents(input); 34 35 tokens_ = Tokenizer::Tokenize(&input_file_, &parse_err_); 36 if (!parse_err_.has_error()) 37 parsed_ = Parser::Parse(tokens_, &parse_err_); 38 } 39 40 TestParseInput::~TestParseInput() { 41 } 42