Index: tools/gn/analyzer_unittest.cc |
diff --git a/tools/gn/analyzer_unittest.cc b/tools/gn/analyzer_unittest.cc |
index a3c8d5becb7b31b6a0270d5d87139697ac8ad33a..3a82ceaf601d4a68832d1e4a806b78a9a7ad5974 100644 |
--- a/tools/gn/analyzer_unittest.cc |
+++ b/tools/gn/analyzer_unittest.cc |
@@ -49,9 +49,13 @@ class AnalyzerTest : public testing::Test { |
const std::string name, |
Target::OutputType type, |
const std::vector<std::string>& sources, |
- const std::vector<Target*>& deps) { |
+ const std::vector<Target*>& deps, |
+ const std::vector<std::string>& gn_files) { |
Label lbl(SourceDir(dir), name, tc_dir_, tc_name_); |
- Target* target = new Target(&settings_, lbl); |
+ std::set<uint32_t> source_files_hashes; |
+ for (const auto& gn : gn_files) |
+ source_files_hashes.insert(base::Hash(gn)); |
+ Target* target = new Target(&settings_, lbl, source_files_hashes); |
target->set_output_type(type); |
for (const auto& s : sources) |
target->sources().push_back(SourceFile(s)); |
@@ -73,25 +77,29 @@ class AnalyzerTest : public testing::Test { |
// get leaked. |
// Ignore the returned target since nothing depends on it. |
- MakeTarget("//", "a", Target::EXECUTABLE, {"//a.cc"}, no_deps); |
+ MakeTarget("//", "a", Target::EXECUTABLE, {"//a.cc"}, no_deps, |
+ {"//BUILD.gn", "//features.gni"}); |
- Target* b = |
- MakeTarget("//d", "b", Target::SOURCE_SET, {"//d/b.cc"}, no_deps); |
+ Target* b = MakeTarget("//d", "b", Target::SOURCE_SET, {"//d/b.cc"}, |
+ no_deps, {"//d/BUILD.gn"}); |
- Target* b_unittests = MakeTarget("//d", "b_unittests", Target::EXECUTABLE, |
- {"//d/b_unittest.cc"}, {b}); |
+ Target* b_unittests = |
+ MakeTarget("//d", "b_unittests", Target::EXECUTABLE, |
+ {"//d/b_unittest.cc"}, {b}, {"//d/BUILD.gn"}); |
- Target* c = MakeTarget("//d", "c", Target::EXECUTABLE, {"//d/c.cc"}, {b}); |
+ Target* c = MakeTarget("//d", "c", Target::EXECUTABLE, {"//d/c.cc"}, {b}, |
+ {"//d/BUILD.gn"}); |
Target* b_unittests_and_c = |
MakeTarget("//d", "b_unittests_and_c", Target::GROUP, no_sources, |
- {b_unittests, c}); |
+ {b_unittests, c}, {"//d/BUILD.gn"}); |
- Target* e = |
- MakeTarget("//d", "e", Target::EXECUTABLE, {"//d/e.cc"}, no_deps); |
+ Target* e = MakeTarget("//d", "e", Target::EXECUTABLE, {"//d/e.cc"}, |
+ no_deps, {"//d/BUILD.gn"}); |
// Also ignore this returned target since nothing depends on it. |
- MakeTarget("//d", "d", Target::GROUP, no_sources, {b_unittests_and_c, e}); |
+ MakeTarget("//d", "d", Target::GROUP, no_sources, {b_unittests_and_c, e}, |
+ {"//d/BUILD.gn"}); |
} |
void RunBasicTest(const std::string& input, |
@@ -201,13 +209,10 @@ TEST_F(AnalyzerTest, WrongInputFields) { |
"}"); |
} |
-TEST_F(AnalyzerTest, BuildFilesWereModified) { |
- // This tests that if a build file is modified, we bail out early with |
- // "Found dependency (all)" error since we can't handle changes to |
- // build files yet (crbug.com/555273). |
+TEST_F(AnalyzerTest, DotGnFileWasModified) { |
RunBasicTest( |
"{" |
- " \"files\": [ \"//a.cc\", \"//BUILD.gn\" ]," |
+ " \"files\": [ \"//.gn\" ]," |
" \"additional_compile_targets\": []," |
" \"test_targets\": [ \"//:a\" ]" |
"}", |
@@ -218,13 +223,10 @@ TEST_F(AnalyzerTest, BuildFilesWereModified) { |
"}"); |
} |
-TEST_F(AnalyzerTest, BuildFilesWereModifiedAndCompilingAll) { |
- // This tests that if a build file is modified, we bail out early with |
- // "Found dependency (all)" error since we can't handle changes to |
- // build files yet (crbug.com/555273). |
+TEST_F(AnalyzerTest, DotGnFileWasModifiedAndCompilingAll) { |
RunBasicTest( |
"{" |
- " \"files\": [ \"//a.cc\", \"//BUILD.gn\" ]," |
+ " \"files\": [ \"//.gn\" ]," |
" \"additional_compile_targets\": [ \"all\" ]," |
" \"test_targets\": [ \"//:a\" ]" |
"}", |
@@ -234,3 +236,45 @@ TEST_F(AnalyzerTest, BuildFilesWereModifiedAndCompilingAll) { |
"\"test_targets\":[\"//:a\"]" |
"}"); |
} |
+ |
+TEST_F(AnalyzerTest, BuildFileWasModified) { |
+ RunBasicTest( |
+ "{" |
+ " \"files\": [ \"//BUILD.gn\" ]," |
+ " \"additional_compile_targets\": []," |
+ " \"test_targets\": [ \"//:a\" ]" |
+ "}", |
+ "{" |
+ "\"compile_targets\":[]," |
+ "\"status\":\"Found dependency\"," |
+ "\"test_targets\":[\"//:a\"]" |
+ "}"); |
+} |
+ |
+TEST_F(AnalyzerTest, BuildFileWasModifiedAndCompilingAll) { |
+ RunBasicTest( |
+ "{" |
+ " \"files\": [ \"//BUILD.gn\" ]," |
+ " \"additional_compile_targets\": [ \"all\" ]," |
+ " \"test_targets\": [ \"//:a\" ]" |
+ "}", |
+ "{" |
+ "\"compile_targets\":[\"//:a\"]," |
+ "\"status\":\"Found dependency\"," |
+ "\"test_targets\":[\"//:a\"]" |
+ "}"); |
+} |
+ |
+TEST_F(AnalyzerTest, UnnededBuildFileWasModified) { |
+ RunBasicTest( |
+ "{" |
+ " \"files\": [ \"//BUILD.gn\" ]," |
+ " \"additional_compile_targets\": []," |
+ " \"test_targets\": [ \"//d:b_unittests\" ]" |
+ "}", |
+ "{" |
+ "\"compile_targets\":[]," |
+ "\"status\":\"No dependency\"," |
+ "\"test_targets\":[]" |
+ "}"); |
+} |