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

Side by Side Diff: build/android/pylib/cmd_helper_test.py

Issue 659533002: New run shell implementation for DeviceUtils (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed nit, and TODO to make cmd_helper_test run on bots Created 6 years, 2 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 | « build/android/pylib/cmd_helper.py ('k') | build/android/pylib/device/adb_wrapper.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Tests for the cmd_helper module."""
6
7 import unittest
8
9 from pylib import cmd_helper
10
11 # TODO(jbudorick) Make these tests run on the bots.
12
13
14 class CmdHelperSingleQuoteTest(unittest.TestCase):
15
16 def testSingleQuote_basic(self):
17 self.assertEquals('hello',
18 cmd_helper.SingleQuote('hello'))
19
20 def testSingleQuote_withSpaces(self):
21 self.assertEquals("'hello world'",
22 cmd_helper.SingleQuote('hello world'))
23
24 def testSingleQuote_withUnsafeChars(self):
25 self.assertEquals("""'hello'"'"'; rm -rf /'""",
26 cmd_helper.SingleQuote("hello'; rm -rf /"))
27
28 def testSingleQuote_dontExpand(self):
29 test_string = 'hello $TEST_VAR'
30 cmd = 'TEST_VAR=world; echo %s' % cmd_helper.SingleQuote(test_string)
31 self.assertEquals(test_string,
32 cmd_helper.GetCmdOutput(cmd, shell=True).rstrip())
33
34
35 class CmdHelperDoubleQuoteTest(unittest.TestCase):
36
37 def testDoubleQuote_basic(self):
38 self.assertEquals('hello',
39 cmd_helper.DoubleQuote('hello'))
40
41 def testDoubleQuote_withSpaces(self):
42 self.assertEquals('"hello world"',
43 cmd_helper.DoubleQuote('hello world'))
44
45 def testDoubleQuote_withUnsafeChars(self):
46 self.assertEquals('''"hello\\"; rm -rf /"''',
47 cmd_helper.DoubleQuote('hello"; rm -rf /'))
48
49 def testSingleQuote_doExpand(self):
50 test_string = 'hello $TEST_VAR'
51 cmd = 'TEST_VAR=world; echo %s' % cmd_helper.DoubleQuote(test_string)
52 self.assertEquals('hello world',
53 cmd_helper.GetCmdOutput(cmd, shell=True).rstrip())
OLDNEW
« no previous file with comments | « build/android/pylib/cmd_helper.py ('k') | build/android/pylib/device/adb_wrapper.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698