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

Side by Side Diff: tools/gn/ninja_group_target_writer_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, 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
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 Err err; 11 Err err;
12 TestWithScope setup; 12 TestWithScope setup;
13 13
14 Target target(setup.settings(), Label(SourceDir("//foo/"), "bar")); 14 Target target(setup.settings(), Label(SourceDir("//foo/"), "bar"), {});
15 target.set_output_type(Target::GROUP); 15 target.set_output_type(Target::GROUP);
16 target.visibility().SetPublic(); 16 target.visibility().SetPublic();
17 17
18 Target dep(setup.settings(), Label(SourceDir("//foo/"), "dep")); 18 Target dep(setup.settings(), Label(SourceDir("//foo/"), "dep"), {});
19 dep.set_output_type(Target::ACTION); 19 dep.set_output_type(Target::ACTION);
20 dep.visibility().SetPublic(); 20 dep.visibility().SetPublic();
21 dep.SetToolchain(setup.toolchain()); 21 dep.SetToolchain(setup.toolchain());
22 ASSERT_TRUE(dep.OnResolved(&err)); 22 ASSERT_TRUE(dep.OnResolved(&err));
23 23
24 Target dep2(setup.settings(), Label(SourceDir("//foo/"), "dep2")); 24 Target dep2(setup.settings(), Label(SourceDir("//foo/"), "dep2"), {});
25 dep2.set_output_type(Target::ACTION); 25 dep2.set_output_type(Target::ACTION);
26 dep2.visibility().SetPublic(); 26 dep2.visibility().SetPublic();
27 dep2.SetToolchain(setup.toolchain()); 27 dep2.SetToolchain(setup.toolchain());
28 ASSERT_TRUE(dep2.OnResolved(&err)); 28 ASSERT_TRUE(dep2.OnResolved(&err));
29 29
30 Target datadep(setup.settings(), Label(SourceDir("//foo/"), "datadep")); 30 Target datadep(setup.settings(), Label(SourceDir("//foo/"), "datadep"), {});
31 datadep.set_output_type(Target::ACTION); 31 datadep.set_output_type(Target::ACTION);
32 datadep.visibility().SetPublic(); 32 datadep.visibility().SetPublic();
33 datadep.SetToolchain(setup.toolchain()); 33 datadep.SetToolchain(setup.toolchain());
34 ASSERT_TRUE(datadep.OnResolved(&err)); 34 ASSERT_TRUE(datadep.OnResolved(&err));
35 35
36 target.public_deps().push_back(LabelTargetPair(&dep)); 36 target.public_deps().push_back(LabelTargetPair(&dep));
37 target.public_deps().push_back(LabelTargetPair(&dep2)); 37 target.public_deps().push_back(LabelTargetPair(&dep2));
38 target.data_deps().push_back(LabelTargetPair(&datadep)); 38 target.data_deps().push_back(LabelTargetPair(&datadep));
39 39
40 target.SetToolchain(setup.toolchain()); 40 target.SetToolchain(setup.toolchain());
41 ASSERT_TRUE(target.OnResolved(&err)); 41 ASSERT_TRUE(target.OnResolved(&err));
42 42
43 std::ostringstream out; 43 std::ostringstream out;
44 NinjaGroupTargetWriter writer(&target, out); 44 NinjaGroupTargetWriter writer(&target, out);
45 writer.Run(); 45 writer.Run();
46 46
47 const char expected[] = 47 const char expected[] =
48 "build obj/foo/bar.stamp: stamp obj/foo/dep.stamp obj/foo/dep2.stamp || ob j/foo/datadep.stamp\n"; 48 "build obj/foo/bar.stamp: stamp obj/foo/dep.stamp obj/foo/dep2.stamp || ob j/foo/datadep.stamp\n";
49 EXPECT_EQ(expected, out.str()); 49 EXPECT_EQ(expected, out.str());
50 } 50 }
OLDNEW
« no previous file with comments | « tools/gn/ninja_create_bundle_target_writer_unittest.cc ('k') | tools/gn/ninja_target_writer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698