| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <sstream> | 5 #include <sstream> |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "tools/gn/ninja_build_writer.h" | 8 #include "tools/gn/ninja_build_writer.h" |
| 9 #include "tools/gn/pool.h" | 9 #include "tools/gn/pool.h" |
| 10 #include "tools/gn/scheduler.h" | 10 #include "tools/gn/scheduler.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 NinjaBuildWriter writer(setup.build_settings(), used_toolchains, | 60 NinjaBuildWriter writer(setup.build_settings(), used_toolchains, |
| 61 setup.toolchain(), targets, ninja_out, depfile_out); | 61 setup.toolchain(), targets, ninja_out, depfile_out); |
| 62 ASSERT_TRUE(writer.Run(&err)); | 62 ASSERT_TRUE(writer.Run(&err)); |
| 63 | 63 |
| 64 const char expected_rule_gn[] = "rule gn\n"; | 64 const char expected_rule_gn[] = "rule gn\n"; |
| 65 const char expected_build_ninja[] = | 65 const char expected_build_ninja[] = |
| 66 "build build.ninja: gn\n" | 66 "build build.ninja: gn\n" |
| 67 " generator = 1\n" | 67 " generator = 1\n" |
| 68 " depfile = build.ninja.d\n"; | 68 " depfile = build.ninja.d\n"; |
| 69 const char expected_link_pool[] = | |
| 70 "pool link_pool\n" | |
| 71 " depth = 0\n"; | |
| 72 const char expected_other_pool[] = | 69 const char expected_other_pool[] = |
| 73 "pool other_toolchain_other_pool\n" | 70 "pool other_toolchain_other_pool\n" |
| 74 " depth = 42\n"; | 71 " depth = 42\n"; |
| 75 const char expected_toolchain[] = | 72 const char expected_toolchain[] = |
| 76 "subninja toolchain.ninja\n"; | 73 "subninja toolchain.ninja\n"; |
| 77 const char expected_targets[] = | 74 const char expected_targets[] = |
| 78 "build bar: phony obj/bar/bar.stamp\n" | 75 "build bar: phony obj/bar/bar.stamp\n" |
| 79 "build foo$:bar: phony obj/foo/bar.stamp\n" | 76 "build foo$:bar: phony obj/foo/bar.stamp\n" |
| 80 "build bar$:bar: phony obj/bar/bar.stamp\n"; | 77 "build bar$:bar: phony obj/bar/bar.stamp\n"; |
| 81 const char expected_root_target[] = | 78 const char expected_root_target[] = |
| 82 "build all: phony $\n" | 79 "build all: phony $\n" |
| 83 " obj/foo/bar.stamp $\n" | 80 " obj/foo/bar.stamp $\n" |
| 84 " obj/bar/bar.stamp\n"; | 81 " obj/bar/bar.stamp\n"; |
| 85 const char expected_default[] = | 82 const char expected_default[] = |
| 86 "default all\n"; | 83 "default all\n"; |
| 87 std::string out_str = ninja_out.str(); | 84 std::string out_str = ninja_out.str(); |
| 88 #define EXPECT_SNIPPET(expected) \ | 85 #define EXPECT_SNIPPET(expected) \ |
| 89 EXPECT_NE(std::string::npos, out_str.find(expected)) << \ | 86 EXPECT_NE(std::string::npos, out_str.find(expected)) << \ |
| 90 "Expected to find: " << expected << std::endl << \ | 87 "Expected to find: " << expected << std::endl << \ |
| 91 "Within: " << out_str | 88 "Within: " << out_str |
| 92 EXPECT_SNIPPET(expected_rule_gn); | 89 EXPECT_SNIPPET(expected_rule_gn); |
| 93 EXPECT_SNIPPET(expected_build_ninja); | 90 EXPECT_SNIPPET(expected_build_ninja); |
| 94 EXPECT_SNIPPET(expected_link_pool); | |
| 95 EXPECT_SNIPPET(expected_other_pool); | 91 EXPECT_SNIPPET(expected_other_pool); |
| 96 EXPECT_SNIPPET(expected_toolchain); | 92 EXPECT_SNIPPET(expected_toolchain); |
| 97 EXPECT_SNIPPET(expected_targets); | 93 EXPECT_SNIPPET(expected_targets); |
| 98 EXPECT_SNIPPET(expected_root_target); | 94 EXPECT_SNIPPET(expected_root_target); |
| 99 EXPECT_SNIPPET(expected_default); | 95 EXPECT_SNIPPET(expected_default); |
| 100 #undef EXPECT_SNIPPET | 96 #undef EXPECT_SNIPPET |
| 101 } | 97 } |
| 102 | 98 |
| 103 TEST(NinjaBuildWriter, DuplicateOutputs) { | 99 TEST(NinjaBuildWriter, DuplicateOutputs) { |
| 104 Scheduler scheduler; | 100 Scheduler scheduler; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 "\n" | 132 "\n" |
| 137 "This is can often be fixed by changing one of the target names, or by \n" | 133 "This is can often be fixed by changing one of the target names, or by \n" |
| 138 "setting an output_name on one of them.\n" | 134 "setting an output_name on one of them.\n" |
| 139 "\n" | 135 "\n" |
| 140 "Collisions:\n" | 136 "Collisions:\n" |
| 141 " //foo:bar\n" | 137 " //foo:bar\n" |
| 142 " //bar:bar\n"; | 138 " //bar:bar\n"; |
| 143 | 139 |
| 144 EXPECT_EQ(expected_help_test, err.help_text()); | 140 EXPECT_EQ(expected_help_test, err.help_text()); |
| 145 } | 141 } |
| OLD | NEW |