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

Unified Diff: tools/gn/source_dir_unittest.cc

Issue 1455203002: [GN] Add support to rebase_path to resolve paths above the source root. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Add tests, handle Windows sources. Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/source_dir.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/source_dir_unittest.cc
diff --git a/tools/gn/source_dir_unittest.cc b/tools/gn/source_dir_unittest.cc
index 04684e6294f4559c90be2907fb235d62cd7d802d..0c73865ec9d6cd7d07df5df84fcc39dbf215e426 100644
--- a/tools/gn/source_dir_unittest.cc
+++ b/tools/gn/source_dir_unittest.cc
@@ -61,11 +61,41 @@ TEST(SourceDir, ResolveRelativeFile) {
Value(nullptr, "../../foo"), &err, source_root) ==
SourceFile("/C:/source/foo"));
EXPECT_FALSE(err.has_error());
+
+ EXPECT_TRUE(base.ResolveRelativeFile(
+ Value(nullptr, "//../foo"), &err, source_root) ==
+ SourceFile("/C:/source/foo"));
+ EXPECT_FALSE(err.has_error());
+
+ EXPECT_TRUE(base.ResolveRelativeFile(
+ Value(nullptr, "//../root/foo"), &err, source_root) ==
+ SourceFile("/C:/source/root/foo"));
+ EXPECT_FALSE(err.has_error());
+
+ EXPECT_TRUE(base.ResolveRelativeFile(
+ Value(nullptr, "//../../../foo/bar"), &err, source_root) ==
+ SourceFile("/foo/bar"));
+ EXPECT_FALSE(err.has_error());
#else
EXPECT_TRUE(base.ResolveRelativeFile(
Value(nullptr, "../../foo"), &err, source_root) ==
SourceFile("/source/foo"));
EXPECT_FALSE(err.has_error());
+
+ EXPECT_TRUE(base.ResolveRelativeFile(
+ Value(nullptr, "//../foo"), &err, source_root) ==
+ SourceFile("/source/foo"));
+ EXPECT_FALSE(err.has_error());
+
+ EXPECT_TRUE(base.ResolveRelativeFile(
+ Value(nullptr, "//../root/foo"), &err, source_root) ==
+ SourceFile("/source/root/foo"));
+ EXPECT_FALSE(err.has_error());
+
+ EXPECT_TRUE(base.ResolveRelativeFile(
+ Value(nullptr, "//../../../foo/bar"), &err, source_root) ==
+ SourceFile("/foo/bar"));
+ EXPECT_FALSE(err.has_error());
#endif
#if defined(OS_WIN)
@@ -120,11 +150,27 @@ TEST(SourceDir, ResolveRelativeDir) {
Value(nullptr, "../../foo"), &err, source_root) ==
SourceDir("/C:/source/foo/"));
EXPECT_FALSE(err.has_error());
+ EXPECT_TRUE(base.ResolveRelativeDir(
+ Value(nullptr, "//../foo"), &err, source_root) ==
+ SourceDir("/C:/source/foo/"));
+ EXPECT_FALSE(err.has_error());
+ EXPECT_TRUE(base.ResolveRelativeDir(
+ Value(nullptr, "//.."), &err, source_root) ==
+ SourceDir("/C:/source/"));
+ EXPECT_FALSE(err.has_error());
#else
EXPECT_TRUE(base.ResolveRelativeDir(
Value(nullptr, "../../foo"), &err, source_root) ==
SourceDir("/source/foo/"));
EXPECT_FALSE(err.has_error());
+ EXPECT_TRUE(base.ResolveRelativeDir(
+ Value(nullptr, "//../foo"), &err, source_root) ==
+ SourceDir("/source/foo/"));
+ EXPECT_FALSE(err.has_error());
+ EXPECT_TRUE(base.ResolveRelativeDir(
+ Value(nullptr, "//.."), &err, source_root) ==
+ SourceDir("/source/"));
+ EXPECT_FALSE(err.has_error());
#endif
#if defined(OS_WIN)
« 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