Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(702)

Side by Side Diff: tools/gn/substitution_writer_unittest.cc

Issue 857163002: Absolute path fixes for gn. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Improve error message Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gn/source_dir.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « tools/gn/source_dir.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698