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/test_with_scope.h" | 10 #include "tools/gn/test_with_scope.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 EXPECT_EQ(1u, b_inherited.size()); | 218 EXPECT_EQ(1u, b_inherited.size()); |
219 EXPECT_TRUE(b_inherited.IndexOf(&c) != static_cast<size_t>(-1)); | 219 EXPECT_TRUE(b_inherited.IndexOf(&c) != static_cast<size_t>(-1)); |
220 | 220 |
221 // A should have B in its inherited libs, but not any others (the complete | 221 // A should have B in its inherited libs, but not any others (the complete |
222 // static library will include the source set). | 222 // static library will include the source set). |
223 const UniqueVector<const Target*>& a_inherited = a.inherited_libraries(); | 223 const UniqueVector<const Target*>& a_inherited = a.inherited_libraries(); |
224 EXPECT_EQ(1u, a_inherited.size()); | 224 EXPECT_EQ(1u, a_inherited.size()); |
225 EXPECT_TRUE(a_inherited.IndexOf(&b) != static_cast<size_t>(-1)); | 225 EXPECT_TRUE(a_inherited.IndexOf(&b) != static_cast<size_t>(-1)); |
226 } | 226 } |
227 | 227 |
| 228 TEST(Target, InheritCompleteStaticLibNoStaticLibDeps) { |
| 229 TestWithScope setup; |
| 230 Err err; |
| 231 |
| 232 // Create a dependency chain: |
| 233 // A (complete static lib) -> B (static lib) |
| 234 Target a(setup.settings(), Label(SourceDir("//foo/"), "a")); |
| 235 a.set_output_type(Target::STATIC_LIBRARY); |
| 236 a.visibility().SetPublic(); |
| 237 a.set_complete_static_lib(true); |
| 238 a.SetToolchain(setup.toolchain()); |
| 239 Target b(setup.settings(), Label(SourceDir("//foo/"), "b")); |
| 240 b.set_output_type(Target::STATIC_LIBRARY); |
| 241 b.visibility().SetPublic(); |
| 242 b.SetToolchain(setup.toolchain()); |
| 243 |
| 244 a.public_deps().push_back(LabelTargetPair(&b)); |
| 245 ASSERT_TRUE(b.OnResolved(&err)); |
| 246 ASSERT_FALSE(a.OnResolved(&err)); |
| 247 } |
| 248 |
228 TEST(Target, GetComputedOutputName) { | 249 TEST(Target, GetComputedOutputName) { |
229 TestWithScope setup; | 250 TestWithScope setup; |
230 Err err; | 251 Err err; |
231 | 252 |
232 // Basic target with no prefix (executable type tool in the TestWithScope has | 253 // Basic target with no prefix (executable type tool in the TestWithScope has |
233 // no prefix) or output name. | 254 // no prefix) or output name. |
234 Target basic(setup.settings(), Label(SourceDir("//foo/"), "bar")); | 255 Target basic(setup.settings(), Label(SourceDir("//foo/"), "bar")); |
235 basic.set_output_type(Target::EXECUTABLE); | 256 basic.set_output_type(Target::EXECUTABLE); |
236 basic.SetToolchain(setup.toolchain()); | 257 basic.SetToolchain(setup.toolchain()); |
237 ASSERT_TRUE(basic.OnResolved(&err)); | 258 ASSERT_TRUE(basic.OnResolved(&err)); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 // Depending on the forward target should apply the config. | 444 // Depending on the forward target should apply the config. |
424 Target dep_on_forward(setup.settings(), Label(SourceDir("//a/"), "dof")); | 445 Target dep_on_forward(setup.settings(), Label(SourceDir("//a/"), "dof")); |
425 dep_on_forward.set_output_type(Target::SOURCE_SET); | 446 dep_on_forward.set_output_type(Target::SOURCE_SET); |
426 dep_on_forward.visibility().SetPublic(); | 447 dep_on_forward.visibility().SetPublic(); |
427 dep_on_forward.SetToolchain(setup.toolchain()); | 448 dep_on_forward.SetToolchain(setup.toolchain()); |
428 dep_on_forward.private_deps().push_back(LabelTargetPair(&forward)); | 449 dep_on_forward.private_deps().push_back(LabelTargetPair(&forward)); |
429 ASSERT_TRUE(dep_on_forward.OnResolved(&err)); | 450 ASSERT_TRUE(dep_on_forward.OnResolved(&err)); |
430 ASSERT_EQ(1u, dep_on_forward.configs().size()); | 451 ASSERT_EQ(1u, dep_on_forward.configs().size()); |
431 EXPECT_EQ(&pub_config, dep_on_forward.configs()[0].ptr); | 452 EXPECT_EQ(&pub_config, dep_on_forward.configs()[0].ptr); |
432 } | 453 } |
OLD | NEW |