| 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 #include "tools/gn/functions.h" | 6 #include "tools/gn/functions.h" |
| 7 #include "tools/gn/target.h" | 7 #include "tools/gn/target.h" |
| 8 #include "tools/gn/test_with_scope.h" | 8 #include "tools/gn/test_with_scope.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 Err err; | 79 Err err; |
| 80 Value result = GetTargetOutputs("//foo:bar", &err); | 80 Value result = GetTargetOutputs("//foo:bar", &err); |
| 81 ASSERT_FALSE(err.has_error()); | 81 ASSERT_FALSE(err.has_error()); |
| 82 AssertSingleStringEquals(result, "//out/Debug/obj/foo/bar.stamp"); | 82 AssertSingleStringEquals(result, "//out/Debug/obj/foo/bar.stamp"); |
| 83 } | 83 } |
| 84 | 84 |
| 85 TEST_F(GetTargetOutputsTest, Copy) { | 85 TEST_F(GetTargetOutputsTest, Copy) { |
| 86 Target* action = new Target(setup_.settings(), GetLabel("//foo/", "bar")); | 86 Target* action = new Target(setup_.settings(), GetLabel("//foo/", "bar")); |
| 87 action->set_output_type(Target::COPY_FILES); | 87 action->set_output_type(Target::COPY_FILES); |
| 88 action->sources().push_back(SourceFile("//file.txt")); | 88 action->sources().push_back(SourceFile("//file.txt")); |
| 89 action->action_values().outputs().push_back( | 89 action->action_values().outputs() = |
| 90 "//out/Debug/{{source_file_part}}.one"); | 90 SubstitutionList::MakeForTest("//out/Debug/{{source_file_part}}.one"); |
| 91 | 91 |
| 92 items_.push_back(new scoped_ptr<Item>(action)); | 92 items_.push_back(new scoped_ptr<Item>(action)); |
| 93 | 93 |
| 94 Err err; | 94 Err err; |
| 95 Value result = GetTargetOutputs("//foo:bar", &err); | 95 Value result = GetTargetOutputs("//foo:bar", &err); |
| 96 ASSERT_FALSE(err.has_error()); | 96 ASSERT_FALSE(err.has_error()); |
| 97 AssertSingleStringEquals(result, "//out/Debug/file.txt.one"); | 97 AssertSingleStringEquals(result, "//out/Debug/file.txt.one"); |
| 98 } | 98 } |
| 99 | 99 |
| 100 TEST_F(GetTargetOutputsTest, Action) { | 100 TEST_F(GetTargetOutputsTest, Action) { |
| 101 Target* action = new Target(setup_.settings(), GetLabel("//foo/", "bar")); | 101 Target* action = new Target(setup_.settings(), GetLabel("//foo/", "bar")); |
| 102 action->set_output_type(Target::ACTION); | 102 action->set_output_type(Target::ACTION); |
| 103 action->action_values().outputs().push_back("//output1.txt"); | 103 action->action_values().outputs() = SubstitutionList::MakeForTest( |
| 104 action->action_values().outputs().push_back("//output2.txt"); | 104 "//output1.txt", |
| 105 "//output2.txt"); |
| 105 | 106 |
| 106 items_.push_back(new scoped_ptr<Item>(action)); | 107 items_.push_back(new scoped_ptr<Item>(action)); |
| 107 | 108 |
| 108 Err err; | 109 Err err; |
| 109 Value result = GetTargetOutputs("//foo:bar", &err); | 110 Value result = GetTargetOutputs("//foo:bar", &err); |
| 110 ASSERT_FALSE(err.has_error()); | 111 ASSERT_FALSE(err.has_error()); |
| 111 AssertTwoStringsEqual(result, "//output1.txt", "//output2.txt"); | 112 AssertTwoStringsEqual(result, "//output1.txt", "//output2.txt"); |
| 112 } | 113 } |
| 113 | 114 |
| 114 TEST_F(GetTargetOutputsTest, ActionForeach) { | 115 TEST_F(GetTargetOutputsTest, ActionForeach) { |
| 115 Target* action = new Target(setup_.settings(), GetLabel("//foo/", "bar")); | 116 Target* action = new Target(setup_.settings(), GetLabel("//foo/", "bar")); |
| 116 action->set_output_type(Target::ACTION_FOREACH); | 117 action->set_output_type(Target::ACTION_FOREACH); |
| 117 action->sources().push_back(SourceFile("//file.txt")); | 118 action->sources().push_back(SourceFile("//file.txt")); |
| 118 action->action_values().outputs().push_back( | 119 action->action_values().outputs() = SubstitutionList::MakeForTest( |
| 119 "//out/Debug/{{source_file_part}}.one"); | 120 "//out/Debug/{{source_file_part}}.one", |
| 120 action->action_values().outputs().push_back( | |
| 121 "//out/Debug/{{source_file_part}}.two"); | 121 "//out/Debug/{{source_file_part}}.two"); |
| 122 | 122 |
| 123 items_.push_back(new scoped_ptr<Item>(action)); | 123 items_.push_back(new scoped_ptr<Item>(action)); |
| 124 | 124 |
| 125 Err err; | 125 Err err; |
| 126 Value result = GetTargetOutputs("//foo:bar", &err); | 126 Value result = GetTargetOutputs("//foo:bar", &err); |
| 127 ASSERT_FALSE(err.has_error()); | 127 ASSERT_FALSE(err.has_error()); |
| 128 AssertTwoStringsEqual(result, "//out/Debug/file.txt.one", | 128 AssertTwoStringsEqual(result, "//out/Debug/file.txt.one", |
| 129 "//out/Debug/file.txt.two"); | 129 "//out/Debug/file.txt.two"); |
| 130 } | 130 } |
| OLD | NEW |