OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef TOOLS_GN_TEST_WITH_SCOPE_H_ | 5 #ifndef TOOLS_GN_TEST_WITH_SCOPE_H_ |
6 #define TOOLS_GN_TEST_WITH_SCOPE_H_ | 6 #define TOOLS_GN_TEST_WITH_SCOPE_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "tools/gn/build_settings.h" | 11 #include "tools/gn/build_settings.h" |
12 #include "tools/gn/err.h" | 12 #include "tools/gn/err.h" |
13 #include "tools/gn/input_file.h" | 13 #include "tools/gn/input_file.h" |
14 #include "tools/gn/parse_tree.h" | 14 #include "tools/gn/parse_tree.h" |
15 #include "tools/gn/scope.h" | 15 #include "tools/gn/scope.h" |
| 16 #include "tools/gn/scope_per_file_provider.h" |
16 #include "tools/gn/settings.h" | 17 #include "tools/gn/settings.h" |
17 #include "tools/gn/target.h" | 18 #include "tools/gn/target.h" |
18 #include "tools/gn/token.h" | 19 #include "tools/gn/token.h" |
19 #include "tools/gn/toolchain.h" | 20 #include "tools/gn/toolchain.h" |
20 #include "tools/gn/value.h" | 21 #include "tools/gn/value.h" |
21 | 22 |
22 // A helper class for setting up a Scope that a test can use. It makes a | 23 // A helper class for setting up a Scope that a test can use. It makes a |
23 // toolchain and sets up all the build state. | 24 // toolchain and sets up all the build state. |
24 class TestWithScope { | 25 class TestWithScope { |
25 public: | 26 public: |
(...skipping 26 matching lines...) Expand all Loading... |
52 static void SetCommandForTool(const std::string& cmd, Tool* tool); | 53 static void SetCommandForTool(const std::string& cmd, Tool* tool); |
53 | 54 |
54 private: | 55 private: |
55 void AppendPrintOutput(const std::string& str); | 56 void AppendPrintOutput(const std::string& str); |
56 | 57 |
57 BuildSettings build_settings_; | 58 BuildSettings build_settings_; |
58 Settings settings_; | 59 Settings settings_; |
59 Toolchain toolchain_; | 60 Toolchain toolchain_; |
60 Scope scope_; | 61 Scope scope_; |
61 | 62 |
| 63 // Supplies the scope with built-in variables like root_out_dir. |
| 64 ScopePerFileProvider scope_progammatic_provider_; |
| 65 |
62 std::string print_output_; | 66 std::string print_output_; |
63 | 67 |
64 DISALLOW_COPY_AND_ASSIGN(TestWithScope); | 68 DISALLOW_COPY_AND_ASSIGN(TestWithScope); |
65 }; | 69 }; |
66 | 70 |
67 // Helper class to treat some string input as a file. | 71 // Helper class to treat some string input as a file. |
68 // | 72 // |
69 // Instantiate it with the contents you want, be sure to check for error, and | 73 // Instantiate it with the contents you want, be sure to check for error, and |
70 // then you can execute the ParseNode or whatever. | 74 // then you can execute the ParseNode or whatever. |
71 class TestParseInput { | 75 class TestParseInput { |
(...skipping 25 matching lines...) Expand all Loading... |
97 // default to public visibility. | 101 // default to public visibility. |
98 class TestTarget : public Target { | 102 class TestTarget : public Target { |
99 public: | 103 public: |
100 TestTarget(TestWithScope& setup, | 104 TestTarget(TestWithScope& setup, |
101 const std::string& label_string, | 105 const std::string& label_string, |
102 Target::OutputType type); | 106 Target::OutputType type); |
103 ~TestTarget() override; | 107 ~TestTarget() override; |
104 }; | 108 }; |
105 | 109 |
106 #endif // TOOLS_GN_TEST_WITH_SCOPE_H_ | 110 #endif // TOOLS_GN_TEST_WITH_SCOPE_H_ |
OLD | NEW |