OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_target_writer.h" | 8 #include "tools/gn/ninja_target_writer.h" |
9 #include "tools/gn/test_with_scope.h" | 9 #include "tools/gn/test_with_scope.h" |
10 | 10 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 TestingNinjaTargetWriter writer(&action, setup.toolchain(), stream); | 90 TestingNinjaTargetWriter writer(&action, setup.toolchain(), stream); |
91 std::string dep = | 91 std::string dep = |
92 writer.WriteInputDepsStampAndGetDep(std::vector<const Target*>()); | 92 writer.WriteInputDepsStampAndGetDep(std::vector<const Target*>()); |
93 | 93 |
94 EXPECT_EQ(" | obj/foo/action.inputdeps.stamp", dep); | 94 EXPECT_EQ(" | obj/foo/action.inputdeps.stamp", dep); |
95 EXPECT_EQ("build obj/foo/action.inputdeps.stamp: stamp ../../foo/script.py " | 95 EXPECT_EQ("build obj/foo/action.inputdeps.stamp: stamp ../../foo/script.py " |
96 "../../foo/action_source.txt obj/foo/base.stamp\n", | 96 "../../foo/action_source.txt obj/foo/base.stamp\n", |
97 stream.str()); | 97 stream.str()); |
98 } | 98 } |
99 } | 99 } |
| 100 |
| 101 // Tests WriteInputDepsStampAndGetDep when toolchain deps are present. |
| 102 TEST(NinjaTargetWriter, WriteInputDepsStampAndGetDepWithToolchainDeps) { |
| 103 TestWithScope setup; |
| 104 |
| 105 // Toolchain dependency. Here we make a target in the same toolchain for |
| 106 // simplicity, but in real life (using the Builder) this would be rejected |
| 107 // because it would be a circular dependency (the target depends on its |
| 108 // toolchain, and the toolchain depends on this target). |
| 109 Target toolchain_dep_target(setup.settings(), |
| 110 Label(SourceDir("//foo/"), "setup")); |
| 111 toolchain_dep_target.set_output_type(Target::ACTION); |
| 112 setup.toolchain()->deps().push_back(LabelTargetPair(&toolchain_dep_target)); |
| 113 |
| 114 // Make a binary target |
| 115 Target target(setup.settings(), Label(SourceDir("//foo/"), "target")); |
| 116 target.set_output_type(Target::EXECUTABLE); |
| 117 |
| 118 std::ostringstream stream; |
| 119 TestingNinjaTargetWriter writer(&target, setup.toolchain(), stream); |
| 120 std::string dep = |
| 121 writer.WriteInputDepsStampAndGetDep(std::vector<const Target*>()); |
| 122 |
| 123 EXPECT_EQ(" | obj/foo/target.inputdeps.stamp", dep); |
| 124 EXPECT_EQ("build obj/foo/target.inputdeps.stamp: stamp " |
| 125 "obj/foo/setup.stamp\n", |
| 126 stream.str()); |
| 127 } |
OLD | NEW |