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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 } | 51 } |
52 | 52 |
53 protected: | 53 protected: |
54 TestWithScope setup_; | 54 TestWithScope setup_; |
55 | 55 |
56 Scope::ItemVector items_; | 56 Scope::ItemVector items_; |
57 }; | 57 }; |
58 | 58 |
59 } // namespace | 59 } // namespace |
60 | 60 |
61 TEST_F(GetTargetOutputsTest, Executable) { | |
62 Target* exe = new Target(setup_.settings(), GetLabel("//foo/", "bar")); | |
63 exe->set_output_type(Target::EXECUTABLE); | |
64 items_.push_back(new scoped_ptr<Item>(exe)); | |
65 | |
66 Err err; | |
67 Value result = GetTargetOutputs("//foo:bar", &err); | |
68 ASSERT_FALSE(err.has_error()); | |
69 // The TestWithScope declares that the build is Linux, so we'll have no | |
70 // extension for the binaries. | |
71 AssertSingleStringEquals(result, "//out/Debug/bar"); | |
72 } | |
73 | |
74 TEST_F(GetTargetOutputsTest, SourceSet) { | |
75 Target* source_set = new Target(setup_.settings(), GetLabel("//foo/", "bar")); | |
76 source_set->set_output_type(Target::SOURCE_SET); | |
77 items_.push_back(new scoped_ptr<Item>(source_set)); | |
78 | |
79 Err err; | |
80 Value result = GetTargetOutputs("//foo:bar", &err); | |
81 ASSERT_FALSE(err.has_error()); | |
82 AssertSingleStringEquals(result, "//out/Debug/obj/foo/bar.stamp"); | |
83 } | |
84 | |
85 TEST_F(GetTargetOutputsTest, Copy) { | 61 TEST_F(GetTargetOutputsTest, Copy) { |
86 Target* action = new Target(setup_.settings(), GetLabel("//foo/", "bar")); | 62 Target* action = new Target(setup_.settings(), GetLabel("//foo/", "bar")); |
87 action->set_output_type(Target::COPY_FILES); | 63 action->set_output_type(Target::COPY_FILES); |
88 action->sources().push_back(SourceFile("//file.txt")); | 64 action->sources().push_back(SourceFile("//file.txt")); |
89 action->action_values().outputs() = | 65 action->action_values().outputs() = |
90 SubstitutionList::MakeForTest("//out/Debug/{{source_file_part}}.one"); | 66 SubstitutionList::MakeForTest("//out/Debug/{{source_file_part}}.one"); |
91 | 67 |
92 items_.push_back(new scoped_ptr<Item>(action)); | 68 items_.push_back(new scoped_ptr<Item>(action)); |
93 | 69 |
94 Err err; | 70 Err err; |
(...skipping 26 matching lines...) Expand all Loading... |
121 "//out/Debug/{{source_file_part}}.two"); | 97 "//out/Debug/{{source_file_part}}.two"); |
122 | 98 |
123 items_.push_back(new scoped_ptr<Item>(action)); | 99 items_.push_back(new scoped_ptr<Item>(action)); |
124 | 100 |
125 Err err; | 101 Err err; |
126 Value result = GetTargetOutputs("//foo:bar", &err); | 102 Value result = GetTargetOutputs("//foo:bar", &err); |
127 ASSERT_FALSE(err.has_error()); | 103 ASSERT_FALSE(err.has_error()); |
128 AssertTwoStringsEqual(result, "//out/Debug/file.txt.one", | 104 AssertTwoStringsEqual(result, "//out/Debug/file.txt.one", |
129 "//out/Debug/file.txt.two"); | 105 "//out/Debug/file.txt.two"); |
130 } | 106 } |
OLD | NEW |