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

Unified Diff: tools/gn/scope_unittest.cc

Issue 2940873002: Implement tracking of BUILD.gn files used to define target, toolchain or (Closed)
Patch Set: Fix compilation after rebase. Created 3 years, 6 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/scope_per_file_provider_unittest.cc ('k') | tools/gn/settings.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/scope_unittest.cc
diff --git a/tools/gn/scope_unittest.cc b/tools/gn/scope_unittest.cc
index a90d725d8dfb4326a0502f55cb8f5d34e133bfe1..7f0df43a4b0b308288c91976e8749567eaab875d 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());
}
+
+ // Input files are merged.
+ {
+ InputFile gni_input_file(SourceFile("//features.gni"));
+ InputFile root_input_file(SourceFile("//BUILD.gn"));
+ Scope gni_scope(setup.settings(), {&gni_input_file});
+ Scope new_scope(setup.settings(), {&root_input_file});
+
+ Err err;
+ Scope::MergeOptions options;
+ EXPECT_TRUE(gni_scope.NonRecursiveMergeTo(&new_scope, options, &assignment,
+ "error", &err));
+ EXPECT_FALSE(err.has_error());
+ const auto& input_files = new_scope.input_files();
+ EXPECT_NE(input_files.end(), input_files.find(&gni_input_file));
+ EXPECT_NE(input_files.end(), input_files.find(&root_input_file));
+ }
}
TEST(Scope, MakeClosure) {
@@ -207,6 +224,8 @@ TEST(Scope, MakeClosure) {
assignment.set_value(assignment_token);
setup.scope()->SetValue("on_root", Value(&assignment, "on_root"),
&assignment);
+ InputFile gni_input_file(SourceFile("//features.gni"));
+ setup.scope()->AddInputFile(&gni_input_file);
// Root scope should be const from the nested caller's perspective.
Scope nested1(static_cast<const Scope*>(setup.scope()));
@@ -228,6 +247,15 @@ 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& input_files = nested1.input_files();
+ EXPECT_NE(input_files.end(), input_files.find(&gni_input_file));
+ }
+ {
+ const auto& input_files = nested2.input_files();
+ EXPECT_NE(input_files.end(), input_files.find(&gni_input_file));
+ }
}
TEST(Scope, GetMutableValue) {
@@ -248,7 +276,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.
« no previous file with comments | « tools/gn/scope_per_file_provider_unittest.cc ('k') | tools/gn/settings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698