| 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 "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "tools/gn/ninja_action_target_writer.h" | 10 #include "tools/gn/ninja_action_target_writer.h" |
| 11 #include "tools/gn/pool.h" |
| 11 #include "tools/gn/substitution_list.h" | 12 #include "tools/gn/substitution_list.h" |
| 12 #include "tools/gn/target.h" | 13 #include "tools/gn/target.h" |
| 13 #include "tools/gn/test_with_scope.h" | 14 #include "tools/gn/test_with_scope.h" |
| 14 | 15 |
| 15 TEST(NinjaActionTargetWriter, WriteOutputFilesForBuildLine) { | 16 TEST(NinjaActionTargetWriter, WriteOutputFilesForBuildLine) { |
| 16 Err err; | 17 Err err; |
| 17 TestWithScope setup; | 18 TestWithScope setup; |
| 18 | 19 |
| 19 Target target(setup.settings(), Label(SourceDir("//foo/"), "bar")); | 20 Target target(setup.settings(), Label(SourceDir("//foo/"), "bar")); |
| 20 target.set_output_type(Target::ACTION_FOREACH); | 21 target.set_output_type(Target::ACTION_FOREACH); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 TestWithScope setup; | 81 TestWithScope setup; |
| 81 | 82 |
| 82 Target target(setup.settings(), Label(SourceDir("//foo/"), "bar")); | 83 Target target(setup.settings(), Label(SourceDir("//foo/"), "bar")); |
| 83 target.set_output_type(Target::ACTION); | 84 target.set_output_type(Target::ACTION); |
| 84 | 85 |
| 85 target.action_values().set_script(SourceFile("//foo/script.py")); | 86 target.action_values().set_script(SourceFile("//foo/script.py")); |
| 86 target.inputs().push_back(SourceFile("//foo/included.txt")); | 87 target.inputs().push_back(SourceFile("//foo/included.txt")); |
| 87 | 88 |
| 88 target.action_values().outputs() = | 89 target.action_values().outputs() = |
| 89 SubstitutionList::MakeForTest("//out/Debug/foo.out"); | 90 SubstitutionList::MakeForTest("//out/Debug/foo.out"); |
| 90 target.action_values().set_console(true); | 91 |
| 92 Pool pool(setup.settings(), Label(SourceDir("//foo/"), "pool")); |
| 93 pool.set_console(true); |
| 94 target.action_values().set_pool(LabelPtrPair<Pool>(&pool)); |
| 91 | 95 |
| 92 target.SetToolchain(setup.toolchain()); | 96 target.SetToolchain(setup.toolchain()); |
| 93 ASSERT_TRUE(target.OnResolved(&err)); | 97 ASSERT_TRUE(target.OnResolved(&err)); |
| 94 | 98 |
| 95 setup.build_settings()->set_python_path(base::FilePath(FILE_PATH_LITERAL( | 99 setup.build_settings()->set_python_path(base::FilePath(FILE_PATH_LITERAL( |
| 96 "/usr/bin/python"))); | 100 "/usr/bin/python"))); |
| 97 | 101 |
| 98 std::ostringstream out; | 102 std::ostringstream out; |
| 99 NinjaActionTargetWriter writer(&target, out); | 103 NinjaActionTargetWriter writer(&target, out); |
| 100 writer.Run(); | 104 writer.Run(); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 // Necessary for the rspfile defined in the rule. | 350 // Necessary for the rspfile defined in the rule. |
| 347 " unique_name = 0\n" | 351 " unique_name = 0\n" |
| 348 // Substitution for the args. | 352 // Substitution for the args. |
| 349 " source_file_part = input1.txt\n" | 353 " source_file_part = input1.txt\n" |
| 350 // Substitution for the rspfile contents. | 354 // Substitution for the rspfile contents. |
| 351 " source_name_part = input1\n" | 355 " source_name_part = input1\n" |
| 352 "\n" | 356 "\n" |
| 353 "build obj/foo/bar.stamp: stamp input1.out\n"; | 357 "build obj/foo/bar.stamp: stamp input1.out\n"; |
| 354 EXPECT_EQ(expected_linux, out.str()); | 358 EXPECT_EQ(expected_linux, out.str()); |
| 355 } | 359 } |
| OLD | NEW |