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

Unified Diff: tools/gn/header_checker_unittest.cc

Issue 1142423004: Make GN header checker more lenient about toolchains. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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/header_checker.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/header_checker_unittest.cc
diff --git a/tools/gn/header_checker_unittest.cc b/tools/gn/header_checker_unittest.cc
index e445a692ef6bcbb35cc23db1270bfb99c4d01745..19d5e4054fd4f850d0f6672180166c57b7ca8abb 100644
--- a/tools/gn/header_checker_unittest.cc
+++ b/tools/gn/header_checker_unittest.cc
@@ -162,12 +162,33 @@ TEST_F(HeaderCheckerTest, CheckInclude) {
c_.public_headers().push_back(c_public);
c_.set_all_headers_public(false);
+ // Create another toolchain.
+ Settings other_settings(setup_.build_settings(), "other/");
+ Toolchain other_toolchain(&other_settings,
+ Label(SourceDir("//toolchain/"), "other"));
+ TestWithScope::SetupToolchain(&other_toolchain);
+ other_settings.set_toolchain_label(other_toolchain.label());
+ other_settings.set_default_toolchain_label(setup_.toolchain()->label());
+
+ // Add a target in the other toolchain with a header in it that is not
+ // connected to any targets in the main toolchain.
+ Target otc(&other_settings, Label(SourceDir("//p/"), "otc",
+ other_toolchain.label().dir(), other_toolchain.label().name()));
+ otc.set_output_type(Target::SOURCE_SET);
+ Err err;
+ EXPECT_TRUE(otc.SetToolchain(&other_toolchain, &err));
+ otc.visibility().SetPublic();
+ targets_.push_back(&otc);
+
+ SourceFile otc_header("//otc_header.h");
+ otc.sources().push_back(otc_header);
+ EXPECT_TRUE(otc.OnResolved(&err));
+
scoped_refptr<HeaderChecker> checker(
new HeaderChecker(setup_.build_settings(), targets_));
// A file in target A can't include a header from D because A has no
// dependency on D.
- Err err;
EXPECT_FALSE(checker->CheckInclude(&a_, input_file, d_header, range, &err));
EXPECT_TRUE(err.has_error());
@@ -188,6 +209,12 @@ TEST_F(HeaderCheckerTest, CheckInclude) {
EXPECT_TRUE(checker->CheckInclude(&a_, input_file, SourceFile("//random.h"),
range, &err));
EXPECT_FALSE(err.has_error());
+
+ // A can depend on a file present only in another toolchain even with no
+ // dependency path.
+ err = Err();
+ EXPECT_TRUE(checker->CheckInclude(&a_, input_file, otc_header, range, &err));
+ EXPECT_FALSE(err.has_error());
}
// A public chain of dependencies should always be identified first, even if
« no previous file with comments | « tools/gn/header_checker.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698