diff options
author | Brett Wilson <brettw@chromium.org> | 2014-09-17 12:00:23 -0700 |
---|---|---|
committer | Brett Wilson <brettw@chromium.org> | 2014-09-17 19:01:13 +0000 |
commit | c4a325a6cef25f7380b9c7cca9178b85849077ae (patch) | |
tree | 060fe9475ef62f3ac51085f911f96e1e2d5a7376 /tools/gn/target_unittest.cc | |
parent | 17e5a85d71ba5ca09fe66ac4c1b0e4e7262db9bd (diff) | |
download | chromium_src-c4a325a6cef25f7380b9c7cca9178b85849077ae.zip chromium_src-c4a325a6cef25f7380b9c7cca9178b85849077ae.tar.gz chromium_src-c4a325a6cef25f7380b9c7cca9178b85849077ae.tar.bz2 |
GN fixes for group dependent configs.
Adds a better tests for pulling dependent and public configs. These don't actually test the bug, but are important.
The bug was removing the group conditional when pulling dependent configs. Previously the groups deps would get duplicated so we wouldn't want to pull a group's public deps. I didn't write a test for this since it seemed odd to test that there is not a special case for this. I just removed the condition.
Fixes a misspelliung and and an extra newline in the help.
BUG=
R=jamesr@chromium.org
Review URL: https://codereview.chromium.org/581723002
Cr-Commit-Position: refs/heads/master@{#295314}
Diffstat (limited to 'tools/gn/target_unittest.cc')
-rw-r--r-- | tools/gn/target_unittest.cc | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tools/gn/target_unittest.cc b/tools/gn/target_unittest.cc index c6f4d05..151cb31 100644 --- a/tools/gn/target_unittest.cc +++ b/tools/gn/target_unittest.cc @@ -376,3 +376,57 @@ TEST(Target, Testonly) { product.SetToolchain(setup.toolchain()); ASSERT_FALSE(product.OnResolved(&err)); } + +TEST(Target, PublicConfigs) { + TestWithScope setup; + Err err; + + Label pub_config_label(SourceDir("//a/"), "pubconfig"); + Config pub_config(setup.settings(), pub_config_label); + + // This is the destination target that has a public config. + Target dest(setup.settings(), Label(SourceDir("//a/"), "a")); + dest.set_output_type(Target::SOURCE_SET); + dest.visibility().SetPublic(); + dest.SetToolchain(setup.toolchain()); + dest.public_configs().push_back(LabelConfigPair(&pub_config)); + ASSERT_TRUE(dest.OnResolved(&err)); + + // This target has a public dependency on dest. + Target pub(setup.settings(), Label(SourceDir("//a/"), "pub")); + pub.set_output_type(Target::SOURCE_SET); + pub.visibility().SetPublic(); + pub.SetToolchain(setup.toolchain()); + pub.public_deps().push_back(LabelTargetPair(&dest)); + ASSERT_TRUE(pub.OnResolved(&err)); + + // Depending on the target with the public dependency should forward dest's + // to the current target. + Target dep_on_pub(setup.settings(), Label(SourceDir("//a/"), "dop")); + dep_on_pub.set_output_type(Target::SOURCE_SET); + dep_on_pub.visibility().SetPublic(); + dep_on_pub.SetToolchain(setup.toolchain()); + dep_on_pub.private_deps().push_back(LabelTargetPair(&pub)); + ASSERT_TRUE(dep_on_pub.OnResolved(&err)); + ASSERT_EQ(1u, dep_on_pub.configs().size()); + EXPECT_EQ(&pub_config, dep_on_pub.configs()[0].ptr); + + // This target has a private dependency on dest for forwards configs. + Target forward(setup.settings(), Label(SourceDir("//a/"), "f")); + forward.set_output_type(Target::SOURCE_SET); + forward.visibility().SetPublic(); + forward.SetToolchain(setup.toolchain()); + forward.private_deps().push_back(LabelTargetPair(&dest)); + forward.forward_dependent_configs().push_back(LabelTargetPair(&dest)); + ASSERT_TRUE(forward.OnResolved(&err)); + + // Depending on the forward target should apply the config. + Target dep_on_forward(setup.settings(), Label(SourceDir("//a/"), "dof")); + dep_on_forward.set_output_type(Target::SOURCE_SET); + dep_on_forward.visibility().SetPublic(); + dep_on_forward.SetToolchain(setup.toolchain()); + dep_on_forward.private_deps().push_back(LabelTargetPair(&forward)); + ASSERT_TRUE(dep_on_forward.OnResolved(&err)); + ASSERT_EQ(1u, dep_on_forward.configs().size()); + EXPECT_EQ(&pub_config, dep_on_forward.configs()[0].ptr); +} |