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

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

Issue 2809633002: Add curly brackets to list of characters that gn needs to escape (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « tools/gn/escape.cc ('k') | no next file » | 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "tools/gn/escape.h" 6 #include "tools/gn/escape.h"
7 7
8 TEST(Escape, Ninja) { 8 TEST(Escape, Ninja) {
9 EscapeOptions opts; 9 EscapeOptions opts;
10 opts.mode = ESCAPE_NINJA; 10 opts.mode = ESCAPE_NINJA;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 TEST(Escape, PosixCommand) { 42 TEST(Escape, PosixCommand) {
43 EscapeOptions opts; 43 EscapeOptions opts;
44 opts.mode = ESCAPE_NINJA_COMMAND; 44 opts.mode = ESCAPE_NINJA_COMMAND;
45 opts.platform = ESCAPE_PLATFORM_POSIX; 45 opts.platform = ESCAPE_PLATFORM_POSIX;
46 46
47 // : and $ ninja escaped with $. Then Shell-escape backslashes and quotes. 47 // : and $ ninja escaped with $. Then Shell-escape backslashes and quotes.
48 EXPECT_EQ("a$:\\$ \\\"\\$$\\\\b", EscapeString("a: \"$\\b", opts, nullptr)); 48 EXPECT_EQ("a$:\\$ \\\"\\$$\\\\b", EscapeString("a: \"$\\b", opts, nullptr));
49 49
50 // Some more generic shell chars. 50 // Some more generic shell chars.
51 EXPECT_EQ("a_\\;\\<\\*b", EscapeString("a_;<*b", opts, nullptr)); 51 EXPECT_EQ("a_\\;\\<\\*b", EscapeString("a_;<*b", opts, nullptr));
52
53 // Curly braces must be escaped to avoid brace expansion on systems using
54 // bash as default shell..
55 EXPECT_EQ("\\{a,b\\}\\{c,d\\}", EscapeString("{a,b}{c,d}", opts, nullptr));
52 } 56 }
53 57
54 TEST(Escape, NinjaPreformatted) { 58 TEST(Escape, NinjaPreformatted) {
55 EscapeOptions opts; 59 EscapeOptions opts;
56 opts.mode = ESCAPE_NINJA_PREFORMATTED_COMMAND; 60 opts.mode = ESCAPE_NINJA_PREFORMATTED_COMMAND;
57 61
58 // Only $ is escaped. 62 // Only $ is escaped.
59 EXPECT_EQ("a: \"$$\\b<;", EscapeString("a: \"$\\b<;", opts, nullptr)); 63 EXPECT_EQ("a: \"$$\\b<;", EscapeString("a: \"$\\b<;", opts, nullptr));
60 } 64 }
OLDNEW
« no previous file with comments | « tools/gn/escape.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698