| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 Target* source_set = new Target(setup_.settings(), GetLabel("//foo/", "bar")); | 75 Target* source_set = new Target(setup_.settings(), GetLabel("//foo/", "bar")); |
| 76 source_set->set_output_type(Target::SOURCE_SET); | 76 source_set->set_output_type(Target::SOURCE_SET); |
| 77 items_.push_back(new scoped_ptr<Item>(source_set)); | 77 items_.push_back(new scoped_ptr<Item>(source_set)); |
| 78 | 78 |
| 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) { |
| 86 Target* action = new Target(setup_.settings(), GetLabel("//foo/", "bar")); |
| 87 action->set_output_type(Target::COPY_FILES); |
| 88 action->sources().push_back(SourceFile("//file.txt")); |
| 89 action->action_values().outputs().push_back( |
| 90 "//out/Debug/{{source_file_part}}.one"); |
| 91 |
| 92 items_.push_back(new scoped_ptr<Item>(action)); |
| 93 |
| 94 Err err; |
| 95 Value result = GetTargetOutputs("//foo:bar", &err); |
| 96 ASSERT_FALSE(err.has_error()); |
| 97 AssertSingleStringEquals(result, "//out/Debug/file.txt.one"); |
| 98 } |
| 99 |
| 85 TEST_F(GetTargetOutputsTest, Action) { | 100 TEST_F(GetTargetOutputsTest, Action) { |
| 86 Target* action = new Target(setup_.settings(), GetLabel("//foo/", "bar")); | 101 Target* action = new Target(setup_.settings(), GetLabel("//foo/", "bar")); |
| 87 action->set_output_type(Target::ACTION); | 102 action->set_output_type(Target::ACTION); |
| 88 action->action_values().outputs().push_back(SourceFile("//output1.txt")); | 103 action->action_values().outputs().push_back("//output1.txt"); |
| 89 action->action_values().outputs().push_back(SourceFile("//output2.txt")); | 104 action->action_values().outputs().push_back("//output2.txt"); |
| 90 | 105 |
| 91 items_.push_back(new scoped_ptr<Item>(action)); | 106 items_.push_back(new scoped_ptr<Item>(action)); |
| 92 | 107 |
| 93 Err err; | 108 Err err; |
| 94 Value result = GetTargetOutputs("//foo:bar", &err); | 109 Value result = GetTargetOutputs("//foo:bar", &err); |
| 95 ASSERT_FALSE(err.has_error()); | 110 ASSERT_FALSE(err.has_error()); |
| 96 AssertTwoStringsEqual(result, "//output1.txt", "//output2.txt"); | 111 AssertTwoStringsEqual(result, "//output1.txt", "//output2.txt"); |
| 97 } | 112 } |
| 98 | 113 |
| 99 TEST_F(GetTargetOutputsTest, ActionForeach) { | 114 TEST_F(GetTargetOutputsTest, ActionForeach) { |
| 100 Target* action = new Target(setup_.settings(), GetLabel("//foo/", "bar")); | 115 Target* action = new Target(setup_.settings(), GetLabel("//foo/", "bar")); |
| 101 action->set_output_type(Target::ACTION_FOREACH); | 116 action->set_output_type(Target::ACTION_FOREACH); |
| 102 action->sources().push_back(SourceFile("//file.txt")); | 117 action->sources().push_back(SourceFile("//file.txt")); |
| 103 action->action_values().outputs().push_back( | 118 action->action_values().outputs().push_back( |
| 104 SourceFile("//out/Debug/{{source_file_part}}.one")); | 119 "//out/Debug/{{source_file_part}}.one"); |
| 105 action->action_values().outputs().push_back( | 120 action->action_values().outputs().push_back( |
| 106 SourceFile("//out/Debug/{{source_file_part}}.two")); | 121 "//out/Debug/{{source_file_part}}.two"); |
| 107 | 122 |
| 108 items_.push_back(new scoped_ptr<Item>(action)); | 123 items_.push_back(new scoped_ptr<Item>(action)); |
| 109 | 124 |
| 110 Err err; | 125 Err err; |
| 111 Value result = GetTargetOutputs("//foo:bar", &err); | 126 Value result = GetTargetOutputs("//foo:bar", &err); |
| 112 ASSERT_FALSE(err.has_error()); | 127 ASSERT_FALSE(err.has_error()); |
| 113 AssertTwoStringsEqual(result, "//out/Debug/file.txt.one", | 128 AssertTwoStringsEqual(result, "//out/Debug/file.txt.one", |
| 114 "//out/Debug/file.txt.two"); | 129 "//out/Debug/file.txt.two"); |
| 115 } | 130 } |
| OLD | NEW |