Index: tools/gn/target_unittest.cc |
diff --git a/tools/gn/target_unittest.cc b/tools/gn/target_unittest.cc |
index 876c2e3f693790e521466c92a5e45239fe497726..b3a85b75a0d824d28bff94e24065c006a8bfb911 100644 |
--- a/tools/gn/target_unittest.cc |
+++ b/tools/gn/target_unittest.cc |
@@ -627,6 +627,53 @@ TEST(Target, WriteFileGeneratedInputs) { |
EXPECT_TRUE(scheduler.GetUnknownGeneratedInputs().empty()); |
} |
+TEST(Target, WriteRuntimeDepsGeneratedInputs) { |
+ Scheduler scheduler; |
+ TestWithScope setup; |
+ Err err; |
+ |
+ SourceFile source_file("//out/Debug/generated.runtime_deps"); |
+ OutputFile output_file(setup.build_settings(), source_file); |
+ |
+ TestTarget generator(setup, "//foo:generator", Target::EXECUTABLE); |
+ generator.set_write_runtime_deps_output(output_file); |
+ g_scheduler->AddWriteRuntimeDepsTarget(&generator); |
+ |
+ TestTarget middle_data_dep(setup, "//foo:middle", Target::EXECUTABLE); |
+ middle_data_dep.data_deps().push_back(LabelTargetPair(&generator)); |
+ |
+ // This target has a generated input and no dependency makes it. |
+ TestTarget dep_missing(setup, "//foo:no_dep", Target::EXECUTABLE); |
+ dep_missing.sources().push_back(source_file); |
+ EXPECT_TRUE(dep_missing.OnResolved(&err)); |
+ AssertSchedulerHasOneUnknownFileMatching(&dep_missing, source_file); |
+ scheduler.ClearUnknownGeneratedInputsAndWrittenFiles(); |
+ |
+ // This target has a generated file and we've directly dependended on it. |
+ TestTarget dep_present(setup, "//foo:with_dep", Target::EXECUTABLE); |
+ dep_present.sources().push_back(source_file); |
+ dep_present.private_deps().push_back(LabelTargetPair(&generator)); |
+ EXPECT_TRUE(dep_present.OnResolved(&err)); |
+ EXPECT_TRUE(scheduler.GetUnknownGeneratedInputs().empty()); |
+ |
+ // This target has a generated file and we've indirectly dependended on it |
+ // via data_deps. |
+ TestTarget dep_indirect(setup, "//foo:with_dep", Target::EXECUTABLE); |
+ dep_indirect.sources().push_back(source_file); |
+ dep_indirect.data_deps().push_back(LabelTargetPair(&middle_data_dep)); |
+ EXPECT_TRUE(dep_indirect.OnResolved(&err)); |
+ AssertSchedulerHasOneUnknownFileMatching(&dep_indirect, source_file); |
+ scheduler.ClearUnknownGeneratedInputsAndWrittenFiles(); |
+ |
+ // This target has a generated file and we've directly dependended on it |
+ // via data_deps. |
+ TestTarget data_dep_present(setup, "//foo:with_dep", Target::EXECUTABLE); |
+ data_dep_present.sources().push_back(source_file); |
+ data_dep_present.data_deps().push_back(LabelTargetPair(&generator)); |
+ EXPECT_TRUE(data_dep_present.OnResolved(&err)); |
+ EXPECT_TRUE(scheduler.GetUnknownGeneratedInputs().empty()); |
+} |
+ |
// Tests that intermediate object files generated by binary targets are also |
// considered generated for the purposes of input checking. Above, we tested |
// the failure cases for generated inputs, so here only test .o files that are |