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

Unified Diff: tools/gn/target_unittest.cc

Issue 551843006: GN: fix datadeps visibility check (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/target.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/target_unittest.cc
diff --git a/tools/gn/target_unittest.cc b/tools/gn/target_unittest.cc
index 895d11d147836b2102c9eb62a850c5d71cc327de..958bc25ec3c512426795a0edfbce2df5bdaa0027 100644
--- a/tools/gn/target_unittest.cc
+++ b/tools/gn/target_unittest.cc
@@ -373,6 +373,28 @@ TEST(Target, VisibilityFails) {
ASSERT_FALSE(a.OnResolved(&err));
}
+// Test visibility with a single datadep.
+TEST(Target, VisibilityDatadeps) {
+ TestWithScope setup;
+ Err err;
+
+ Target b(setup.settings(), Label(SourceDir("//public/"), "b"));
+ b.set_output_type(Target::STATIC_LIBRARY);
+ b.SetToolchain(setup.toolchain());
+ b.visibility().SetPublic();
+ ASSERT_TRUE(b.OnResolved(&err));
+
+ // Make a target depending on "b". The dependency must have an origin to mark
+ // it as user-set so we check visibility. This check should fail.
+ Target a(setup.settings(), Label(SourceDir("//app/"), "a"));
+ a.set_output_type(Target::EXECUTABLE);
+ a.datadeps().push_back(LabelTargetPair(&b));
+ IdentifierNode origin; // Dummy origin.
+ a.datadeps()[0].origin = &origin;
+ a.SetToolchain(setup.toolchain());
+ ASSERT_TRUE(a.OnResolved(&err)) << err.help_text();
+}
+
// Tests that A -> Group -> B where the group is visible from A but B isn't,
// passes visibility even though the group's deps get expanded into A.
TEST(Target, VisibilityGroup) {
« no previous file with comments | « tools/gn/target.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698