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

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

Issue 561273003: Add public deps to GN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 6 years, 3 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
« no previous file with comments | « tools/gn/ninja_group_target_writer.cc ('k') | tools/gn/ninja_target_writer_unittest.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/ninja_group_target_writer.h" 6 #include "tools/gn/ninja_group_target_writer.h"
7 #include "tools/gn/target.h" 7 #include "tools/gn/target.h"
8 #include "tools/gn/test_with_scope.h" 8 #include "tools/gn/test_with_scope.h"
9 9
10 TEST(NinjaGroupTargetWriter, Run) { 10 TEST(NinjaGroupTargetWriter, Run) {
11 TestWithScope setup; 11 TestWithScope setup;
12 Err err; 12 Err err;
13 13
14 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/")); 14 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/"));
15 Target target(setup.settings(), Label(SourceDir("//foo/"), "bar")); 15 Target target(setup.settings(), Label(SourceDir("//foo/"), "bar"));
16 16
17 target.set_output_type(Target::GROUP); 17 target.set_output_type(Target::GROUP);
18 target.visibility().SetPublic();
18 19
19 Target dep(setup.settings(), Label(SourceDir("//foo/"), "dep")); 20 Target dep(setup.settings(), Label(SourceDir("//foo/"), "dep"));
20 dep.set_output_type(Target::ACTION); 21 dep.set_output_type(Target::ACTION);
22 dep.visibility().SetPublic();
21 dep.SetToolchain(setup.toolchain()); 23 dep.SetToolchain(setup.toolchain());
22 ASSERT_TRUE(dep.OnResolved(&err)); 24 ASSERT_TRUE(dep.OnResolved(&err));
23 25
24 Target dep2(setup.settings(), Label(SourceDir("//foo/"), "dep2")); 26 Target dep2(setup.settings(), Label(SourceDir("//foo/"), "dep2"));
25 dep2.set_output_type(Target::ACTION); 27 dep2.set_output_type(Target::ACTION);
28 dep2.visibility().SetPublic();
26 dep2.SetToolchain(setup.toolchain()); 29 dep2.SetToolchain(setup.toolchain());
27 ASSERT_TRUE(dep2.OnResolved(&err)); 30 ASSERT_TRUE(dep2.OnResolved(&err));
28 31
29 Target datadep(setup.settings(), Label(SourceDir("//foo/"), "datadep")); 32 Target datadep(setup.settings(), Label(SourceDir("//foo/"), "datadep"));
30 datadep.set_output_type(Target::ACTION); 33 datadep.set_output_type(Target::ACTION);
34 datadep.visibility().SetPublic();
31 datadep.SetToolchain(setup.toolchain()); 35 datadep.SetToolchain(setup.toolchain());
32 ASSERT_TRUE(datadep.OnResolved(&err)); 36 ASSERT_TRUE(datadep.OnResolved(&err));
33 37
34 target.deps().push_back(LabelTargetPair(&dep)); 38 target.public_deps().push_back(LabelTargetPair(&dep));
35 target.deps().push_back(LabelTargetPair(&dep2)); 39 target.public_deps().push_back(LabelTargetPair(&dep2));
36 target.datadeps().push_back(LabelTargetPair(&datadep)); 40 target.data_deps().push_back(LabelTargetPair(&datadep));
37 41
38 target.SetToolchain(setup.toolchain()); 42 target.SetToolchain(setup.toolchain());
39 ASSERT_TRUE(target.OnResolved(&err)); 43 ASSERT_TRUE(target.OnResolved(&err));
40 44
41 std::ostringstream out; 45 std::ostringstream out;
42 NinjaGroupTargetWriter writer(&target, out); 46 NinjaGroupTargetWriter writer(&target, out);
43 writer.Run(); 47 writer.Run();
44 48
45 const char expected[] = 49 const char expected[] =
46 "build obj/foo/bar.stamp: stamp obj/foo/dep.stamp obj/foo/dep2.stamp || ob j/foo/datadep.stamp\n"; 50 "build obj/foo/bar.stamp: stamp obj/foo/dep.stamp obj/foo/dep2.stamp || ob j/foo/datadep.stamp\n";
47 EXPECT_EQ(expected, out.str()); 51 EXPECT_EQ(expected, out.str());
48 } 52 }
OLDNEW
« no previous file with comments | « tools/gn/ninja_group_target_writer.cc ('k') | tools/gn/ninja_target_writer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698