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

Side by Side Diff: tools/gn/target_unittest.cc

Issue 51693002: GN: toolchain threading cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « tools/gn/target.cc ('k') | tools/gn/test_with_scope.h » ('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 #include "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "tools/gn/build_settings.h" 6 #include "tools/gn/build_settings.h"
7 #include "tools/gn/config.h" 7 #include "tools/gn/config.h"
8 #include "tools/gn/settings.h" 8 #include "tools/gn/settings.h"
9 #include "tools/gn/target.h" 9 #include "tools/gn/target.h"
10 #include "tools/gn/toolchain.h" 10 #include "tools/gn/toolchain.h"
11 11
12 namespace { 12 namespace {
13 13
14 class TargetTest : public testing::Test { 14 class TargetTest : public testing::Test {
15 public: 15 public:
16 TargetTest() 16 TargetTest()
17 : build_settings_(), 17 : build_settings_(),
18 toolchain_(Label(SourceDir("//tc/"), "tc")), 18 settings_(&build_settings_, std::string()),
19 settings_(&build_settings_, &toolchain_, std::string()) { 19 toolchain_(&settings_, Label(SourceDir("//tc/"), "tc")) {
20 settings_.set_toolchain_label(toolchain_.label());
20 } 21 }
21 virtual ~TargetTest() { 22 virtual ~TargetTest() {
22 } 23 }
23 24
24 protected: 25 protected:
25 BuildSettings build_settings_; 26 BuildSettings build_settings_;
27 Settings settings_;
26 Toolchain toolchain_; 28 Toolchain toolchain_;
27 Settings settings_;
28 }; 29 };
29 30
30 } // namespace 31 } // namespace
31 32
32 // Tests that depending on a group is like depending directly on the group's 33 // Tests that depending on a group is like depending directly on the group's
33 // deps. 34 // deps.
34 TEST_F(TargetTest, GroupDeps) { 35 TEST_F(TargetTest, GroupDeps) {
35 // Two low-level targets. 36 // Two low-level targets.
36 Target x(&settings_, Label(SourceDir("//component/"), "x")); 37 Target x(&settings_, Label(SourceDir("//component/"), "x"));
37 Target y(&settings_, Label(SourceDir("//component/"), "y")); 38 Target y(&settings_, Label(SourceDir("//component/"), "y"));
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 Target a(&settings_, Label(SourceDir("//foo/"), "a")); 116 Target a(&settings_, Label(SourceDir("//foo/"), "a"));
116 a.set_output_type(Target::EXECUTABLE); 117 a.set_output_type(Target::EXECUTABLE);
117 Target b(&settings_, Label(SourceDir("//foo/"), "b")); 118 Target b(&settings_, Label(SourceDir("//foo/"), "b"));
118 b.set_output_type(Target::STATIC_LIBRARY); 119 b.set_output_type(Target::STATIC_LIBRARY);
119 Target c(&settings_, Label(SourceDir("//foo/"), "c")); 120 Target c(&settings_, Label(SourceDir("//foo/"), "c"));
120 c.set_output_type(Target::STATIC_LIBRARY); 121 c.set_output_type(Target::STATIC_LIBRARY);
121 a.deps().push_back(LabelTargetPair(&b)); 122 a.deps().push_back(LabelTargetPair(&b));
122 b.deps().push_back(LabelTargetPair(&c)); 123 b.deps().push_back(LabelTargetPair(&c));
123 124
124 // Normal non-inherited config. 125 // Normal non-inherited config.
125 Config config(Label(SourceDir("//foo/"), "config")); 126 Config config(&settings_, Label(SourceDir("//foo/"), "config"));
126 c.configs().push_back(LabelConfigPair(&config)); 127 c.configs().push_back(LabelConfigPair(&config));
127 128
128 // All dependent config. 129 // All dependent config.
129 Config all(Label(SourceDir("//foo/"), "all")); 130 Config all(&settings_, Label(SourceDir("//foo/"), "all"));
130 c.all_dependent_configs().push_back(LabelConfigPair(&all)); 131 c.all_dependent_configs().push_back(LabelConfigPair(&all));
131 132
132 // Direct dependent config. 133 // Direct dependent config.
133 Config direct(Label(SourceDir("//foo/"), "direct")); 134 Config direct(&settings_, Label(SourceDir("//foo/"), "direct"));
134 c.direct_dependent_configs().push_back(LabelConfigPair(&direct)); 135 c.direct_dependent_configs().push_back(LabelConfigPair(&direct));
135 136
136 c.OnResolved(); 137 c.OnResolved();
137 b.OnResolved(); 138 b.OnResolved();
138 a.OnResolved(); 139 a.OnResolved();
139 140
140 // B should have gotten both dependent configs from C. 141 // B should have gotten both dependent configs from C.
141 ASSERT_EQ(2u, b.configs().size()); 142 ASSERT_EQ(2u, b.configs().size());
142 EXPECT_EQ(&all, b.configs()[0].ptr); 143 EXPECT_EQ(&all, b.configs()[0].ptr);
143 EXPECT_EQ(&direct, b.configs()[1].ptr); 144 EXPECT_EQ(&direct, b.configs()[1].ptr);
(...skipping 17 matching lines...) Expand all
161 b_fwd.OnResolved(); 162 b_fwd.OnResolved();
162 a_fwd.OnResolved(); 163 a_fwd.OnResolved();
163 164
164 // A_fwd should now have both configs. 165 // A_fwd should now have both configs.
165 ASSERT_EQ(2u, a_fwd.configs().size()); 166 ASSERT_EQ(2u, a_fwd.configs().size());
166 EXPECT_EQ(&all, a_fwd.configs()[0].ptr); 167 EXPECT_EQ(&all, a_fwd.configs()[0].ptr);
167 EXPECT_EQ(&direct, a_fwd.configs()[1].ptr); 168 EXPECT_EQ(&direct, a_fwd.configs()[1].ptr);
168 ASSERT_EQ(1u, a_fwd.all_dependent_configs().size()); 169 ASSERT_EQ(1u, a_fwd.all_dependent_configs().size());
169 EXPECT_EQ(&all, a_fwd.all_dependent_configs()[0].ptr); 170 EXPECT_EQ(&all, a_fwd.all_dependent_configs()[0].ptr);
170 } 171 }
OLDNEW
« no previous file with comments | « tools/gn/target.cc ('k') | tools/gn/test_with_scope.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698