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

Unified Diff: tools/gn/filesystem_utils_unittest.cc

Issue 1256043006: Reference written files relatively when possible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: tools/gn/filesystem_utils_unittest.cc
diff --git a/tools/gn/filesystem_utils_unittest.cc b/tools/gn/filesystem_utils_unittest.cc
index 14bc9515307e3767a108ff2f358a7789b68eb7a5..44b0fa5895331a9c0c612cfa6eda7197a93d8ba1 100644
--- a/tools/gn/filesystem_utils_unittest.cc
+++ b/tools/gn/filesystem_utils_unittest.cc
@@ -119,6 +119,51 @@ TEST(FilesystemUtils, EnsureStringIsInOutputDir) {
EXPECT_TRUE(err.has_error());
}
+TEST(FilesystemUtils, ComputeStringInOutputDir) {
+ SourceDir out_d("//out/Debug/");
+ SourceFile foo("//foo");
+ SourceFile debugit("//out/Debugit");
+ SourceFile out_less("//out/Debug");
+
+ // Some outside.
+ Err err;
+ EXPECT_EQ("", ComputeStringInOutputDir(out_d, foo, &err));
+ EXPECT_TRUE(err.has_error());
+
+ err = Err();
+ EXPECT_EQ("", ComputeStringInOutputDir(out_d, debugit, &err));
+ EXPECT_TRUE(err.has_error());
+
+ // Some inside.
+ err = Err();
+ EXPECT_EQ("", ComputeStringInOutputDir(out_d, out_less, &err));
+ EXPECT_TRUE(err.has_error());
+
+ err = Err();
+ const char * const r_a = "a";
+ SourceFile a("//out/Debug/a");
+ EXPECT_EQ(r_a, ComputeStringInOutputDir(out_d, a, &err));
+ EXPECT_FALSE(err.has_error());
+
+ err = Err();
+ const char * const r_ofoo = "foo";
+ SourceFile ofoo("//out/Debug/foo");
+ EXPECT_EQ(r_ofoo, ComputeStringInOutputDir(out_d, ofoo, &err));
+ EXPECT_FALSE(err.has_error());
+
+ err = Err();
+ const char * const r_olong = "super-cal/bong/pas";
+ SourceFile olong("//out/Debug/super-cal/bong/pas");
+ EXPECT_EQ(r_olong, ComputeStringInOutputDir(out_d, olong, &err));
+ EXPECT_FALSE(err.has_error());
+
+ // Pattern but no template expansions are allowed.
+ SourceFile wrong("//{{source_gen_dir}}");
+ EXPECT_EQ("", ComputeStringInOutputDir(out_d, wrong, &err));
+ EXPECT_TRUE(err.has_error());
+
+}
+
TEST(FilesystemUtils, IsPathAbsolute) {
EXPECT_TRUE(IsPathAbsolute("/foo/bar"));
EXPECT_TRUE(IsPathAbsolute("/"));

Powered by Google App Engine
This is Rietveld 408576698