[Session restore] Rename group name Enabled to Restore.
[chromium-blink-merge.git] / tools / gn / ninja_group_target_writer_unittest.cc
blobc9d0ab4553d80ecc99980e3d7adb2450515989ac
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
3 // found in the LICENSE file.
5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "tools/gn/ninja_group_target_writer.h"
7 #include "tools/gn/target.h"
8 #include "tools/gn/test_with_scope.h"
10 TEST(NinjaGroupTargetWriter, Run) {
11 TestWithScope setup;
12 Err err;
14 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/"));
15 Target target(setup.settings(), Label(SourceDir("//foo/"), "bar"));
17 target.set_output_type(Target::GROUP);
18 target.visibility().SetPublic();
20 Target dep(setup.settings(), Label(SourceDir("//foo/"), "dep"));
21 dep.set_output_type(Target::ACTION);
22 dep.visibility().SetPublic();
23 dep.SetToolchain(setup.toolchain());
24 ASSERT_TRUE(dep.OnResolved(&err));
26 Target dep2(setup.settings(), Label(SourceDir("//foo/"), "dep2"));
27 dep2.set_output_type(Target::ACTION);
28 dep2.visibility().SetPublic();
29 dep2.SetToolchain(setup.toolchain());
30 ASSERT_TRUE(dep2.OnResolved(&err));
32 Target datadep(setup.settings(), Label(SourceDir("//foo/"), "datadep"));
33 datadep.set_output_type(Target::ACTION);
34 datadep.visibility().SetPublic();
35 datadep.SetToolchain(setup.toolchain());
36 ASSERT_TRUE(datadep.OnResolved(&err));
38 target.public_deps().push_back(LabelTargetPair(&dep));
39 target.public_deps().push_back(LabelTargetPair(&dep2));
40 target.data_deps().push_back(LabelTargetPair(&datadep));
42 target.SetToolchain(setup.toolchain());
43 ASSERT_TRUE(target.OnResolved(&err));
45 std::ostringstream out;
46 NinjaGroupTargetWriter writer(&target, out);
47 writer.Run();
49 const char expected[] =
50 "build obj/foo/bar.stamp: stamp obj/foo/dep.stamp obj/foo/dep2.stamp || obj/foo/datadep.stamp\n";
51 EXPECT_EQ(expected, out.str());