| OLD | NEW | 
|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "tools/gn/target.h" | 5 #include "tools/gn/target.h" | 
| 6 | 6 | 
| 7 #include <utility> | 7 #include <utility> | 
| 8 | 8 | 
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" | 
| 10 #include "tools/gn/build_settings.h" | 10 #include "tools/gn/build_settings.h" | 
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 580   TestTarget existent_generator(setup, "//foo:existent_generator", | 580   TestTarget existent_generator(setup, "//foo:existent_generator", | 
| 581                                 Target::EXECUTABLE); | 581                                 Target::EXECUTABLE); | 
| 582   existent_generator.sources().push_back(generated_file); | 582   existent_generator.sources().push_back(generated_file); | 
| 583   EXPECT_TRUE(existent_generator.OnResolved(&err)); | 583   EXPECT_TRUE(existent_generator.OnResolved(&err)); | 
| 584   scheduler.AddWrittenFile(generated_file); | 584   scheduler.AddWrittenFile(generated_file); | 
| 585 | 585 | 
| 586   // Should be OK. | 586   // Should be OK. | 
| 587   EXPECT_TRUE(scheduler.GetUnknownGeneratedInputs().empty()); | 587   EXPECT_TRUE(scheduler.GetUnknownGeneratedInputs().empty()); | 
| 588 } | 588 } | 
| 589 | 589 | 
|  | 590 // Tests that intermediate object files generated by binary targets are also | 
|  | 591 // considered generated for the purposes of input checking. Above, we tested | 
|  | 592 // the failure cases for generated inputs, so here only test .o files that are | 
|  | 593 // present. | 
|  | 594 TEST(Target, ObjectGeneratedInputs) { | 
|  | 595   Scheduler scheduler; | 
|  | 596   TestWithScope setup; | 
|  | 597   Err err; | 
|  | 598 | 
|  | 599   // This target compiles the source. | 
|  | 600   SourceFile source_file("//source.cc"); | 
|  | 601   TestTarget source_generator(setup, "//:source_target", Target::SOURCE_SET); | 
|  | 602   source_generator.sources().push_back(source_file); | 
|  | 603   EXPECT_TRUE(source_generator.OnResolved(&err)); | 
|  | 604 | 
|  | 605   // This is the object file that the test toolchain generates for the source. | 
|  | 606   SourceFile object_file("//out/Debug/obj/source_target.source.o"); | 
|  | 607 | 
|  | 608   TestTarget final_target(setup, "//:final", Target::ACTION); | 
|  | 609   final_target.inputs().push_back(object_file); | 
|  | 610   EXPECT_TRUE(final_target.OnResolved(&err)); | 
|  | 611 | 
|  | 612   AssertSchedulerHasOneUnknownFileMatching(&final_target, object_file); | 
|  | 613 } | 
|  | 614 | 
| 590 TEST(Target, ResolvePrecompiledHeaders) { | 615 TEST(Target, ResolvePrecompiledHeaders) { | 
| 591   TestWithScope setup; | 616   TestWithScope setup; | 
| 592   Err err; | 617   Err err; | 
| 593 | 618 | 
| 594   Target target(setup.settings(), Label(SourceDir("//foo/"), "bar")); | 619   Target target(setup.settings(), Label(SourceDir("//foo/"), "bar")); | 
| 595 | 620 | 
| 596   // Target with no settings, no configs, should be a no-op. | 621   // Target with no settings, no configs, should be a no-op. | 
| 597   EXPECT_TRUE(target.ResolvePrecompiledHeaders(&err)); | 622   EXPECT_TRUE(target.ResolvePrecompiledHeaders(&err)); | 
| 598 | 623 | 
| 599   // Config with PCH values. | 624   // Config with PCH values. | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 636       "\n" | 661       "\n" | 
| 637       "From //foo:bar\n" | 662       "From //foo:bar\n" | 
| 638       "  header: pch.h\n" | 663       "  header: pch.h\n" | 
| 639       "  source: //pcs.cc\n" | 664       "  source: //pcs.cc\n" | 
| 640       "\n" | 665       "\n" | 
| 641       "From //foo:c2\n" | 666       "From //foo:c2\n" | 
| 642       "  header: pch2.h\n" | 667       "  header: pch2.h\n" | 
| 643       "  source: //pcs2.cc", | 668       "  source: //pcs2.cc", | 
| 644       err.help_text()); | 669       err.help_text()); | 
| 645 } | 670 } | 
| OLD | NEW | 
|---|