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

Side by Side Diff: tools/gn/builder_unittest.cc

Issue 350743004: Allow dependencies of toolchains in GN. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gn/builder.cc ('k') | tools/gn/function_toolchain.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "tools/gn/builder.h" 6 #include "tools/gn/builder.h"
7 #include "tools/gn/loader.h" 7 #include "tools/gn/loader.h"
8 #include "tools/gn/target.h" 8 #include "tools/gn/target.h"
9 #include "tools/gn/test_with_scope.h" 9 #include "tools/gn/test_with_scope.h"
10 #include "tools/gn/toolchain.h" 10 #include "tools/gn/toolchain.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 Settings settings_; 82 Settings settings_;
83 Scope scope_; 83 Scope scope_;
84 }; 84 };
85 85
86 } // namespace 86 } // namespace
87 87
88 TEST_F(BuilderTest, BasicDeps) { 88 TEST_F(BuilderTest, BasicDeps) {
89 SourceDir toolchain_dir = settings_.toolchain_label().dir(); 89 SourceDir toolchain_dir = settings_.toolchain_label().dir();
90 std::string toolchain_name = settings_.toolchain_label().name(); 90 std::string toolchain_name = settings_.toolchain_label().name();
91 91
92 DefineToolchain();
93 BuilderRecord* toolchain_record =
94 builder_->GetRecord(settings_.toolchain_label());
95 ASSERT_TRUE(toolchain_record);
96 EXPECT_EQ(BuilderRecord::ITEM_TOOLCHAIN, toolchain_record->type());
97
98 // Construct a dependency chain: A -> B -> C. Define A first with a 92 // Construct a dependency chain: A -> B -> C. Define A first with a
99 // forward-reference to B, then C, then B to test the different orders that 93 // forward-reference to B, then C, then B to test the different orders that
100 // the dependencies are hooked up. 94 // the dependencies are hooked up.
101 Label a_label(SourceDir("//a/"), "a", toolchain_dir, toolchain_name); 95 Label a_label(SourceDir("//a/"), "a", toolchain_dir, toolchain_name);
102 Label b_label(SourceDir("//b/"), "b", toolchain_dir, toolchain_name); 96 Label b_label(SourceDir("//b/"), "b", toolchain_dir, toolchain_name);
103 Label c_label(SourceDir("//c/"), "c", toolchain_dir, toolchain_name); 97 Label c_label(SourceDir("//c/"), "c", toolchain_dir, toolchain_name);
104 98
105 // The builder will take ownership of the pointers. 99 // The builder will take ownership of the pointers.
106 Target* a = new Target(&settings_, a_label); 100 Target* a = new Target(&settings_, a_label);
107 a->deps().push_back(LabelTargetPair(b_label)); 101 a->deps().push_back(LabelTargetPair(b_label));
108 a->set_output_type(Target::EXECUTABLE); 102 a->set_output_type(Target::EXECUTABLE);
109 builder_->ItemDefined(scoped_ptr<Item>(a)); 103 builder_->ItemDefined(scoped_ptr<Item>(a));
110 104
111 // Should have requested that B and the toolchain is loaded. 105 // Should have requested that B and the toolchain is loaded.
112 EXPECT_TRUE(loader_->HasLoadedTwo(SourceFile("//tc/BUILD.gn"), 106 EXPECT_TRUE(loader_->HasLoadedTwo(SourceFile("//tc/BUILD.gn"),
113 SourceFile("//b/BUILD.gn"))); 107 SourceFile("//b/BUILD.gn")));
114 108
109 // Define the toolchain.
110 DefineToolchain();
111 BuilderRecord* toolchain_record =
112 builder_->GetRecord(settings_.toolchain_label());
113 ASSERT_TRUE(toolchain_record);
114 EXPECT_EQ(BuilderRecord::ITEM_TOOLCHAIN, toolchain_record->type());
115
115 // A should be unresolved with an item 116 // A should be unresolved with an item
116 BuilderRecord* a_record = builder_->GetRecord(a_label); 117 BuilderRecord* a_record = builder_->GetRecord(a_label);
117 EXPECT_TRUE(a_record->item()); 118 EXPECT_TRUE(a_record->item());
118 EXPECT_FALSE(a_record->resolved()); 119 EXPECT_FALSE(a_record->resolved());
119 EXPECT_FALSE(a_record->can_resolve()); 120 EXPECT_FALSE(a_record->can_resolve());
120 121
121 // B should be unresolved, have no item, and no deps. 122 // B should be unresolved, have no item, and no deps.
122 BuilderRecord* b_record = builder_->GetRecord(b_label); 123 BuilderRecord* b_record = builder_->GetRecord(b_label);
123 EXPECT_FALSE(b_record->item()); 124 EXPECT_FALSE(b_record->item());
124 EXPECT_FALSE(b_record->resolved()); 125 EXPECT_FALSE(b_record->resolved());
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 a->set_output_type(Target::EXECUTABLE); 208 a->set_output_type(Target::EXECUTABLE);
208 builder_->ItemDefined(scoped_ptr<Item>(a)); 209 builder_->ItemDefined(scoped_ptr<Item>(a));
209 210
210 // A should have the generate bit set since it's in the default toolchain. 211 // A should have the generate bit set since it's in the default toolchain.
211 BuilderRecord* a_record = builder_->GetRecord(a_label); 212 BuilderRecord* a_record = builder_->GetRecord(a_label);
212 EXPECT_TRUE(a_record->should_generate()); 213 EXPECT_TRUE(a_record->should_generate());
213 214
214 // It should have gotten pushed to B. 215 // It should have gotten pushed to B.
215 EXPECT_TRUE(b_record->should_generate()); 216 EXPECT_TRUE(b_record->should_generate());
216 } 217 }
OLDNEW
« no previous file with comments | « tools/gn/builder.cc ('k') | tools/gn/function_toolchain.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698