Index: tools/gn/scope_unittest.cc |
diff --git a/tools/gn/scope_unittest.cc b/tools/gn/scope_unittest.cc |
index a90d725d8dfb4326a0502f55cb8f5d34e133bfe1..534358726ac111caf7860e88a449c3bf18a08ba0 100644 |
--- a/tools/gn/scope_unittest.cc |
+++ b/tools/gn/scope_unittest.cc |
@@ -51,7 +51,7 @@ TEST(Scope, NonRecursiveMergeTo) { |
// Detect collisions of values' values. |
{ |
- Scope new_scope(setup.settings()); |
+ Scope new_scope(setup.settings(), {}); |
Value new_value(&assignment, "goodbye"); |
new_scope.SetValue("v", new_value, &assignment); |
@@ -64,7 +64,7 @@ TEST(Scope, NonRecursiveMergeTo) { |
// Template name collisions. |
{ |
- Scope new_scope(setup.settings()); |
+ Scope new_scope(setup.settings(), {}); |
scoped_refptr<Template> new_templ( |
new Template(&new_scope, &templ_definition)); |
@@ -78,7 +78,7 @@ TEST(Scope, NonRecursiveMergeTo) { |
// The clobber flag should just overwrite colliding values. |
{ |
- Scope new_scope(setup.settings()); |
+ Scope new_scope(setup.settings(), {}); |
Value new_value(&assignment, "goodbye"); |
new_scope.SetValue("v", new_value, &assignment); |
@@ -96,7 +96,7 @@ TEST(Scope, NonRecursiveMergeTo) { |
// Clobber flag for templates. |
{ |
- Scope new_scope(setup.settings()); |
+ Scope new_scope(setup.settings(), {}); |
scoped_refptr<Template> new_templ( |
new Template(&new_scope, &templ_definition)); |
@@ -116,7 +116,7 @@ TEST(Scope, NonRecursiveMergeTo) { |
// Don't flag values that technically collide but have the same value. |
{ |
- Scope new_scope(setup.settings()); |
+ Scope new_scope(setup.settings(), {}); |
Value new_value(&assignment, "hello"); |
new_scope.SetValue("v", new_value, &assignment); |
@@ -128,7 +128,7 @@ TEST(Scope, NonRecursiveMergeTo) { |
// Templates that technically collide but are the same. |
{ |
- Scope new_scope(setup.settings()); |
+ Scope new_scope(setup.settings(), {}); |
scoped_refptr<Template> new_templ( |
new Template(&new_scope, &templ_definition)); |
@@ -142,7 +142,7 @@ TEST(Scope, NonRecursiveMergeTo) { |
// Copy private values and templates. |
{ |
- Scope new_scope(setup.settings()); |
+ Scope new_scope(setup.settings(), {}); |
Err err; |
EXPECT_TRUE(setup.scope()->NonRecursiveMergeTo( |
@@ -154,7 +154,7 @@ TEST(Scope, NonRecursiveMergeTo) { |
// Skip private values and templates. |
{ |
- Scope new_scope(setup.settings()); |
+ Scope new_scope(setup.settings(), {}); |
Err err; |
Scope::MergeOptions options; |
@@ -168,7 +168,7 @@ TEST(Scope, NonRecursiveMergeTo) { |
// Don't mark used. |
{ |
- Scope new_scope(setup.settings()); |
+ Scope new_scope(setup.settings(), {}); |
Err err; |
Scope::MergeOptions options; |
@@ -181,7 +181,7 @@ TEST(Scope, NonRecursiveMergeTo) { |
// Mark dest used. |
{ |
- Scope new_scope(setup.settings()); |
+ Scope new_scope(setup.settings(), {}); |
Err err; |
Scope::MergeOptions options; |
@@ -192,6 +192,23 @@ TEST(Scope, NonRecursiveMergeTo) { |
EXPECT_TRUE(new_scope.CheckForUnusedVars(&err)); |
EXPECT_FALSE(err.has_error()); |
} |
+ |
+ // Source file hashes are merged. |
+ { |
+ Scope gni_scope(setup.settings(), {base::Hash("//features.gni")}); |
+ Scope new_scope(setup.settings(), {base::Hash("//BUILD.gn")}); |
+ |
+ Err err; |
+ Scope::MergeOptions options; |
+ EXPECT_TRUE(gni_scope.NonRecursiveMergeTo(&new_scope, options, &assignment, |
+ "error", &err)); |
+ EXPECT_FALSE(err.has_error()); |
+ const auto& source_files_hashes = new_scope.source_files_hashes(); |
+ EXPECT_NE(source_files_hashes.end(), |
+ source_files_hashes.find(base::Hash("//features.gni"))); |
+ EXPECT_NE(source_files_hashes.end(), |
+ source_files_hashes.find(base::Hash("//BUILD.gn"))); |
+ } |
} |
TEST(Scope, MakeClosure) { |
@@ -207,6 +224,7 @@ TEST(Scope, MakeClosure) { |
assignment.set_value(assignment_token); |
setup.scope()->SetValue("on_root", Value(&assignment, "on_root"), |
&assignment); |
+ setup.scope()->AddSourceFile(SourceFile("//features.gni")); |
// Root scope should be const from the nested caller's perspective. |
Scope nested1(static_cast<const Scope*>(setup.scope())); |
@@ -228,6 +246,17 @@ TEST(Scope, MakeClosure) { |
EXPECT_TRUE(HasStringValueEqualTo(result.get(), "on_root", "on_root")); |
EXPECT_TRUE(HasStringValueEqualTo(result.get(), "on_one", "on_two")); |
EXPECT_TRUE(HasStringValueEqualTo(result.get(), "on_two", "on_two2")); |
+ |
+ { |
+ const auto& source_files_hashes = nested1.source_files_hashes(); |
+ EXPECT_NE(source_files_hashes.end(), |
+ source_files_hashes.find(base::Hash("//features.gni"))); |
+ } |
+ { |
+ const auto& source_files_hashes = nested2.source_files_hashes(); |
+ EXPECT_NE(source_files_hashes.end(), |
+ source_files_hashes.find(base::Hash("//features.gni"))); |
+ } |
} |
TEST(Scope, GetMutableValue) { |
@@ -248,7 +277,7 @@ TEST(Scope, GetMutableValue) { |
Value value(&assignment, "hello"); |
// Create a root scope with one value. |
- Scope root_scope(setup.settings()); |
+ Scope root_scope(setup.settings(), {}); |
root_scope.SetValue(kOnConst, value, &assignment); |
// Create a first nested scope with a different value. |