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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 154 |
155 EXPECT_EQ("obj/foo/bar", | 155 EXPECT_EQ("obj/foo/bar", |
156 GetRelSubst("//foo/bar/baz.txt", SUBSTITUTION_SOURCE_OUT_DIR)); | 156 GetRelSubst("//foo/bar/baz.txt", SUBSTITUTION_SOURCE_OUT_DIR)); |
157 EXPECT_EQ("//out/Debug/obj/foo/bar", | 157 EXPECT_EQ("//out/Debug/obj/foo/bar", |
158 GetAbsSubst("//foo/bar/baz.txt", SUBSTITUTION_SOURCE_OUT_DIR)); | 158 GetAbsSubst("//foo/bar/baz.txt", SUBSTITUTION_SOURCE_OUT_DIR)); |
159 | 159 |
160 // Operations on an absolute path. | 160 // Operations on an absolute path. |
161 EXPECT_EQ("/baz.txt", GetRelSubst("/baz.txt", SUBSTITUTION_SOURCE)); | 161 EXPECT_EQ("/baz.txt", GetRelSubst("/baz.txt", SUBSTITUTION_SOURCE)); |
162 EXPECT_EQ("/.", GetRelSubst("/baz.txt", SUBSTITUTION_SOURCE_DIR)); | 162 EXPECT_EQ("/.", GetRelSubst("/baz.txt", SUBSTITUTION_SOURCE_DIR)); |
163 EXPECT_EQ("gen", GetRelSubst("/baz.txt", SUBSTITUTION_SOURCE_GEN_DIR)); | 163 EXPECT_EQ("gen", GetRelSubst("/baz.txt", SUBSTITUTION_SOURCE_GEN_DIR)); |
164 EXPECT_EQ("obj", GetRelSubst("/baz.txt", SUBSTITUTION_SOURCE_OUT_DIR)); | 164 EXPECT_EQ("obj/ABS_PATH", |
| 165 GetRelSubst("/baz.txt", SUBSTITUTION_SOURCE_OUT_DIR)); |
165 | 166 |
166 EXPECT_EQ(".", | 167 EXPECT_EQ(".", |
167 GetRelSubst("//baz.txt", SUBSTITUTION_SOURCE_ROOT_RELATIVE_DIR)); | 168 GetRelSubst("//baz.txt", SUBSTITUTION_SOURCE_ROOT_RELATIVE_DIR)); |
168 | 169 |
169 #undef GetAbsSubst | 170 #undef GetAbsSubst |
170 #undef GetRelSubst | 171 #undef GetRelSubst |
171 } | 172 } |
172 | 173 |
173 TEST(SubstitutionWriter, TargetSubstitutions) { | 174 TEST(SubstitutionWriter, TargetSubstitutions) { |
174 TestWithScope setup; | 175 TestWithScope setup; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 // Test that we handle paths that end up in the root build dir properly | 250 // Test that we handle paths that end up in the root build dir properly |
250 // (no leading "./" or "/"). | 251 // (no leading "./" or "/"). |
251 SubstitutionPattern pattern; | 252 SubstitutionPattern pattern; |
252 ASSERT_TRUE(pattern.Parse("{{root_out_dir}}/{{target_output_name}}.so", | 253 ASSERT_TRUE(pattern.Parse("{{root_out_dir}}/{{target_output_name}}.so", |
253 nullptr, &err)); | 254 nullptr, &err)); |
254 | 255 |
255 OutputFile output = SubstitutionWriter::ApplyPatternToLinkerAsOutputFile( | 256 OutputFile output = SubstitutionWriter::ApplyPatternToLinkerAsOutputFile( |
256 &target, tool, pattern); | 257 &target, tool, pattern); |
257 EXPECT_EQ("./libbaz.so", output.value()); | 258 EXPECT_EQ("./libbaz.so", output.value()); |
258 } | 259 } |
OLD | NEW |