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

Unified Diff: tools/gn/filesystem_utils_unittest.cc

Issue 80463004: GN generator for GYP actions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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/filesystem_utils.cc ('k') | tools/gn/functions_target.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/filesystem_utils_unittest.cc
diff --git a/tools/gn/filesystem_utils_unittest.cc b/tools/gn/filesystem_utils_unittest.cc
index aeb09a4f95dd485a55b0662745e957f80da869be..f62f4820c671d29d30ca6da96d9691ba6b89bb23 100644
--- a/tools/gn/filesystem_utils_unittest.cc
+++ b/tools/gn/filesystem_utils_unittest.cc
@@ -245,3 +245,85 @@ TEST(FilesystemUtils, RebaseSourceAbsolutePath) {
EXPECT_EQ("../bar",
RebaseSourceAbsolutePath("//foo/bar", SourceDir("//foo/bar/")));
}
+
+TEST(FilesystemUtils, DirectoryWithNoLastSlash) {
+ EXPECT_EQ("", DirectoryWithNoLastSlash(SourceDir()));
+ EXPECT_EQ("/.", DirectoryWithNoLastSlash(SourceDir("/")));
+ EXPECT_EQ("//.", DirectoryWithNoLastSlash(SourceDir("//")));
+ EXPECT_EQ("//foo", DirectoryWithNoLastSlash(SourceDir("//foo/")));
+ EXPECT_EQ("/bar", DirectoryWithNoLastSlash(SourceDir("/bar/")));
+}
+
+TEST(FilesystemUtils, GetToolchainDirs) {
+ BuildSettings build_settings;
+ build_settings.SetBuildDir(SourceDir("//out/Debug/"));
+
+ Settings default_settings(&build_settings, "");
+ EXPECT_EQ("//out/Debug/",
+ GetToolchainOutputDir(&default_settings).value());
+ EXPECT_EQ("//out/Debug/gen/",
+ GetToolchainGenDir(&default_settings).value());
+
+ Settings other_settings(&build_settings, "two");
+ EXPECT_EQ("//out/Debug/two/",
+ GetToolchainOutputDir(&other_settings).value());
+ EXPECT_EQ("//out/Debug/two/gen/",
+ GetToolchainGenDir(&other_settings).value());
+}
+
+TEST(FilesystemUtils, GetOutDirForSourceDir) {
+ BuildSettings build_settings;
+ build_settings.SetBuildDir(SourceDir("//out/Debug/"));
+
+ // Test the default toolchain.
+ Settings default_settings(&build_settings, "");
+ EXPECT_EQ("//out/Debug/obj/",
+ GetOutputDirForSourceDir(&default_settings,
+ SourceDir("//")).value());
+ EXPECT_EQ("//out/Debug/obj/foo/bar/",
+ GetOutputDirForSourceDir(&default_settings,
+ SourceDir("//foo/bar/")).value());
+
+ // Secondary toolchain.
+ Settings other_settings(&build_settings, "two");
+ EXPECT_EQ("//out/Debug/two/obj/",
+ GetOutputDirForSourceDir(&other_settings, SourceDir("//")).value());
+ EXPECT_EQ("//out/Debug/two/obj/foo/bar/",
+ GetOutputDirForSourceDir(&other_settings,
+ SourceDir("//foo/bar/")).value());
+}
+
+TEST(FilesystemUtils, GetGenDirForSourceDir) {
+ BuildSettings build_settings;
+ build_settings.SetBuildDir(SourceDir("//out/Debug/"));
+
+ // Test the default toolchain.
+ Settings default_settings(&build_settings, "");
+ EXPECT_EQ("//out/Debug/gen/",
+ GetGenDirForSourceDir(&default_settings, SourceDir("//")).value());
+ EXPECT_EQ("//out/Debug/gen/foo/bar/",
+ GetGenDirForSourceDir(&default_settings,
+ SourceDir("//foo/bar/")).value());
+
+ // Secondary toolchain.
+ Settings other_settings(&build_settings, "two");
+ EXPECT_EQ("//out/Debug/two/gen/",
+ GetGenDirForSourceDir(&other_settings, SourceDir("//")).value());
+ EXPECT_EQ("//out/Debug/two/gen/foo/bar/",
+ GetGenDirForSourceDir(&other_settings,
+ SourceDir("//foo/bar/")).value());
+}
+
+// Tests handling of output dirs when build dir is the same as the root.
+TEST(FilesystemUtils, GetDirForEmptyBuildDir) {
+ BuildSettings build_settings;
+ build_settings.SetBuildDir(SourceDir("//"));
+ Settings settings(&build_settings, "");
+
+ EXPECT_EQ("//", GetToolchainOutputDir(&settings).value());
+ EXPECT_EQ("//gen/", GetToolchainGenDir(&settings).value());
+ EXPECT_EQ("//obj/",
+ GetOutputDirForSourceDir(&settings, SourceDir("//")).value());
+ EXPECT_EQ("//gen/",
+ GetGenDirForSourceDir(&settings, SourceDir("//")).value());
+}
« no previous file with comments | « tools/gn/filesystem_utils.cc ('k') | tools/gn/functions_target.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698