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

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

Issue 21114002: Add initial prototype for the GN meta-buildsystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add owners and readme Created 7 years, 4 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/target_manager.cc ('k') | tools/gn/token.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "tools/gn/err.h"
7 #include "tools/gn/settings.h"
8 #include "tools/gn/target_manager.h"
9 #include "tools/gn/value.h"
10
11 /* TODO(brettw) make this compile again
12 namespace {
13
14 class TestTargetManagerDelegate : public TargetManager::Delegate {
15 public:
16 TestTargetManagerDelegate() {}
17
18 virtual bool ScheduleInvocation(ToolchainManager* toolchain_manager,
19 const LocationRange& origin,
20 const Label& toolchain_name,
21 const SourceDir& dir,
22 Err* err) OVERRIDE {
23 invokes.push_back(dir.value());
24 return true;
25 }
26 virtual void ScheduleTargetFileWrite(const Target* target) {
27 writes.push_back(target);
28 }
29
30 std::vector<std::string> invokes;
31 std::vector<const Target*> writes;
32 };
33
34 } // namespace
35
36 TEST(TargetManager, ResolveDeps) {
37 TestTargetManagerDelegate ttmd;
38 BuildSettings build_settings(&ttmd);
39
40 TargetManager& target_manager = build_settings.target_manager();
41
42 SourceDir tc_dir("/chrome/");
43 std::string tc_name("toolchain");
44
45 // Get a root target. This should not invoke anything.
46 Err err;
47 Label chromelabel(SourceDir("/chrome/"), "chrome", tc_dir, tc_name);
48 Target* chrome = target_manager.GetTarget(
49 chromelabel, LocationRange(), NULL, &err);
50 EXPECT_EQ(0u, ttmd.invokes.size());
51
52 // Declare it has a dependency on content1 and 2. We should get one
53 // invocation of the content build file.
54 Label content1label(SourceDir("/content/"), "content1", tc_dir, tc_name);
55 Target* content1 = target_manager.GetTarget(
56 content1label, LocationRange(), chrome, &err);
57 EXPECT_EQ(1u, ttmd.invokes.size());
58
59 Label content2label(SourceDir("/content/"), "content2", tc_dir, tc_name);
60 Target* content2 = target_manager.GetTarget(
61 content2label, LocationRange(), chrome, &err);
62 EXPECT_EQ(2u, ttmd.invokes.size());
63
64 // Declare chrome has a depdency on base, this should load it.
65 Label baselabel(SourceDir("/base/"), "base", tc_dir, tc_name);
66 Target* base1 = target_manager.GetTarget(
67 baselabel, LocationRange(), chrome, &err);
68 EXPECT_EQ(3u, ttmd.invokes.size());
69
70 // Declare content1 has a dependency on base.
71 Target* base2 = target_manager.GetTarget(
72 baselabel, LocationRange(), content1, &err);
73 EXPECT_EQ(3u, ttmd.invokes.size());
74 EXPECT_EQ(base1, base2);
75
76 // Mark content1 and chrome as done. They have unresolved depdendencies so
77 // shouldn't be written out yet.
78 target_manager.TargetGenerationComplete(content1label);
79 target_manager.TargetGenerationComplete(chromelabel);
80 EXPECT_EQ(0u, ttmd.writes.size());
81
82 // Mark content2 as done. It has no dependencies so should be written.
83 target_manager.TargetGenerationComplete(content2label);
84 ASSERT_EQ(1u, ttmd.writes.size());
85 EXPECT_EQ(content2label, ttmd.writes[0]->label());
86
87 // Mark base as complete. It should have caused itself, content1 and then
88 // chrome to be written.
89 target_manager.TargetGenerationComplete(baselabel);
90 ASSERT_EQ(4u, ttmd.writes.size());
91 EXPECT_EQ(baselabel, ttmd.writes[1]->label());
92 EXPECT_EQ(content1label, ttmd.writes[2]->label());
93 EXPECT_EQ(chromelabel, ttmd.writes[3]->label());
94 }
95 */
OLDNEW
« no previous file with comments | « tools/gn/target_manager.cc ('k') | tools/gn/token.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698