| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "tools/gn/config.h" | 8 #include "tools/gn/config.h" |
| 9 #include "tools/gn/header_checker.h" | 9 #include "tools/gn/header_checker.h" |
| 10 #include "tools/gn/scheduler.h" | 10 #include "tools/gn/scheduler.h" |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 EXPECT_TRUE(err.has_error()); | 281 EXPECT_TRUE(err.has_error()); |
| 282 | 282 |
| 283 // Add an allow_circular_includes_from on A that lists B. | 283 // Add an allow_circular_includes_from on A that lists B. |
| 284 a_.allow_circular_includes_from().insert(b_.label()); | 284 a_.allow_circular_includes_from().insert(b_.label()); |
| 285 | 285 |
| 286 // Now the include from B to A should be allowed. | 286 // Now the include from B to A should be allowed. |
| 287 err = Err(); | 287 err = Err(); |
| 288 EXPECT_TRUE(checker->CheckInclude(&b_, input_file, a_public, range, &err)); | 288 EXPECT_TRUE(checker->CheckInclude(&b_, input_file, a_public, range, &err)); |
| 289 EXPECT_FALSE(err.has_error()); | 289 EXPECT_FALSE(err.has_error()); |
| 290 } | 290 } |
| 291 |
| 292 TEST_F(HeaderCheckerTest, SkipGeneratedFilesFromOtherTargets) { |
| 293 Err err; |
| 294 |
| 295 Target action(setup_.settings(), Label(SourceDir("//a"), "generate_file")); |
| 296 action.set_output_type(Target::ACTION); |
| 297 action.SetToolchain(setup_.toolchain(), &err); |
| 298 action.visibility().SetPublic(); |
| 299 action.action_values().outputs() = |
| 300 SubstitutionList::MakeForTest("//out/Debug/gen/a/a.h"); |
| 301 |
| 302 Target target(setup_.settings(), Label(SourceDir("//a"), "use_file")); |
| 303 target.set_output_type(Target::SOURCE_SET); |
| 304 target.SetToolchain(setup_.toolchain(), &err); |
| 305 target.visibility().SetPublic(); |
| 306 target.sources().push_back(SourceFile("//out/Debug/gen/a/a.h")); |
| 307 |
| 308 std::vector<const Target*> all_targets; |
| 309 all_targets.push_back(&action); |
| 310 all_targets.push_back(&target); |
| 311 std::vector<const Target*> to_check; |
| 312 to_check.push_back(&target); |
| 313 bool force_check = false; |
| 314 std::vector<Err> errs; |
| 315 scoped_refptr<HeaderChecker> checker( |
| 316 new HeaderChecker(setup_.build_settings(), all_targets)); |
| 317 EXPECT_TRUE(checker->Run(to_check, force_check, &errs)); |
| 318 } |
| OLD | NEW |