| Index: tools/gn/ninja_copy_target_writer_unittest.cc
|
| diff --git a/tools/gn/ninja_copy_target_writer_unittest.cc b/tools/gn/ninja_copy_target_writer_unittest.cc
|
| index b86508b91dc57f9d95fa77085a7ff21dc2ec67cb..0b1618e15e58164ae750a90b7c80da3f0ca66ef9 100644
|
| --- a/tools/gn/ninja_copy_target_writer_unittest.cc
|
| +++ b/tools/gn/ninja_copy_target_writer_unittest.cc
|
| @@ -10,8 +10,10 @@
|
| #include "tools/gn/ninja_copy_target_writer.h"
|
| #include "tools/gn/test_with_scope.h"
|
|
|
| +// Tests mutliple files with an output pattern and no toolchain dependency.
|
| TEST(NinjaCopyTargetWriter, Run) {
|
| TestWithScope setup;
|
| + setup.settings()->set_target_os(Settings::LINUX);
|
| setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/"));
|
| Target target(setup.settings(), Label(SourceDir("//foo/"), "bar"));
|
| target.set_output_type(Target::COPY_FILES);
|
| @@ -22,45 +24,51 @@ TEST(NinjaCopyTargetWriter, Run) {
|
| target.action_values().outputs().push_back(
|
| SourceFile("//out/Debug/{{source_name_part}}.out"));
|
|
|
| - // Posix.
|
| - {
|
| - setup.settings()->set_target_os(Settings::LINUX);
|
| + std::ostringstream out;
|
| + NinjaCopyTargetWriter writer(&target, setup.toolchain(), out);
|
| + writer.Run();
|
|
|
| - std::ostringstream out;
|
| - NinjaCopyTargetWriter writer(&target, setup.toolchain(), out);
|
| - writer.Run();
|
| + const char expected_linux[] =
|
| + "build input1.out: copy ../../foo/input1.txt\n"
|
| + "build input2.out: copy ../../foo/input2.txt\n"
|
| + "\n"
|
| + "build obj/foo/bar.stamp: stamp input1.out input2.out\n";
|
| + std::string out_str = out.str();
|
| + EXPECT_EQ(expected_linux, out_str);
|
| +}
|
|
|
| - const char expected_linux[] =
|
| - "build input1.out: copy ../../foo/input1.txt\n"
|
| - "build input2.out: copy ../../foo/input2.txt\n"
|
| - "\n"
|
| - "build obj/foo/bar.stamp: stamp input1.out input2.out\n";
|
| - std::string out_str = out.str();
|
| -#if defined(OS_WIN)
|
| - std::replace(out_str.begin(), out_str.end(), '\\', '/');
|
| -#endif
|
| - EXPECT_EQ(expected_linux, out_str);
|
| - }
|
| +// Tests a single file with no output pattern and a toolchain dependency.
|
| +TEST(NinjaCopyTargetWriter, ToolchainDeps) {
|
| + TestWithScope setup;
|
| + setup.settings()->set_target_os(Settings::LINUX);
|
| + setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/"));
|
| + Target target(setup.settings(), Label(SourceDir("//foo/"), "bar"));
|
| + target.set_output_type(Target::COPY_FILES);
|
|
|
| - // Windows.
|
| - {
|
| - setup.settings()->set_target_os(Settings::WIN);
|
| + // Toolchain dependency. Here we make a target in the same toolchain for
|
| + // simplicity, but in real life (using the Builder) this would be rejected
|
| + // because it would be a circular dependency (the target depends on its
|
| + // toolchain, and the toolchain depends on this target).
|
| + Target toolchain_dep_target(setup.settings(),
|
| + Label(SourceDir("//foo/"), "setup"));
|
| + toolchain_dep_target.set_output_type(Target::ACTION);
|
| + setup.toolchain()->deps().push_back(LabelTargetPair(&toolchain_dep_target));
|
| +
|
| + target.sources().push_back(SourceFile("//foo/input1.txt"));
|
| +
|
| + target.action_values().outputs().push_back(
|
| + SourceFile("//out/Debug/output.out"));
|
|
|
| - std::ostringstream out;
|
| - NinjaCopyTargetWriter writer(&target, setup.toolchain(), out);
|
| - writer.Run();
|
| + std::ostringstream out;
|
| + NinjaCopyTargetWriter writer(&target, setup.toolchain(), out);
|
| + writer.Run();
|
|
|
| - // TODO(brettw) I think we'll need to worry about backslashes here
|
| - // depending if we're on actual Windows or Linux pretending to be Windows.
|
| - const char expected_win[] =
|
| - "build input1.out: copy ../../foo/input1.txt\n"
|
| - "build input2.out: copy ../../foo/input2.txt\n"
|
| - "\n"
|
| - "build obj/foo/bar.stamp: stamp input1.out input2.out\n";
|
| - std::string out_str = out.str();
|
| -#if defined(OS_WIN)
|
| - std::replace(out_str.begin(), out_str.end(), '\\', '/');
|
| -#endif
|
| - EXPECT_EQ(expected_win, out_str);
|
| - }
|
| + const char expected_linux[] =
|
| + "build obj/foo/bar.inputdeps.stamp: stamp obj/foo/setup.stamp\n"
|
| + "build output.out: copy ../../foo/input1.txt | "
|
| + "obj/foo/bar.inputdeps.stamp\n"
|
| + "\n"
|
| + "build obj/foo/bar.stamp: stamp output.out\n";
|
| + std::string out_str = out.str();
|
| + EXPECT_EQ(expected_linux, out_str);
|
| }
|
|
|