Title: [122481] trunk/Tools
Revision
122481
Author
[email protected]
Date
2012-07-12 10:57:41 -0700 (Thu, 12 Jul 2012)

Log Message

Allow putting ranges in user.py list prompts
https://bugs.webkit.org/show_bug.cgi?id=91115

Reviewed by Adam Barth.

Ranges are inclusive and denoted by a dash. This is useful for rebaselining a whole port
since the items are listed with each port's builders being contiguous.

* Scripts/webkitpy/common/system/user.py:
(User._wait_on_list_response):
* Scripts/webkitpy/common/system/user_unittest.py:
(UserTest.test_prompt_with_multiple_lists.run_prompt_test):
(UserTest.test_prompt_with_multiple_lists):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (122480 => 122481)


--- trunk/Tools/ChangeLog	2012-07-12 17:33:48 UTC (rev 122480)
+++ trunk/Tools/ChangeLog	2012-07-12 17:57:41 UTC (rev 122481)
@@ -1,3 +1,19 @@
+2012-07-12  Ojan Vafai  <[email protected]>
+
+        Allow putting ranges in user.py list prompts
+        https://bugs.webkit.org/show_bug.cgi?id=91115
+
+        Reviewed by Adam Barth.
+
+        Ranges are inclusive and denoted by a dash. This is useful for rebaselining a whole port
+        since the items are listed with each port's builders being contiguous.
+
+        * Scripts/webkitpy/common/system/user.py:
+        (User._wait_on_list_response):
+        * Scripts/webkitpy/common/system/user_unittest.py:
+        (UserTest.test_prompt_with_multiple_lists.run_prompt_test):
+        (UserTest.test_prompt_with_multiple_lists):
+
 2012-07-12  Arnaud Renevier  <[email protected]>
 
         [GTK] Implement disableImageLoading in DRT

Modified: trunk/Tools/Scripts/webkitpy/common/system/user.py (122480 => 122481)


--- trunk/Tools/Scripts/webkitpy/common/system/user.py	2012-07-12 17:33:48 UTC (rev 122480)
+++ trunk/Tools/Scripts/webkitpy/common/system/user.py	2012-07-12 17:57:41 UTC (rev 122481)
@@ -90,13 +90,21 @@
     def _wait_on_list_response(cls, list_items, can_choose_multiple, raw_input):
         while True:
             if can_choose_multiple:
-                response = cls.prompt("Enter one or more numbers (comma-separated), or \"all\": ", raw_input=raw_input)
+                response = cls.prompt("Enter one or more numbers (comma-separated) or ranges (e.g. 3-7), or \"all\": ", raw_input=raw_input)
                 if not response.strip() or response == "all":
                     return list_items
+
                 try:
-                    indices = [int(r) - 1 for r in re.split("\s*,\s*", response)]
+                    indices = []
+                    for value in re.split("\s*,\s*", response):
+                        parts = value.split('-')
+                        if len(parts) == 2:
+                            indices += range(int(parts[0]) - 1, int(parts[1]))
+                        else:
+                            indices.append(int(value) - 1)
                 except ValueError, err:
                     continue
+
                 return [list_items[i] for i in indices]
             else:
                 try:

Modified: trunk/Tools/Scripts/webkitpy/common/system/user_unittest.py (122480 => 122481)


--- trunk/Tools/Scripts/webkitpy/common/system/user_unittest.py	2012-07-12 17:33:48 UTC (rev 122480)
+++ trunk/Tools/Scripts/webkitpy/common/system/user_unittest.py	2012-07-12 17:57:41 UTC (rev 122481)
@@ -59,9 +59,9 @@
             actual_result = output_capture.assert_outputs(
                 self,
                 User.prompt_with_multiple_lists,
-                args=["title", ["subtitle1", "subtitle2"], [["foo", "bar"], ["foobar", "barbaz"]]],
+                args=["title", ["subtitle1", "subtitle2"], [["foo", "bar"], ["foobar", "barbaz", "foobaz"]]],
                 kwargs={"can_choose_multiple": can_choose_multiple, "raw_input": mock_raw_input},
-                expected_stdout="title\n\nsubtitle1\n 1. foo\n 2. bar\n\nsubtitle2\n 3. foobar\n 4. barbaz\n")
+                expected_stdout="title\n\nsubtitle1\n 1. foo\n 2. bar\n\nsubtitle2\n 3. foobar\n 4. barbaz\n 5. foobaz\n")
             self.assertEqual(actual_result, expected_result)
             self.assertEqual(len(inputs), 0)
 
@@ -69,13 +69,17 @@
         run_prompt_test(["badinput", "2"], "bar")
         run_prompt_test(["3"], "foobar")
         run_prompt_test(["4"], "barbaz")
+        run_prompt_test(["5"], "foobaz")
 
         run_prompt_test(["1,2"], ["foo", "bar"], can_choose_multiple=True)
+        run_prompt_test(["1-3"], ["foo", "bar", "foobar"], can_choose_multiple=True)
+        run_prompt_test(["1-2,3"], ["foo", "bar", "foobar"], can_choose_multiple=True)
+        run_prompt_test(["2-1,3"], ["foobar"], can_choose_multiple=True)
         run_prompt_test(["  1,  2   "], ["foo", "bar"], can_choose_multiple=True)
-        run_prompt_test(["all"], ["foo", "bar", 'foobar', 'barbaz'], can_choose_multiple=True)
-        run_prompt_test([""], ["foo", "bar", 'foobar', 'barbaz'], can_choose_multiple=True)
-        run_prompt_test(["  "], ["foo", "bar", 'foobar', 'barbaz'], can_choose_multiple=True)
-        run_prompt_test(["badinput", "all"], ["foo", "bar", 'foobar', 'barbaz'], can_choose_multiple=True)
+        run_prompt_test(["all"], ["foo", "bar", 'foobar', 'barbaz', 'foobaz'], can_choose_multiple=True)
+        run_prompt_test([""], ["foo", "bar", 'foobar', 'barbaz', 'foobaz'], can_choose_multiple=True)
+        run_prompt_test(["  "], ["foo", "bar", 'foobar', 'barbaz', 'foobaz'], can_choose_multiple=True)
+        run_prompt_test(["badinput", "all"], ["foo", "bar", 'foobar', 'barbaz', 'foobaz'], can_choose_multiple=True)
 
     def test_prompt_with_list(self):
         def run_prompt_test(inputs, expected_result, can_choose_multiple=False):
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to