Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: tools/gn/test_with_scope.h

Issue 1126193005: Check for inputs not generated by deps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@data
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gn/target_unittest.cc ('k') | tools/gn/test_with_scope.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/settings.h" 16 #include "tools/gn/settings.h"
17 #include "tools/gn/target.h"
17 #include "tools/gn/token.h" 18 #include "tools/gn/token.h"
18 #include "tools/gn/toolchain.h" 19 #include "tools/gn/toolchain.h"
19 #include "tools/gn/value.h" 20 #include "tools/gn/value.h"
20 21
21 // A helper class for setting up a Scope that a test can use. It makes a 22 // A helper class for setting up a Scope that a test can use. It makes a
22 // toolchain and sets up all the build state. 23 // toolchain and sets up all the build state.
23 class TestWithScope { 24 class TestWithScope {
24 public: 25 public:
25 TestWithScope(); 26 TestWithScope();
26 ~TestWithScope(); 27 ~TestWithScope();
27 28
28 BuildSettings* build_settings() { return &build_settings_; } 29 BuildSettings* build_settings() { return &build_settings_; }
29 Settings* settings() { return &settings_; } 30 Settings* settings() { return &settings_; }
30 Toolchain* toolchain() { return &toolchain_; } 31 Toolchain* toolchain() { return &toolchain_; }
31 Scope* scope() { return &scope_; } 32 Scope* scope() { return &scope_; }
32 33
33 // This buffer accumulates output from any print() commands executed in the 34 // This buffer accumulates output from any print() commands executed in the
34 // context of this test. Note that the implementation of this is not 35 // context of this test. Note that the implementation of this is not
35 // threadsafe so don't write tests that call print from multiple threads. 36 // threadsafe so don't write tests that call print from multiple threads.
36 std::string& print_output() { return print_output_; } 37 std::string& print_output() { return print_output_; }
37 38
39 // Parse the given string into a label in the default toolchain. This will
40 // assert if the label isn't valid (this is intended for hardcoded labels).
41 Label ParseLabel(const std::string& str) const;
42
38 // Fills in the tools for the given toolchain with reasonable default values. 43 // Fills in the tools for the given toolchain with reasonable default values.
39 // The toolchain in this object will be automatically set up with this 44 // The toolchain in this object will be automatically set up with this
40 // function, it is exposed to allow tests to get the same functionality for 45 // function, it is exposed to allow tests to get the same functionality for
41 // other toolchains they make 46 // other toolchains they make
42 static void SetupToolchain(Toolchain* toolchain); 47 static void SetupToolchain(Toolchain* toolchain);
43 48
44 private: 49 private:
45 void AppendPrintOutput(const std::string& str); 50 void AppendPrintOutput(const std::string& str);
46 51
47 BuildSettings build_settings_; 52 BuildSettings build_settings_;
(...skipping 27 matching lines...) Expand all
75 InputFile input_file_; 80 InputFile input_file_;
76 81
77 std::vector<Token> tokens_; 82 std::vector<Token> tokens_;
78 scoped_ptr<ParseNode> parsed_; 83 scoped_ptr<ParseNode> parsed_;
79 84
80 Err parse_err_; 85 Err parse_err_;
81 86
82 DISALLOW_COPY_AND_ASSIGN(TestParseInput); 87 DISALLOW_COPY_AND_ASSIGN(TestParseInput);
83 }; 88 };
84 89
90 // Shortcut for creating targets for tests that take the test setup, a pretty-
91 // style label, and a target type and sets everything up. The target will
92 // default to public visibility.
93 class TestTarget : public Target {
94 public:
95 TestTarget(TestWithScope& setup,
96 const std::string& label_string,
97 Target::OutputType type);
98 ~TestTarget() override;
99 };
100
85 #endif // TOOLS_GN_TEST_WITH_SCOPE_H_ 101 #endif // TOOLS_GN_TEST_WITH_SCOPE_H_
OLDNEW
« no previous file with comments | « tools/gn/target_unittest.cc ('k') | tools/gn/test_with_scope.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698