OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 <algorithm> | 5 #include <algorithm> |
6 #include <sstream> | 6 #include <sstream> |
7 | 7 |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "tools/gn/ninja_copy_target_writer.h" | 9 #include "tools/gn/ninja_copy_target_writer.h" |
10 #include "tools/gn/target.h" | 10 #include "tools/gn/target.h" |
11 #include "tools/gn/test_with_scope.h" | 11 #include "tools/gn/test_with_scope.h" |
12 | 12 |
13 // Tests mutliple files with an output pattern and no toolchain dependency. | 13 // Tests multiple files with an output pattern and no toolchain dependency. |
14 TEST(NinjaCopyTargetWriter, Run) { | 14 TEST(NinjaCopyTargetWriter, Run) { |
15 TestWithScope setup; | 15 TestWithScope setup; |
16 Err err; | 16 Err err; |
17 | 17 |
18 setup.settings()->set_target_os(Settings::LINUX); | 18 setup.settings()->set_target_os(Settings::LINUX); |
19 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/")); | 19 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/")); |
20 Target target(setup.settings(), Label(SourceDir("//foo/"), "bar")); | 20 Target target(setup.settings(), Label(SourceDir("//foo/"), "bar")); |
21 target.set_output_type(Target::COPY_FILES); | 21 target.set_output_type(Target::COPY_FILES); |
22 | 22 |
23 target.sources().push_back(SourceFile("//foo/input1.txt")); | 23 target.sources().push_back(SourceFile("//foo/input1.txt")); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 NinjaCopyTargetWriter writer(&target, out); | 64 NinjaCopyTargetWriter writer(&target, out); |
65 writer.Run(); | 65 writer.Run(); |
66 | 66 |
67 const char expected_linux[] = | 67 const char expected_linux[] = |
68 "build output.out: copy ../../foo/input1.txt\n" | 68 "build output.out: copy ../../foo/input1.txt\n" |
69 "\n" | 69 "\n" |
70 "build obj/foo/bar.stamp: stamp output.out\n"; | 70 "build obj/foo/bar.stamp: stamp output.out\n"; |
71 std::string out_str = out.str(); | 71 std::string out_str = out.str(); |
72 EXPECT_EQ(expected_linux, out_str); | 72 EXPECT_EQ(expected_linux, out_str); |
73 } | 73 } |
| 74 |
| 75 TEST(NinjaCopyTargetWriter, OrderOnlyDeps) { |
| 76 TestWithScope setup; |
| 77 Err err; |
| 78 |
| 79 setup.settings()->set_target_os(Settings::LINUX); |
| 80 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/")); |
| 81 |
| 82 Target target(setup.settings(), Label(SourceDir("//foo/"), "bar")); |
| 83 target.set_output_type(Target::COPY_FILES); |
| 84 target.sources().push_back(SourceFile("//foo/input1.txt")); |
| 85 target.action_values().outputs() = |
| 86 SubstitutionList::MakeForTest("//out/Debug/{{source_name_part}}.out"); |
| 87 target.inputs().push_back(SourceFile("//foo/script.py")); |
| 88 target.SetToolchain(setup.toolchain()); |
| 89 ASSERT_TRUE(target.OnResolved(&err)); |
| 90 |
| 91 std::ostringstream out; |
| 92 NinjaCopyTargetWriter writer(&target, out); |
| 93 writer.Run(); |
| 94 |
| 95 const char expected_linux[] = |
| 96 "build obj/foo/bar.inputdeps.stamp: stamp ../../foo/script.py\n" |
| 97 "build input1.out: copy ../../foo/input1.txt || " |
| 98 "obj/foo/bar.inputdeps.stamp\n" |
| 99 "\n" |
| 100 "build obj/foo/bar.stamp: stamp input1.out\n"; |
| 101 std::string out_str = out.str(); |
| 102 EXPECT_EQ(expected_linux, out_str); |
| 103 } |
OLD | NEW |