Remove the now unused TextButton code.
[chromium-blink-merge.git] / tools / gn / ninja_copy_target_writer_unittest.cc
blob0b1618e15e58164ae750a90b7c80da3f0ca66ef9
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.
5 #include <algorithm>
6 #include <sstream>
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "tools/gn/file_template.h"
10 #include "tools/gn/ninja_copy_target_writer.h"
11 #include "tools/gn/test_with_scope.h"
13 // Tests mutliple files with an output pattern and no toolchain dependency.
14 TEST(NinjaCopyTargetWriter, Run) {
15 TestWithScope setup;
16 setup.settings()->set_target_os(Settings::LINUX);
17 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/"));
18 Target target(setup.settings(), Label(SourceDir("//foo/"), "bar"));
19 target.set_output_type(Target::COPY_FILES);
21 target.sources().push_back(SourceFile("//foo/input1.txt"));
22 target.sources().push_back(SourceFile("//foo/input2.txt"));
24 target.action_values().outputs().push_back(
25 SourceFile("//out/Debug/{{source_name_part}}.out"));
27 std::ostringstream out;
28 NinjaCopyTargetWriter writer(&target, setup.toolchain(), out);
29 writer.Run();
31 const char expected_linux[] =
32 "build input1.out: copy ../../foo/input1.txt\n"
33 "build input2.out: copy ../../foo/input2.txt\n"
34 "\n"
35 "build obj/foo/bar.stamp: stamp input1.out input2.out\n";
36 std::string out_str = out.str();
37 EXPECT_EQ(expected_linux, out_str);
40 // Tests a single file with no output pattern and a toolchain dependency.
41 TEST(NinjaCopyTargetWriter, ToolchainDeps) {
42 TestWithScope setup;
43 setup.settings()->set_target_os(Settings::LINUX);
44 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/"));
45 Target target(setup.settings(), Label(SourceDir("//foo/"), "bar"));
46 target.set_output_type(Target::COPY_FILES);
48 // Toolchain dependency. Here we make a target in the same toolchain for
49 // simplicity, but in real life (using the Builder) this would be rejected
50 // because it would be a circular dependency (the target depends on its
51 // toolchain, and the toolchain depends on this target).
52 Target toolchain_dep_target(setup.settings(),
53 Label(SourceDir("//foo/"), "setup"));
54 toolchain_dep_target.set_output_type(Target::ACTION);
55 setup.toolchain()->deps().push_back(LabelTargetPair(&toolchain_dep_target));
57 target.sources().push_back(SourceFile("//foo/input1.txt"));
59 target.action_values().outputs().push_back(
60 SourceFile("//out/Debug/output.out"));
62 std::ostringstream out;
63 NinjaCopyTargetWriter writer(&target, setup.toolchain(), out);
64 writer.Run();
66 const char expected_linux[] =
67 "build obj/foo/bar.inputdeps.stamp: stamp obj/foo/setup.stamp\n"
68 "build output.out: copy ../../foo/input1.txt | "
69 "obj/foo/bar.inputdeps.stamp\n"
70 "\n"
71 "build obj/foo/bar.stamp: stamp output.out\n";
72 std::string out_str = out.str();
73 EXPECT_EQ(expected_linux, out_str);