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

Side by Side Diff: tools/gn/header_checker_unittest.cc

Issue 1476263005: Test for generated files being detected during `gn check`. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-check-bug
Patch Set: Created 5 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/gn/test_with_scope.cc » ('j') | tools/gn/test_with_scope.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « no previous file | tools/gn/test_with_scope.cc » ('j') | tools/gn/test_with_scope.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698