| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 GetAbsSubst("//foo/bar/baz.txt", SUBSTITUTION_SOURCE_GEN_DIR)); | 153 GetAbsSubst("//foo/bar/baz.txt", SUBSTITUTION_SOURCE_GEN_DIR)); |
| 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/ABS_PATH", |
| 164 GetRelSubst("/baz.txt", SUBSTITUTION_SOURCE_GEN_DIR)); |
| 164 EXPECT_EQ("obj/ABS_PATH", | 165 EXPECT_EQ("obj/ABS_PATH", |
| 165 GetRelSubst("/baz.txt", SUBSTITUTION_SOURCE_OUT_DIR)); | 166 GetRelSubst("/baz.txt", SUBSTITUTION_SOURCE_OUT_DIR)); |
| 166 #if defined(OS_WIN) | 167 #if defined(OS_WIN) |
| 168 EXPECT_EQ("gen/ABS_PATH/C", |
| 169 GetRelSubst("/C:/baz.txt", SUBSTITUTION_SOURCE_GEN_DIR)); |
| 167 EXPECT_EQ("obj/ABS_PATH/C", | 170 EXPECT_EQ("obj/ABS_PATH/C", |
| 168 GetRelSubst("/C:/baz.txt", SUBSTITUTION_SOURCE_OUT_DIR)); | 171 GetRelSubst("/C:/baz.txt", SUBSTITUTION_SOURCE_OUT_DIR)); |
| 169 #endif | 172 #endif |
| 170 | 173 |
| 171 EXPECT_EQ(".", | 174 EXPECT_EQ(".", |
| 172 GetRelSubst("//baz.txt", SUBSTITUTION_SOURCE_ROOT_RELATIVE_DIR)); | 175 GetRelSubst("//baz.txt", SUBSTITUTION_SOURCE_ROOT_RELATIVE_DIR)); |
| 173 | 176 |
| 174 #undef GetAbsSubst | 177 #undef GetAbsSubst |
| 175 #undef GetRelSubst | 178 #undef GetRelSubst |
| 176 } | 179 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 // Test that we handle paths that end up in the root build dir properly | 257 // Test that we handle paths that end up in the root build dir properly |
| 255 // (no leading "./" or "/"). | 258 // (no leading "./" or "/"). |
| 256 SubstitutionPattern pattern; | 259 SubstitutionPattern pattern; |
| 257 ASSERT_TRUE(pattern.Parse("{{root_out_dir}}/{{target_output_name}}.so", | 260 ASSERT_TRUE(pattern.Parse("{{root_out_dir}}/{{target_output_name}}.so", |
| 258 nullptr, &err)); | 261 nullptr, &err)); |
| 259 | 262 |
| 260 OutputFile output = SubstitutionWriter::ApplyPatternToLinkerAsOutputFile( | 263 OutputFile output = SubstitutionWriter::ApplyPatternToLinkerAsOutputFile( |
| 261 &target, tool, pattern); | 264 &target, tool, pattern); |
| 262 EXPECT_EQ("./libbaz.so", output.value()); | 265 EXPECT_EQ("./libbaz.so", output.value()); |
| 263 } | 266 } |
| OLD | NEW |