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 #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" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 b_fwd.OnResolved(); | 162 b_fwd.OnResolved(); |
163 a_fwd.OnResolved(); | 163 a_fwd.OnResolved(); |
164 | 164 |
165 // A_fwd should now have both configs. | 165 // A_fwd should now have both configs. |
166 ASSERT_EQ(2u, a_fwd.configs().size()); | 166 ASSERT_EQ(2u, a_fwd.configs().size()); |
167 EXPECT_EQ(&all, a_fwd.configs()[0].ptr); | 167 EXPECT_EQ(&all, a_fwd.configs()[0].ptr); |
168 EXPECT_EQ(&direct, a_fwd.configs()[1].ptr); | 168 EXPECT_EQ(&direct, a_fwd.configs()[1].ptr); |
169 ASSERT_EQ(1u, a_fwd.all_dependent_configs().size()); | 169 ASSERT_EQ(1u, a_fwd.all_dependent_configs().size()); |
170 EXPECT_EQ(&all, a_fwd.all_dependent_configs()[0].ptr); | 170 EXPECT_EQ(&all, a_fwd.all_dependent_configs()[0].ptr); |
171 } | 171 } |
| 172 |
| 173 // Tests that forward_dependent_configs_from works for groups, forwarding the |
| 174 // group's deps' dependent configs. |
| 175 TEST_F(TargetTest, ForwardDependentConfigsFromGroups) { |
| 176 Target a(&settings_, Label(SourceDir("//foo/"), "a")); |
| 177 a.set_output_type(Target::EXECUTABLE); |
| 178 Target b(&settings_, Label(SourceDir("//foo/"), "b")); |
| 179 b.set_output_type(Target::GROUP); |
| 180 Target c(&settings_, Label(SourceDir("//foo/"), "c")); |
| 181 c.set_output_type(Target::STATIC_LIBRARY); |
| 182 a.deps().push_back(LabelTargetPair(&b)); |
| 183 b.deps().push_back(LabelTargetPair(&c)); |
| 184 |
| 185 // Direct dependent config on C. |
| 186 Config direct(&settings_, Label(SourceDir("//foo/"), "direct")); |
| 187 c.direct_dependent_configs().push_back(LabelConfigPair(&direct)); |
| 188 |
| 189 // A forwards the dependent configs from B. |
| 190 a.forward_dependent_configs().push_back(LabelTargetPair(&b)); |
| 191 |
| 192 c.OnResolved(); |
| 193 b.OnResolved(); |
| 194 a.OnResolved(); |
| 195 |
| 196 // The config should now be on A, and in A's direct dependent configs. |
| 197 ASSERT_EQ(1u, a.configs().size()); |
| 198 ASSERT_EQ(&direct, a.configs()[0].ptr); |
| 199 ASSERT_EQ(1u, a.direct_dependent_configs().size()); |
| 200 ASSERT_EQ(&direct, a.direct_dependent_configs()[0].ptr); |
| 201 } |
OLD | NEW |