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)); |
| 166 #if defined(OS_WIN) |
| 167 EXPECT_EQ("obj/ABS_PATH/C", |
| 168 GetRelSubst("/C:/baz.txt", SUBSTITUTION_SOURCE_OUT_DIR)); |
| 169 #endif |
165 | 170 |
166 EXPECT_EQ(".", | 171 EXPECT_EQ(".", |
167 GetRelSubst("//baz.txt", SUBSTITUTION_SOURCE_ROOT_RELATIVE_DIR)); | 172 GetRelSubst("//baz.txt", SUBSTITUTION_SOURCE_ROOT_RELATIVE_DIR)); |
168 | 173 |
169 #undef GetAbsSubst | 174 #undef GetAbsSubst |
170 #undef GetRelSubst | 175 #undef GetRelSubst |
171 } | 176 } |
172 | 177 |
173 TEST(SubstitutionWriter, TargetSubstitutions) { | 178 TEST(SubstitutionWriter, TargetSubstitutions) { |
174 TestWithScope setup; | 179 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 | 254 // Test that we handle paths that end up in the root build dir properly |
250 // (no leading "./" or "/"). | 255 // (no leading "./" or "/"). |
251 SubstitutionPattern pattern; | 256 SubstitutionPattern pattern; |
252 ASSERT_TRUE(pattern.Parse("{{root_out_dir}}/{{target_output_name}}.so", | 257 ASSERT_TRUE(pattern.Parse("{{root_out_dir}}/{{target_output_name}}.so", |
253 nullptr, &err)); | 258 nullptr, &err)); |
254 | 259 |
255 OutputFile output = SubstitutionWriter::ApplyPatternToLinkerAsOutputFile( | 260 OutputFile output = SubstitutionWriter::ApplyPatternToLinkerAsOutputFile( |
256 &target, tool, pattern); | 261 &target, tool, pattern); |
257 EXPECT_EQ("./libbaz.so", output.value()); | 262 EXPECT_EQ("./libbaz.so", output.value()); |
258 } | 263 } |
OLD | NEW |