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 <sstream> | 5 #include <sstream> |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "tools/gn/err.h" | 8 #include "tools/gn/err.h" |
9 #include "tools/gn/escape.h" | 9 #include "tools/gn/escape.h" |
10 #include "tools/gn/substitution_list.h" | 10 #include "tools/gn/substitution_list.h" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 target.set_output_type(Target::STATIC_LIBRARY); | 186 target.set_output_type(Target::STATIC_LIBRARY); |
187 target.SetToolchain(setup.toolchain()); | 187 target.SetToolchain(setup.toolchain()); |
188 ASSERT_TRUE(target.OnResolved(&err)); | 188 ASSERT_TRUE(target.OnResolved(&err)); |
189 | 189 |
190 std::string result; | 190 std::string result; |
191 EXPECT_TRUE(SubstitutionWriter::GetTargetSubstitution( | 191 EXPECT_TRUE(SubstitutionWriter::GetTargetSubstitution( |
192 &target, SUBSTITUTION_LABEL, &result)); | 192 &target, SUBSTITUTION_LABEL, &result)); |
193 EXPECT_EQ("//foo/bar:baz", result); | 193 EXPECT_EQ("//foo/bar:baz", result); |
194 | 194 |
195 EXPECT_TRUE(SubstitutionWriter::GetTargetSubstitution( | 195 EXPECT_TRUE(SubstitutionWriter::GetTargetSubstitution( |
| 196 &target, SUBSTITUTION_LABEL_NAME, &result)); |
| 197 EXPECT_EQ("baz", result); |
| 198 |
| 199 EXPECT_TRUE(SubstitutionWriter::GetTargetSubstitution( |
196 &target, SUBSTITUTION_ROOT_GEN_DIR, &result)); | 200 &target, SUBSTITUTION_ROOT_GEN_DIR, &result)); |
197 EXPECT_EQ("gen", result); | 201 EXPECT_EQ("gen", result); |
198 | 202 |
199 EXPECT_TRUE(SubstitutionWriter::GetTargetSubstitution( | 203 EXPECT_TRUE(SubstitutionWriter::GetTargetSubstitution( |
200 &target, SUBSTITUTION_ROOT_OUT_DIR, &result)); | 204 &target, SUBSTITUTION_ROOT_OUT_DIR, &result)); |
201 EXPECT_EQ(".", result); | 205 EXPECT_EQ(".", result); |
202 | 206 |
203 EXPECT_TRUE(SubstitutionWriter::GetTargetSubstitution( | 207 EXPECT_TRUE(SubstitutionWriter::GetTargetSubstitution( |
204 &target, SUBSTITUTION_TARGET_GEN_DIR, &result)); | 208 &target, SUBSTITUTION_TARGET_GEN_DIR, &result)); |
205 EXPECT_EQ("gen/foo/bar", result); | 209 EXPECT_EQ("gen/foo/bar", result); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 // Test that we handle paths that end up in the root build dir properly | 261 // Test that we handle paths that end up in the root build dir properly |
258 // (no leading "./" or "/"). | 262 // (no leading "./" or "/"). |
259 SubstitutionPattern pattern; | 263 SubstitutionPattern pattern; |
260 ASSERT_TRUE(pattern.Parse("{{root_out_dir}}/{{target_output_name}}.so", | 264 ASSERT_TRUE(pattern.Parse("{{root_out_dir}}/{{target_output_name}}.so", |
261 nullptr, &err)); | 265 nullptr, &err)); |
262 | 266 |
263 OutputFile output = SubstitutionWriter::ApplyPatternToLinkerAsOutputFile( | 267 OutputFile output = SubstitutionWriter::ApplyPatternToLinkerAsOutputFile( |
264 &target, tool, pattern); | 268 &target, tool, pattern); |
265 EXPECT_EQ("./libbaz.so", output.value()); | 269 EXPECT_EQ("./libbaz.so", output.value()); |
266 } | 270 } |
OLD | NEW |