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

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

Issue 1375023003: tools/gn: Remove code for forward_dependent_configs_from variable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: forward_dependent_configs Created 5 years, 2 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_generator.cc ('k') | tools/gn/variables.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/scheduler.h" 8 #include "tools/gn/scheduler.h"
9 #include "tools/gn/settings.h" 9 #include "tools/gn/settings.h"
10 #include "tools/gn/target.h" 10 #include "tools/gn/target.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 EXPECT_EQ(libdir, shared.all_lib_dirs()[1]); 68 EXPECT_EQ(libdir, shared.all_lib_dirs()[1]);
69 69
70 // Executable target shouldn't get either by depending on shared. 70 // Executable target shouldn't get either by depending on shared.
71 TestTarget exec(setup, "//foo:exec", Target::EXECUTABLE); 71 TestTarget exec(setup, "//foo:exec", Target::EXECUTABLE);
72 exec.private_deps().push_back(LabelTargetPair(&shared)); 72 exec.private_deps().push_back(LabelTargetPair(&shared));
73 ASSERT_TRUE(exec.OnResolved(&err)); 73 ASSERT_TRUE(exec.OnResolved(&err));
74 EXPECT_EQ(0u, exec.all_libs().size()); 74 EXPECT_EQ(0u, exec.all_libs().size());
75 EXPECT_EQ(0u, exec.all_lib_dirs().size()); 75 EXPECT_EQ(0u, exec.all_lib_dirs().size());
76 } 76 }
77 77
78 // Test all_dependent_configs, public_config inheritance, and 78 // Test all_dependent_configs and public_config inheritance.
79 // forward_dependent_configs_from
80 TEST(Target, DependentConfigs) { 79 TEST(Target, DependentConfigs) {
81 TestWithScope setup; 80 TestWithScope setup;
82 Err err; 81 Err err;
83 82
84 // Set up a dependency chain of a -> b -> c 83 // Set up a dependency chain of a -> b -> c
85 TestTarget a(setup, "//foo:a", Target::EXECUTABLE); 84 TestTarget a(setup, "//foo:a", Target::EXECUTABLE);
86 TestTarget b(setup, "//foo:b", Target::STATIC_LIBRARY); 85 TestTarget b(setup, "//foo:b", Target::STATIC_LIBRARY);
87 TestTarget c(setup, "//foo:c", Target::STATIC_LIBRARY); 86 TestTarget c(setup, "//foo:c", Target::STATIC_LIBRARY);
88 a.private_deps().push_back(LabelTargetPair(&b)); 87 a.private_deps().push_back(LabelTargetPair(&b));
89 b.private_deps().push_back(LabelTargetPair(&c)); 88 b.private_deps().push_back(LabelTargetPair(&c));
(...skipping 27 matching lines...) Expand all
117 // A should have just gotten the "all" dependent config from C. 116 // A should have just gotten the "all" dependent config from C.
118 ASSERT_EQ(1u, a.configs().size()); 117 ASSERT_EQ(1u, a.configs().size());
119 EXPECT_EQ(&all, a.configs()[0].ptr); 118 EXPECT_EQ(&all, a.configs()[0].ptr);
120 EXPECT_EQ(&all, a.all_dependent_configs()[0].ptr); 119 EXPECT_EQ(&all, a.all_dependent_configs()[0].ptr);
121 120
122 // Making an an alternate A and B with B forwarding the direct dependents. 121 // Making an an alternate A and B with B forwarding the direct dependents.
123 TestTarget a_fwd(setup, "//foo:a_fwd", Target::EXECUTABLE); 122 TestTarget a_fwd(setup, "//foo:a_fwd", Target::EXECUTABLE);
124 TestTarget b_fwd(setup, "//foo:b_fwd", Target::STATIC_LIBRARY); 123 TestTarget b_fwd(setup, "//foo:b_fwd", Target::STATIC_LIBRARY);
125 a_fwd.private_deps().push_back(LabelTargetPair(&b_fwd)); 124 a_fwd.private_deps().push_back(LabelTargetPair(&b_fwd));
126 b_fwd.private_deps().push_back(LabelTargetPair(&c)); 125 b_fwd.private_deps().push_back(LabelTargetPair(&c));
127 b_fwd.forward_dependent_configs().push_back(LabelTargetPair(&c));
tfarina 2015/10/06 03:28:50 I'm not sure about these unit tests changes. Pleas
128 126
129 ASSERT_TRUE(b_fwd.OnResolved(&err)); 127 ASSERT_TRUE(b_fwd.OnResolved(&err));
130 ASSERT_TRUE(a_fwd.OnResolved(&err)); 128 ASSERT_TRUE(a_fwd.OnResolved(&err));
131 129
132 // A_fwd should now have both configs. 130 // A_fwd should now have both configs.
133 ASSERT_EQ(2u, a_fwd.configs().size()); 131 ASSERT_EQ(1u, a_fwd.configs().size());
134 EXPECT_EQ(&all, a_fwd.configs()[0].ptr); 132 EXPECT_EQ(&all, a_fwd.configs()[0].ptr);
135 EXPECT_EQ(&direct, a_fwd.configs()[1].ptr);
136 ASSERT_EQ(1u, a_fwd.all_dependent_configs().size()); 133 ASSERT_EQ(1u, a_fwd.all_dependent_configs().size());
137 EXPECT_EQ(&all, a_fwd.all_dependent_configs()[0].ptr); 134 EXPECT_EQ(&all, a_fwd.all_dependent_configs()[0].ptr);
138 } 135 }
139 136
140 TEST(Target, InheritLibs) { 137 TEST(Target, InheritLibs) {
141 TestWithScope setup; 138 TestWithScope setup;
142 Err err; 139 Err err;
143 140
144 // Create a dependency chain: 141 // Create a dependency chain:
145 // A (executable) -> B (shared lib) -> C (static lib) -> D (source set) 142 // A (executable) -> B (shared lib) -> C (static lib) -> D (source set)
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 // to the current target. 377 // to the current target.
381 TestTarget dep_on_pub(setup, "//a:dop", Target::SOURCE_SET); 378 TestTarget dep_on_pub(setup, "//a:dop", Target::SOURCE_SET);
382 dep_on_pub.private_deps().push_back(LabelTargetPair(&pub)); 379 dep_on_pub.private_deps().push_back(LabelTargetPair(&pub));
383 ASSERT_TRUE(dep_on_pub.OnResolved(&err)); 380 ASSERT_TRUE(dep_on_pub.OnResolved(&err));
384 ASSERT_EQ(1u, dep_on_pub.configs().size()); 381 ASSERT_EQ(1u, dep_on_pub.configs().size());
385 EXPECT_EQ(&pub_config, dep_on_pub.configs()[0].ptr); 382 EXPECT_EQ(&pub_config, dep_on_pub.configs()[0].ptr);
386 383
387 // This target has a private dependency on dest for forwards configs. 384 // This target has a private dependency on dest for forwards configs.
388 TestTarget forward(setup, "//a:f", Target::SOURCE_SET); 385 TestTarget forward(setup, "//a:f", Target::SOURCE_SET);
389 forward.private_deps().push_back(LabelTargetPair(&dest)); 386 forward.private_deps().push_back(LabelTargetPair(&dest));
390 forward.forward_dependent_configs().push_back(LabelTargetPair(&dest));
391 ASSERT_TRUE(forward.OnResolved(&err)); 387 ASSERT_TRUE(forward.OnResolved(&err));
392
393 // Depending on the forward target should apply the config.
394 TestTarget dep_on_forward(setup, "//a:dof", Target::SOURCE_SET);
395 dep_on_forward.private_deps().push_back(LabelTargetPair(&forward));
396 ASSERT_TRUE(dep_on_forward.OnResolved(&err));
397 ASSERT_EQ(1u, dep_on_forward.configs().size());
398 EXPECT_EQ(&pub_config, dep_on_forward.configs()[0].ptr);
399 } 388 }
400 389
401 // Tests that different link/depend outputs work for solink tools. 390 // Tests that different link/depend outputs work for solink tools.
402 TEST(Target, LinkAndDepOutputs) { 391 TEST(Target, LinkAndDepOutputs) {
403 TestWithScope setup; 392 TestWithScope setup;
404 Err err; 393 Err err;
405 394
406 Toolchain toolchain(setup.settings(), Label(SourceDir("//tc/"), "tc")); 395 Toolchain toolchain(setup.settings(), Label(SourceDir("//tc/"), "tc"));
407 396
408 scoped_ptr<Tool> solink_tool(new Tool()); 397 scoped_ptr<Tool> solink_tool(new Tool());
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 "\n" 601 "\n"
613 "From //foo:bar\n" 602 "From //foo:bar\n"
614 " header: pch.h\n" 603 " header: pch.h\n"
615 " source: //pcs.cc\n" 604 " source: //pcs.cc\n"
616 "\n" 605 "\n"
617 "From //foo:c2\n" 606 "From //foo:c2\n"
618 " header: pch2.h\n" 607 " header: pch2.h\n"
619 " source: //pcs2.cc", 608 " source: //pcs2.cc",
620 err.help_text()); 609 err.help_text());
621 } 610 }
OLDNEW
« no previous file with comments | « tools/gn/target_generator.cc ('k') | tools/gn/variables.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698