Index: build/android/pylib/cmd_helper_test.py |
diff --git a/build/android/pylib/cmd_helper_test.py b/build/android/pylib/cmd_helper_test.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5fb9ac7738c9c44de57bd4040a9cee97ef9859b2 |
--- /dev/null |
+++ b/build/android/pylib/cmd_helper_test.py |
@@ -0,0 +1,51 @@ |
+# Copyright 2013 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+"""Tests for the cmd_helper module.""" |
+ |
+import unittest |
+ |
+from pylib import cmd_helper |
+ |
+ |
jbudorick
2014/10/17 15:48:00
Add a TODO for me to make these run on the bots.
|
+class CmdHelperSingleQuoteTest(unittest.TestCase): |
+ |
+ def testSingleQuote_basic(self): |
+ self.assertEquals('hello', |
+ cmd_helper.SingleQuote('hello')) |
+ |
+ def testSingleQuote_withSpaces(self): |
+ self.assertEquals("'hello world'", |
+ cmd_helper.SingleQuote('hello world')) |
+ |
+ def testSingleQuote_withUnsafeChars(self): |
+ self.assertEquals("""'hello'"'"'; rm -rf /'""", |
+ cmd_helper.SingleQuote("hello'; rm -rf /")) |
+ |
+ def testSingleQuote_dontExpand(self): |
+ test_string = 'hello $TEST_VAR' |
+ cmd = 'TEST_VAR=world; echo %s' % cmd_helper.SingleQuote(test_string) |
+ self.assertEquals(test_string, |
+ cmd_helper.GetCmdOutput(cmd, shell=True).rstrip()) |
+ |
+ |
+class CmdHelperDoubleQuoteTest(unittest.TestCase): |
+ |
+ def testDoubleQuote_basic(self): |
+ self.assertEquals('hello', |
+ cmd_helper.DoubleQuote('hello')) |
+ |
+ def testDoubleQuote_withSpaces(self): |
+ self.assertEquals('"hello world"', |
+ cmd_helper.DoubleQuote('hello world')) |
+ |
+ def testDoubleQuote_withUnsafeChars(self): |
+ self.assertEquals('''"hello\\"; rm -rf /"''', |
+ cmd_helper.DoubleQuote('hello"; rm -rf /')) |
+ |
+ def testSingleQuote_doExpand(self): |
+ test_string = 'hello $TEST_VAR' |
+ cmd = 'TEST_VAR=world; echo %s' % cmd_helper.DoubleQuote(test_string) |
+ self.assertEquals('hello world', |
+ cmd_helper.GetCmdOutput(cmd, shell=True).rstrip()) |