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

Unified Diff: tools/gn/builder_unittest.cc

Issue 2152413002: GN: don't write separate files for non-binary targets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: typo Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/builder.h ('k') | tools/gn/command_check.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/builder_unittest.cc
diff --git a/tools/gn/builder_unittest.cc b/tools/gn/builder_unittest.cc
index 96fad7d268be2c5e8a8016a00bdadd0cbd8c1c48..616e76ae9df0f00355a21f9a8281cb62a70c9e5a 100644
--- a/tools/gn/builder_unittest.cc
+++ b/tools/gn/builder_unittest.cc
@@ -67,7 +67,7 @@ class BuilderTest : public testing::Test {
public:
BuilderTest()
: loader_(new MockLoader),
- builder_(new Builder(loader_.get())),
+ builder_(loader_.get()),
settings_(&build_settings_, std::string()),
scope_(&settings_) {
build_settings_.SetBuildDir(SourceDir("//out/"));
@@ -78,13 +78,13 @@ class BuilderTest : public testing::Test {
Toolchain* DefineToolchain() {
Toolchain* tc = new Toolchain(&settings_, settings_.toolchain_label());
TestWithScope::SetupToolchain(tc);
- builder_->ItemDefined(std::unique_ptr<Item>(tc));
+ builder_.ItemDefined(std::unique_ptr<Item>(tc));
return tc;
}
protected:
scoped_refptr<MockLoader> loader_;
- scoped_refptr<Builder> builder_;
+ Builder builder_;
BuildSettings build_settings_;
Settings settings_;
Scope scope_;
@@ -107,7 +107,7 @@ TEST_F(BuilderTest, BasicDeps) {
Target* a = new Target(&settings_, a_label);
a->public_deps().push_back(LabelTargetPair(b_label));
a->set_output_type(Target::EXECUTABLE);
- builder_->ItemDefined(std::unique_ptr<Item>(a));
+ builder_.ItemDefined(std::unique_ptr<Item>(a));
// Should have requested that B and the toolchain is loaded.
EXPECT_TRUE(loader_->HasLoadedTwo(SourceFile("//tc/BUILD.gn"),
@@ -116,18 +116,18 @@ TEST_F(BuilderTest, BasicDeps) {
// Define the toolchain.
DefineToolchain();
BuilderRecord* toolchain_record =
- builder_->GetRecord(settings_.toolchain_label());
+ builder_.GetRecord(settings_.toolchain_label());
ASSERT_TRUE(toolchain_record);
EXPECT_EQ(BuilderRecord::ITEM_TOOLCHAIN, toolchain_record->type());
// A should be unresolved with an item
- BuilderRecord* a_record = builder_->GetRecord(a_label);
+ BuilderRecord* a_record = builder_.GetRecord(a_label);
EXPECT_TRUE(a_record->item());
EXPECT_FALSE(a_record->resolved());
EXPECT_FALSE(a_record->can_resolve());
// B should be unresolved, have no item, and no deps.
- BuilderRecord* b_record = builder_->GetRecord(b_label);
+ BuilderRecord* b_record = builder_.GetRecord(b_label);
EXPECT_FALSE(b_record->item());
EXPECT_FALSE(b_record->resolved());
EXPECT_FALSE(b_record->can_resolve());
@@ -152,7 +152,7 @@ TEST_F(BuilderTest, BasicDeps) {
Target* c = new Target(&settings_, c_label);
c->set_output_type(Target::STATIC_LIBRARY);
c->visibility().SetPublic();
- builder_->ItemDefined(std::unique_ptr<Item>(c));
+ builder_.ItemDefined(std::unique_ptr<Item>(c));
// C only depends on the already-loaded toolchain so we shouldn't have
// requested anything else.
@@ -163,14 +163,14 @@ TEST_F(BuilderTest, BasicDeps) {
a->public_deps().push_back(LabelTargetPair(c_label));
b->set_output_type(Target::SHARED_LIBRARY);
b->visibility().SetPublic();
- builder_->ItemDefined(std::unique_ptr<Item>(b));
+ builder_.ItemDefined(std::unique_ptr<Item>(b));
// B depends only on the already-loaded C and toolchain so we shouldn't have
// requested anything else.
EXPECT_TRUE(loader_->HasLoadedNone());
// All targets should now be resolved.
- BuilderRecord* c_record = builder_->GetRecord(c_label);
+ BuilderRecord* c_record = builder_.GetRecord(c_label);
EXPECT_TRUE(a_record->resolved());
EXPECT_TRUE(b_record->resolved());
EXPECT_TRUE(c_record->resolved());
@@ -194,7 +194,7 @@ TEST_F(BuilderTest, ShouldGenerate) {
settings2.set_toolchain_label(toolchain_label2);
Toolchain* tc2 = new Toolchain(&settings2, toolchain_label2);
TestWithScope::SetupToolchain(tc2);
- builder_->ItemDefined(std::unique_ptr<Item>(tc2));
+ builder_.ItemDefined(std::unique_ptr<Item>(tc2));
// Construct a dependency chain: A -> B. A is in the default toolchain, B
// is not.
@@ -207,20 +207,20 @@ TEST_F(BuilderTest, ShouldGenerate) {
Target* b = new Target(&settings2, b_label);
b->visibility().SetPublic();
b->set_output_type(Target::EXECUTABLE);
- builder_->ItemDefined(std::unique_ptr<Item>(b));
+ builder_.ItemDefined(std::unique_ptr<Item>(b));
// B should not be marked generated by default.
- BuilderRecord* b_record = builder_->GetRecord(b_label);
+ BuilderRecord* b_record = builder_.GetRecord(b_label);
EXPECT_FALSE(b_record->should_generate());
// Define A with a dependency on B.
Target* a = new Target(&settings_, a_label);
a->public_deps().push_back(LabelTargetPair(b_label));
a->set_output_type(Target::EXECUTABLE);
- builder_->ItemDefined(std::unique_ptr<Item>(a));
+ builder_.ItemDefined(std::unique_ptr<Item>(a));
// A should have the generate bit set since it's in the default toolchain.
- BuilderRecord* a_record = builder_->GetRecord(a_label);
+ BuilderRecord* a_record = builder_.GetRecord(a_label);
EXPECT_TRUE(a_record->should_generate());
// It should have gotten pushed to B.
@@ -242,7 +242,7 @@ TEST_F(BuilderTest, ConfigLoad) {
// The builder will take ownership of the pointers.
Config* a = new Config(&settings_, a_label);
a->configs().push_back(LabelConfigPair(b_label));
- builder_->ItemDefined(std::unique_ptr<Item>(a));
+ builder_.ItemDefined(std::unique_ptr<Item>(a));
// Should have requested that B is loaded.
EXPECT_TRUE(loader_->HasLoadedOne(SourceFile("//b/BUILD.gn")));
« no previous file with comments | « tools/gn/builder.h ('k') | tools/gn/command_check.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698