| 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 <string> |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "tools/gn/build_settings.h" | 12 #include "tools/gn/build_settings.h" |
| 12 #include "tools/gn/err.h" | 13 #include "tools/gn/err.h" |
| 13 #include "tools/gn/input_file.h" | 14 #include "tools/gn/input_file.h" |
| 14 #include "tools/gn/parse_tree.h" | 15 #include "tools/gn/parse_tree.h" |
| 15 #include "tools/gn/scope.h" | 16 #include "tools/gn/scope.h" |
| 16 #include "tools/gn/scope_per_file_provider.h" | 17 #include "tools/gn/scope_per_file_provider.h" |
| 17 #include "tools/gn/settings.h" | 18 #include "tools/gn/settings.h" |
| 18 #include "tools/gn/target.h" | 19 #include "tools/gn/target.h" |
| 19 #include "tools/gn/token.h" | 20 #include "tools/gn/token.h" |
| 20 #include "tools/gn/toolchain.h" | 21 #include "tools/gn/toolchain.h" |
| 21 #include "tools/gn/value.h" | 22 #include "tools/gn/value.h" |
| 22 | 23 |
| 23 // A helper class for setting up a Scope that a test can use. It makes a | 24 // A helper class for setting up a Scope that a test can use. It makes a |
| 24 // toolchain and sets up all the build state. | 25 // toolchain and sets up all the build state. |
| 25 class TestWithScope { | 26 class TestWithScope { |
| 26 public: | 27 public: |
| 27 TestWithScope(); | 28 TestWithScope(); |
| 28 ~TestWithScope(); | 29 ~TestWithScope(); |
| 29 | 30 |
| 30 BuildSettings* build_settings() { return &build_settings_; } | 31 BuildSettings* build_settings() { return &build_settings_; } |
| 31 Settings* settings() { return &settings_; } | 32 Settings* settings() { return &settings_; } |
| 33 const Settings* settings() const { return &settings_; } |
| 32 Toolchain* toolchain() { return &toolchain_; } | 34 Toolchain* toolchain() { return &toolchain_; } |
| 35 const Toolchain* toolchain() const { return &toolchain_; } |
| 33 Scope* scope() { return &scope_; } | 36 Scope* scope() { return &scope_; } |
| 34 | 37 |
| 35 // This buffer accumulates output from any print() commands executed in the | 38 // This buffer accumulates output from any print() commands executed in the |
| 36 // context of this test. Note that the implementation of this is not | 39 // context of this test. Note that the implementation of this is not |
| 37 // threadsafe so don't write tests that call print from multiple threads. | 40 // threadsafe so don't write tests that call print from multiple threads. |
| 38 std::string& print_output() { return print_output_; } | 41 std::string& print_output() { return print_output_; } |
| 39 | 42 |
| 40 // Parse the given string into a label in the default toolchain. This will | 43 // Parse the given string into a label in the default toolchain. This will |
| 41 // assert if the label isn't valid (this is intended for hardcoded labels). | 44 // assert if the label isn't valid (this is intended for hardcoded labels). |
| 42 Label ParseLabel(const std::string& str) const; | 45 Label ParseLabel(const std::string& str) const; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 Err parse_err_; | 97 Err parse_err_; |
| 95 | 98 |
| 96 DISALLOW_COPY_AND_ASSIGN(TestParseInput); | 99 DISALLOW_COPY_AND_ASSIGN(TestParseInput); |
| 97 }; | 100 }; |
| 98 | 101 |
| 99 // Shortcut for creating targets for tests that take the test setup, a pretty- | 102 // Shortcut for creating targets for tests that take the test setup, a pretty- |
| 100 // style label, and a target type and sets everything up. The target will | 103 // style label, and a target type and sets everything up. The target will |
| 101 // default to public visibility. | 104 // default to public visibility. |
| 102 class TestTarget : public Target { | 105 class TestTarget : public Target { |
| 103 public: | 106 public: |
| 104 TestTarget(TestWithScope& setup, | 107 TestTarget(const TestWithScope& setup, |
| 105 const std::string& label_string, | 108 const std::string& label_string, |
| 106 Target::OutputType type); | 109 Target::OutputType type); |
| 107 ~TestTarget() override; | 110 ~TestTarget() override; |
| 108 }; | 111 }; |
| 109 | 112 |
| 110 #endif // TOOLS_GN_TEST_WITH_SCOPE_H_ | 113 #endif // TOOLS_GN_TEST_WITH_SCOPE_H_ |
| OLD | NEW |