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

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

Issue 165823003: GN: Change gen command syntax, support relative dirs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments fixes Created 6 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 | Annotate | Revision Log
« no previous file with comments | « tools/gn/filesystem_utils.cc ('k') | tools/gn/gn_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "base/strings/string_util.h" 5 #include "base/strings/string_util.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "tools/gn/filesystem_utils.h" 9 #include "tools/gn/filesystem_utils.h"
10 10
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 } 247 }
248 248
249 TEST(FilesystemUtils, DirectoryWithNoLastSlash) { 249 TEST(FilesystemUtils, DirectoryWithNoLastSlash) {
250 EXPECT_EQ("", DirectoryWithNoLastSlash(SourceDir())); 250 EXPECT_EQ("", DirectoryWithNoLastSlash(SourceDir()));
251 EXPECT_EQ("/.", DirectoryWithNoLastSlash(SourceDir("/"))); 251 EXPECT_EQ("/.", DirectoryWithNoLastSlash(SourceDir("/")));
252 EXPECT_EQ("//.", DirectoryWithNoLastSlash(SourceDir("//"))); 252 EXPECT_EQ("//.", DirectoryWithNoLastSlash(SourceDir("//")));
253 EXPECT_EQ("//foo", DirectoryWithNoLastSlash(SourceDir("//foo/"))); 253 EXPECT_EQ("//foo", DirectoryWithNoLastSlash(SourceDir("//foo/")));
254 EXPECT_EQ("/bar", DirectoryWithNoLastSlash(SourceDir("/bar/"))); 254 EXPECT_EQ("/bar", DirectoryWithNoLastSlash(SourceDir("/bar/")));
255 } 255 }
256 256
257 TEST(FilesystemUtils, SourceDirForPath) {
258 #if defined(OS_WIN)
259 base::FilePath root(L"C:\\source\\foo\\");
260 EXPECT_EQ("/C:/foo/bar/", SourceDirForPath(root,
261 base::FilePath(L"C:\\foo\\bar")).value());
262 EXPECT_EQ("/", SourceDirForPath(root,
263 base::FilePath(L"/")).value());
264 EXPECT_EQ("//", SourceDirForPath(root,
265 base::FilePath(L"C:\\source\\foo")).value());
266 EXPECT_EQ("//bar/", SourceDirForPath(root,
267 base::FilePath(L"C:\\source\\foo\\bar\\")). value());
268 EXPECT_EQ("//bar/baz/", SourceDirForPath(root,
269 base::FilePath(L"C:\\source\\foo\\bar\\baz")).value());
270
271 // Should be case-and-slash-insensitive.
272 EXPECT_EQ("//baR/", SourceDirForPath(root,
273 base::FilePath(L"c:/SOURCE\\Foo/baR/")).value());
274
275 // Some "weird" Windows paths.
276 EXPECT_EQ("/foo/bar/", SourceDirForPath(root,
277 base::FilePath(L"/foo/bar/")).value());
278 EXPECT_EQ("/C:/foo/bar/", SourceDirForPath(root,
279 base::FilePath(L"C:foo/bar/")).value());
280
281 // Also allow absolute GN-style Windows paths.
282 EXPECT_EQ("/C:/foo/bar/", SourceDirForPath(root,
283 base::FilePath(L"/C:/foo/bar")).value());
284 EXPECT_EQ("//bar/", SourceDirForPath(root,
285 base::FilePath(L"/C:/source/foo/bar")).value());
286
287 #else
288 base::FilePath root("/source/foo/");
289 EXPECT_EQ("/foo/bar/", SourceDirForPath(root,
290 base::FilePath("/foo/bar/")).value());
291 EXPECT_EQ("/", SourceDirForPath(root,
292 base::FilePath("/")).value());
293 EXPECT_EQ("//", SourceDirForPath(root,
294 base::FilePath("/source/foo")).value());
295 EXPECT_EQ("//bar/", SourceDirForPath(root,
296 base::FilePath("/source/foo/bar/")).value());
297 EXPECT_EQ("//bar/baz/", SourceDirForPath(root,
298 base::FilePath("/source/foo/bar/baz/")).value());
299
300 // Should be case-sensitive.
301 EXPECT_EQ("/SOURCE/foo/bar/", SourceDirForPath(root,
302 base::FilePath("/SOURCE/foo/bar/")).value());
303 #endif
304 }
305
257 TEST(FilesystemUtils, GetToolchainDirs) { 306 TEST(FilesystemUtils, GetToolchainDirs) {
258 BuildSettings build_settings; 307 BuildSettings build_settings;
259 build_settings.SetBuildDir(SourceDir("//out/Debug/")); 308 build_settings.SetBuildDir(SourceDir("//out/Debug/"));
260 309
261 Settings default_settings(&build_settings, ""); 310 Settings default_settings(&build_settings, "");
262 EXPECT_EQ("//out/Debug/", 311 EXPECT_EQ("//out/Debug/",
263 GetToolchainOutputDir(&default_settings).value()); 312 GetToolchainOutputDir(&default_settings).value());
264 EXPECT_EQ("//out/Debug/gen/", 313 EXPECT_EQ("//out/Debug/gen/",
265 GetToolchainGenDir(&default_settings).value()); 314 GetToolchainGenDir(&default_settings).value());
266 315
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 build_settings.SetBuildDir(SourceDir("//")); 369 build_settings.SetBuildDir(SourceDir("//"));
321 Settings settings(&build_settings, ""); 370 Settings settings(&build_settings, "");
322 371
323 EXPECT_EQ("//", GetToolchainOutputDir(&settings).value()); 372 EXPECT_EQ("//", GetToolchainOutputDir(&settings).value());
324 EXPECT_EQ("//gen/", GetToolchainGenDir(&settings).value()); 373 EXPECT_EQ("//gen/", GetToolchainGenDir(&settings).value());
325 EXPECT_EQ("//obj/", 374 EXPECT_EQ("//obj/",
326 GetOutputDirForSourceDir(&settings, SourceDir("//")).value()); 375 GetOutputDirForSourceDir(&settings, SourceDir("//")).value());
327 EXPECT_EQ("//gen/", 376 EXPECT_EQ("//gen/",
328 GetGenDirForSourceDir(&settings, SourceDir("//")).value()); 377 GetGenDirForSourceDir(&settings, SourceDir("//")).value());
329 } 378 }
OLDNEW
« no previous file with comments | « tools/gn/filesystem_utils.cc ('k') | tools/gn/gn_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698