| 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/target.h" | 9 #include "tools/gn/target.h" |
| 10 #include "tools/gn/test_with_scope.h" | 10 #include "tools/gn/test_with_scope.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 ASSERT_TRUE(target.OnResolved(&err)); | 65 ASSERT_TRUE(target.OnResolved(&err)); |
| 66 ASSERT_TRUE(action.OnResolved(&err)); | 66 ASSERT_TRUE(action.OnResolved(&err)); |
| 67 | 67 |
| 68 // Input deps for the base (should be only the script itself). | 68 // Input deps for the base (should be only the script itself). |
| 69 { | 69 { |
| 70 std::ostringstream stream; | 70 std::ostringstream stream; |
| 71 TestingNinjaTargetWriter writer(&base_target, setup.toolchain(), stream); | 71 TestingNinjaTargetWriter writer(&base_target, setup.toolchain(), stream); |
| 72 OutputFile dep = | 72 OutputFile dep = |
| 73 writer.WriteInputDepsStampAndGetDep(std::vector<const Target*>()); | 73 writer.WriteInputDepsStampAndGetDep(std::vector<const Target*>()); |
| 74 | 74 |
| 75 EXPECT_EQ("obj/foo/base.inputdeps.stamp", dep.value()); | 75 // Since there is only one dependency, it should just be returned and |
| 76 EXPECT_EQ("build obj/foo/base.inputdeps.stamp: stamp " | 76 // nothing written to the stream. |
| 77 "../../foo/script.py\n", | 77 EXPECT_EQ("../../foo/script.py", dep.value()); |
| 78 stream.str()); | 78 EXPECT_EQ("", stream.str()); |
| 79 } | 79 } |
| 80 | 80 |
| 81 // Input deps for the target (should depend on the base). | 81 // Input deps for the target (should depend on the base). |
| 82 { | 82 { |
| 83 std::ostringstream stream; | 83 std::ostringstream stream; |
| 84 TestingNinjaTargetWriter writer(&target, setup.toolchain(), stream); | 84 TestingNinjaTargetWriter writer(&target, setup.toolchain(), stream); |
| 85 OutputFile dep = | 85 OutputFile dep = |
| 86 writer.WriteInputDepsStampAndGetDep(std::vector<const Target*>()); | 86 writer.WriteInputDepsStampAndGetDep(std::vector<const Target*>()); |
| 87 | 87 |
| 88 // Since there is more than one dependency, a stamp file will be returned |
| 89 // and the rule for the stamp file will be written to the stream. |
| 88 EXPECT_EQ("obj/foo/target.inputdeps.stamp", dep.value()); | 90 EXPECT_EQ("obj/foo/target.inputdeps.stamp", dep.value()); |
| 89 EXPECT_EQ("build obj/foo/target.inputdeps.stamp: stamp " | 91 EXPECT_EQ("build obj/foo/target.inputdeps.stamp: stamp " |
| 90 "../../foo/input.txt obj/foo/base.stamp\n", | 92 "../../foo/input.txt obj/foo/base.stamp\n", |
| 91 stream.str()); | 93 stream.str()); |
| 92 } | 94 } |
| 93 | 95 |
| 94 // Input deps for action which should depend on the base since its a hard dep | 96 // Input deps for action which should depend on the base since its a hard dep |
| 95 // that is a (indirect) dependency, as well as the the action source. | 97 // that is a (indirect) dependency, as well as the the action source. |
| 96 { | 98 { |
| 97 std::ostringstream stream; | 99 std::ostringstream stream; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 126 Target target(setup.settings(), Label(SourceDir("//foo/"), "target")); | 128 Target target(setup.settings(), Label(SourceDir("//foo/"), "target")); |
| 127 target.set_output_type(Target::EXECUTABLE); | 129 target.set_output_type(Target::EXECUTABLE); |
| 128 target.SetToolchain(setup.toolchain()); | 130 target.SetToolchain(setup.toolchain()); |
| 129 ASSERT_TRUE(target.OnResolved(&err)); | 131 ASSERT_TRUE(target.OnResolved(&err)); |
| 130 | 132 |
| 131 std::ostringstream stream; | 133 std::ostringstream stream; |
| 132 TestingNinjaTargetWriter writer(&target, setup.toolchain(), stream); | 134 TestingNinjaTargetWriter writer(&target, setup.toolchain(), stream); |
| 133 OutputFile dep = | 135 OutputFile dep = |
| 134 writer.WriteInputDepsStampAndGetDep(std::vector<const Target*>()); | 136 writer.WriteInputDepsStampAndGetDep(std::vector<const Target*>()); |
| 135 | 137 |
| 136 EXPECT_EQ("obj/foo/target.inputdeps.stamp", dep.value()); | 138 // Since there is more than one dependency, a stamp file will be returned |
| 137 EXPECT_EQ("build obj/foo/target.inputdeps.stamp: stamp " | 139 // and the rule for the stamp file will be written to the stream. |
| 138 "obj/foo/setup.stamp\n", | 140 EXPECT_EQ("obj/foo/setup.stamp", dep.value()); |
| 139 stream.str()); | 141 EXPECT_EQ("", stream.str()); |
| 140 } | 142 } |
| OLD | NEW |