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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 protected: | 51 protected: |
52 TestWithScope setup_; | 52 TestWithScope setup_; |
53 | 53 |
54 Scope::ItemVector items_; | 54 Scope::ItemVector items_; |
55 }; | 55 }; |
56 | 56 |
57 } // namespace | 57 } // namespace |
58 | 58 |
59 TEST_F(GetTargetOutputsTest, Copy) { | 59 TEST_F(GetTargetOutputsTest, Copy) { |
60 Target* action = new Target(setup_.settings(), GetLabel("//foo/", "bar")); | 60 Target* action = new Target(setup_.settings(), GetLabel("//foo/", "bar"), {}); |
61 action->set_output_type(Target::COPY_FILES); | 61 action->set_output_type(Target::COPY_FILES); |
62 action->sources().push_back(SourceFile("//file.txt")); | 62 action->sources().push_back(SourceFile("//file.txt")); |
63 action->action_values().outputs() = | 63 action->action_values().outputs() = |
64 SubstitutionList::MakeForTest("//out/Debug/{{source_file_part}}.one"); | 64 SubstitutionList::MakeForTest("//out/Debug/{{source_file_part}}.one"); |
65 | 65 |
66 items_.push_back(action); | 66 items_.push_back(action); |
67 | 67 |
68 Err err; | 68 Err err; |
69 Value result = GetTargetOutputs("//foo:bar", &err); | 69 Value result = GetTargetOutputs("//foo:bar", &err); |
70 ASSERT_FALSE(err.has_error()); | 70 ASSERT_FALSE(err.has_error()); |
71 AssertSingleStringEquals(result, "//out/Debug/file.txt.one"); | 71 AssertSingleStringEquals(result, "//out/Debug/file.txt.one"); |
72 } | 72 } |
73 | 73 |
74 TEST_F(GetTargetOutputsTest, Action) { | 74 TEST_F(GetTargetOutputsTest, Action) { |
75 Target* action = new Target(setup_.settings(), GetLabel("//foo/", "bar")); | 75 Target* action = new Target(setup_.settings(), GetLabel("//foo/", "bar"), {}); |
76 action->set_output_type(Target::ACTION); | 76 action->set_output_type(Target::ACTION); |
77 action->action_values().outputs() = SubstitutionList::MakeForTest( | 77 action->action_values().outputs() = SubstitutionList::MakeForTest( |
78 "//output1.txt", | 78 "//output1.txt", |
79 "//output2.txt"); | 79 "//output2.txt"); |
80 | 80 |
81 items_.push_back(action); | 81 items_.push_back(action); |
82 | 82 |
83 Err err; | 83 Err err; |
84 Value result = GetTargetOutputs("//foo:bar", &err); | 84 Value result = GetTargetOutputs("//foo:bar", &err); |
85 ASSERT_FALSE(err.has_error()); | 85 ASSERT_FALSE(err.has_error()); |
86 AssertTwoStringsEqual(result, "//output1.txt", "//output2.txt"); | 86 AssertTwoStringsEqual(result, "//output1.txt", "//output2.txt"); |
87 } | 87 } |
88 | 88 |
89 TEST_F(GetTargetOutputsTest, ActionForeach) { | 89 TEST_F(GetTargetOutputsTest, ActionForeach) { |
90 Target* action = new Target(setup_.settings(), GetLabel("//foo/", "bar")); | 90 Target* action = new Target(setup_.settings(), GetLabel("//foo/", "bar"), {}); |
91 action->set_output_type(Target::ACTION_FOREACH); | 91 action->set_output_type(Target::ACTION_FOREACH); |
92 action->sources().push_back(SourceFile("//file.txt")); | 92 action->sources().push_back(SourceFile("//file.txt")); |
93 action->action_values().outputs() = SubstitutionList::MakeForTest( | 93 action->action_values().outputs() = SubstitutionList::MakeForTest( |
94 "//out/Debug/{{source_file_part}}.one", | 94 "//out/Debug/{{source_file_part}}.one", |
95 "//out/Debug/{{source_file_part}}.two"); | 95 "//out/Debug/{{source_file_part}}.two"); |
96 | 96 |
97 items_.push_back(action); | 97 items_.push_back(action); |
98 | 98 |
99 Err err; | 99 Err err; |
100 Value result = GetTargetOutputs("//foo:bar", &err); | 100 Value result = GetTargetOutputs("//foo:bar", &err); |
101 ASSERT_FALSE(err.has_error()); | 101 ASSERT_FALSE(err.has_error()); |
102 AssertTwoStringsEqual(result, "//out/Debug/file.txt.one", | 102 AssertTwoStringsEqual(result, "//out/Debug/file.txt.one", |
103 "//out/Debug/file.txt.two"); | 103 "//out/Debug/file.txt.two"); |
104 } | 104 } |
OLD | NEW |