Index: tools/gn/header_checker_unittest.cc |
diff --git a/tools/gn/header_checker_unittest.cc b/tools/gn/header_checker_unittest.cc |
index dd1ce24351489f572d4feb5d41beaca153ce72d5..8d109015512a5454ff351848162e37c48772118d 100644 |
--- a/tools/gn/header_checker_unittest.cc |
+++ b/tools/gn/header_checker_unittest.cc |
@@ -86,57 +86,58 @@ TEST_F(HeaderCheckerTest, IsDependencyOf) { |
a_.public_deps().push_back(LabelTargetPair(&p)); |
// A does not depend on itself. |
- bool is_public = false; |
- std::vector<const Target*> chain; |
- EXPECT_FALSE(checker->IsDependencyOf(&a_, &a_, &chain, &is_public)); |
+ bool is_permitted = false; |
+ HeaderChecker::Chain chain; |
+ EXPECT_FALSE(checker->IsDependencyOf(&a_, &a_, &chain, &is_permitted)); |
- // A depends on B. |
+ // A depends publicly on B. |
chain.clear(); |
- is_public = false; |
- EXPECT_TRUE(checker->IsDependencyOf(&b_, &a_, &chain, &is_public)); |
+ is_permitted = false; |
+ EXPECT_TRUE(checker->IsDependencyOf(&b_, &a_, &chain, &is_permitted)); |
ASSERT_EQ(2u, chain.size()); |
- EXPECT_EQ(&b_, chain[0]); |
- EXPECT_EQ(&a_, chain[1]); |
- EXPECT_TRUE(is_public); |
+ EXPECT_EQ(HeaderChecker::ChainLink(&b_, true), chain[0]); |
+ EXPECT_EQ(HeaderChecker::ChainLink(&a_, true), chain[1]); |
+ EXPECT_TRUE(is_permitted); |
// A indirectly depends on C. The "public" dependency path through B should |
// be identified. |
chain.clear(); |
- is_public = false; |
- EXPECT_TRUE(checker->IsDependencyOf(&c_, &a_, &chain, &is_public)); |
+ is_permitted = false; |
+ EXPECT_TRUE(checker->IsDependencyOf(&c_, &a_, &chain, &is_permitted)); |
ASSERT_EQ(3u, chain.size()); |
- EXPECT_EQ(&c_, chain[0]); |
- EXPECT_EQ(&b_, chain[1]); |
- EXPECT_EQ(&a_, chain[2]); |
- EXPECT_TRUE(is_public); |
+ EXPECT_EQ(HeaderChecker::ChainLink(&c_, true), chain[0]); |
+ EXPECT_EQ(HeaderChecker::ChainLink(&b_, true), chain[1]); |
+ EXPECT_EQ(HeaderChecker::ChainLink(&a_, true), chain[2]); |
+ EXPECT_TRUE(is_permitted); |
// C does not depend on A. |
chain.clear(); |
- is_public = false; |
- EXPECT_FALSE(checker->IsDependencyOf(&a_, &c_, &chain, &is_public)); |
+ is_permitted = false; |
+ EXPECT_FALSE(checker->IsDependencyOf(&a_, &c_, &chain, &is_permitted)); |
EXPECT_TRUE(chain.empty()); |
- EXPECT_FALSE(is_public); |
+ EXPECT_FALSE(is_permitted); |
- // Add a private A -> C dependency. This should not be detected since it's |
- // private, even though it's shorter than the A -> B -> C one. |
+ // Remove the B -> C public dependency, leaving P's private dep on C the only |
+ // path from A to C. This should now be found. |
chain.clear(); |
- is_public = false; |
- a_.private_deps().push_back(LabelTargetPair(&c_)); |
- EXPECT_TRUE(checker->IsDependencyOf(&c_, &a_, &chain, &is_public)); |
- EXPECT_EQ(&c_, chain[0]); |
- EXPECT_EQ(&b_, chain[1]); |
- EXPECT_EQ(&a_, chain[2]); |
- EXPECT_TRUE(is_public); |
- |
- // Remove the B -> C public dependency, leaving A's private dep on C the only |
- // path. This should now be found. |
- chain.clear(); |
- EXPECT_EQ(&c_, b_.public_deps()[0].ptr); // Validate it's the right one. |
+ EXPECT_EQ(&c_, b_.public_deps()[0].ptr); // Validate it's the right one. |
b_.public_deps().erase(b_.public_deps().begin()); |
- EXPECT_TRUE(checker->IsDependencyOf(&c_, &a_, &chain, &is_public)); |
- EXPECT_EQ(&c_, chain[0]); |
- EXPECT_EQ(&a_, chain[1]); |
- EXPECT_FALSE(is_public); |
+ EXPECT_TRUE(checker->IsDependencyOf(&c_, &a_, &chain, &is_permitted)); |
+ EXPECT_EQ(3u, chain.size()); |
+ EXPECT_EQ(HeaderChecker::ChainLink(&c_, false), chain[0]); |
+ EXPECT_EQ(HeaderChecker::ChainLink(&p, true), chain[1]); |
scottmg
2014/09/18 22:33:52
hm, no i guess is_public for ChainLink makes sense
|
+ EXPECT_EQ(HeaderChecker::ChainLink(&a_, true), chain[2]); |
+ EXPECT_FALSE(is_permitted); |
+ |
scottmg
2014/09/18 22:33:52
since the iteration depends on discarding disallow
|
+ // P privately depends on C. That dependency should be OK since it's only |
+ // one hop. |
+ chain.clear(); |
+ is_permitted = false; |
+ EXPECT_TRUE(checker->IsDependencyOf(&c_, &p, &chain, &is_permitted)); |
+ ASSERT_EQ(2u, chain.size()); |
+ EXPECT_EQ(HeaderChecker::ChainLink(&c_, false), chain[0]); |
+ EXPECT_EQ(HeaderChecker::ChainLink(&p, true), chain[1]); |
+ EXPECT_TRUE(is_permitted); |
scottmg
2014/09/18 22:33:52
Maybe a test that
A -> B -> C -> D
is right too,
|
} |
TEST_F(HeaderCheckerTest, CheckInclude) { |