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

Unified Diff: tools/gn/escape_unittest.cc

Issue 305653008: Escape more characters for GN shell writing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
« tools/gn/escape.cc ('K') | « tools/gn/escape.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/escape_unittest.cc
diff --git a/tools/gn/escape_unittest.cc b/tools/gn/escape_unittest.cc
index 7ba0af060d18099de347dee1297c86a5c35ba700..9d0cf7a9000acbf29ec26c22b562243be0d9787d 100644
--- a/tools/gn/escape_unittest.cc
+++ b/tools/gn/escape_unittest.cc
@@ -19,10 +19,24 @@ TEST(Escape, Shell) {
#if defined(OS_WIN)
// Windows shell doesn't escape backslashes, but it does backslash-escape
// quotes.
- EXPECT_EQ("\"asdf: \\\"$\\bar\"", result);
+ EXPECT_EQ("\"asdf: \\\"\\$\\bar\"", result);
#else
- EXPECT_EQ("\"asdf: \\\"$\\\\bar\"", result);
+ EXPECT_EQ("\"asdf: \\\"\\$\\\\bar\"", result);
#endif
+
+ // Some more generic shell chars.
+ result = EscapeString("a_;<*b", opts, NULL);
+ EXPECT_EQ("a_\\;\\<\\*b", result);
+}
+
+TEST(Escape, NinjaShell) {
+ EscapeOptions opts;
+ opts.mode = ESCAPE_NINJA_SHELL;
+
+ // When escaping for Ninja and the shell, we would escape a $, then escape
+ // the backslash again.
+ std::string result = EscapeString("a$b", opts, NULL);
+ EXPECT_EQ("a\\$$b", result);
}
TEST(Escape, UsedQuotes) {
« tools/gn/escape.cc ('K') | « tools/gn/escape.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698