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

Unified Diff: build/android/devil/utils/cmd_helper_test.py

Issue 1397663002: DeviceUtils.StartInstrumentation: Shrink command-line (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add blank line Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/devil/utils/cmd_helper.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/devil/utils/cmd_helper_test.py
diff --git a/build/android/devil/utils/cmd_helper_test.py b/build/android/devil/utils/cmd_helper_test.py
old mode 100644
new mode 100755
index ba45a51437757a012ea82ddcbe8250d0d8b3de80..c01c31947a3c38e6c48d754fbe63632c76db3674
--- a/build/android/devil/utils/cmd_helper_test.py
+++ b/build/android/devil/utils/cmd_helper_test.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
# 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.
@@ -52,6 +53,36 @@ class CmdHelperDoubleQuoteTest(unittest.TestCase):
cmd_helper.GetCmdOutput(cmd, shell=True).rstrip())
+class CmdHelperShinkToSnippetTest(unittest.TestCase):
+
+ def testShrinkToSnippet_noArgs(self):
+ self.assertEquals('foo',
+ cmd_helper.ShrinkToSnippet(['foo'], 'a', 'bar'))
+ self.assertEquals("'foo foo'",
+ cmd_helper.ShrinkToSnippet(['foo foo'], 'a', 'bar'))
+ self.assertEquals('"$a"\' bar\'',
+ cmd_helper.ShrinkToSnippet(['foo bar'], 'a', 'foo'))
+ self.assertEquals('\'foo \'"$a"',
+ cmd_helper.ShrinkToSnippet(['foo bar'], 'a', 'bar'))
+ self.assertEquals('foo"$a"',
+ cmd_helper.ShrinkToSnippet(['foobar'], 'a', 'bar'))
+
+ def testShrinkToSnippet_singleArg(self):
+ self.assertEquals("foo ''",
+ cmd_helper.ShrinkToSnippet(['foo', ''], 'a', 'bar'))
+ self.assertEquals("foo foo",
+ cmd_helper.ShrinkToSnippet(['foo', 'foo'], 'a', 'bar'))
+ self.assertEquals('"$a" "$a"',
+ cmd_helper.ShrinkToSnippet(['foo', 'foo'], 'a', 'foo'))
+ self.assertEquals('foo "$a""$a"',
+ cmd_helper.ShrinkToSnippet(['foo', 'barbar'], 'a', 'bar'))
+ self.assertEquals('foo "$a"\' \'"$a"',
+ cmd_helper.ShrinkToSnippet(['foo', 'bar bar'], 'a', 'bar'))
+ self.assertEquals('foo "$a""$a"\' \'',
+ cmd_helper.ShrinkToSnippet(['foo', 'barbar '], 'a', 'bar'))
+ self.assertEquals('foo \' \'"$a""$a"\' \'',
+ cmd_helper.ShrinkToSnippet(['foo', ' barbar '], 'a', 'bar'))
+
class CmdHelperIterCmdOutputLinesTest(unittest.TestCase):
"""Test IterCmdOutputLines with some calls to the unix 'seq' command."""
@@ -81,3 +112,7 @@ class CmdHelperIterCmdOutputLinesTest(unittest.TestCase):
# the end of the output and, thus, the status never gets checked
if num == 10:
break
+
+
+if __name__ == '__main__':
+ unittest.main()
« no previous file with comments | « build/android/devil/utils/cmd_helper.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698