Changeset 122481 in webkit
- Timestamp:
- Jul 12, 2012 10:57:41 AM (12 years ago)
- Location:
- trunk/Tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r122467 r122481 1 2012-07-12 Ojan Vafai <ojan@chromium.org> 2 3 Allow putting ranges in user.py list prompts 4 https://bugs.webkit.org/show_bug.cgi?id=91115 5 6 Reviewed by Adam Barth. 7 8 Ranges are inclusive and denoted by a dash. This is useful for rebaselining a whole port 9 since the items are listed with each port's builders being contiguous. 10 11 * Scripts/webkitpy/common/system/user.py: 12 (User._wait_on_list_response): 13 * Scripts/webkitpy/common/system/user_unittest.py: 14 (UserTest.test_prompt_with_multiple_lists.run_prompt_test): 15 (UserTest.test_prompt_with_multiple_lists): 16 1 17 2012-07-12 Arnaud Renevier <arno@renevier.net> 2 18 -
trunk/Tools/Scripts/webkitpy/common/system/user.py
r122234 r122481 91 91 while True: 92 92 if can_choose_multiple: 93 response = cls.prompt("Enter one or more numbers (comma-separated) , or \"all\": ", raw_input=raw_input)93 response = cls.prompt("Enter one or more numbers (comma-separated) or ranges (e.g. 3-7), or \"all\": ", raw_input=raw_input) 94 94 if not response.strip() or response == "all": 95 95 return list_items 96 96 97 try: 97 indices = [int(r) - 1 for r in re.split("\s*,\s*", response)] 98 indices = [] 99 for value in re.split("\s*,\s*", response): 100 parts = value.split('-') 101 if len(parts) == 2: 102 indices += range(int(parts[0]) - 1, int(parts[1])) 103 else: 104 indices.append(int(value) - 1) 98 105 except ValueError, err: 99 106 continue 107 100 108 return [list_items[i] for i in indices] 101 109 else: -
trunk/Tools/Scripts/webkitpy/common/system/user_unittest.py
r122234 r122481 60 60 self, 61 61 User.prompt_with_multiple_lists, 62 args=["title", ["subtitle1", "subtitle2"], [["foo", "bar"], ["foobar", "barbaz" ]]],62 args=["title", ["subtitle1", "subtitle2"], [["foo", "bar"], ["foobar", "barbaz", "foobaz"]]], 63 63 kwargs={"can_choose_multiple": can_choose_multiple, "raw_input": mock_raw_input}, 64 expected_stdout="title\n\nsubtitle1\n 1. foo\n 2. bar\n\nsubtitle2\n 3. foobar\n 4. barbaz\n ")64 expected_stdout="title\n\nsubtitle1\n 1. foo\n 2. bar\n\nsubtitle2\n 3. foobar\n 4. barbaz\n 5. foobaz\n") 65 65 self.assertEqual(actual_result, expected_result) 66 66 self.assertEqual(len(inputs), 0) … … 70 70 run_prompt_test(["3"], "foobar") 71 71 run_prompt_test(["4"], "barbaz") 72 run_prompt_test(["5"], "foobaz") 72 73 73 74 run_prompt_test(["1,2"], ["foo", "bar"], can_choose_multiple=True) 75 run_prompt_test(["1-3"], ["foo", "bar", "foobar"], can_choose_multiple=True) 76 run_prompt_test(["1-2,3"], ["foo", "bar", "foobar"], can_choose_multiple=True) 77 run_prompt_test(["2-1,3"], ["foobar"], can_choose_multiple=True) 74 78 run_prompt_test([" 1, 2 "], ["foo", "bar"], can_choose_multiple=True) 75 run_prompt_test(["all"], ["foo", "bar", 'foobar', 'barbaz' ], can_choose_multiple=True)76 run_prompt_test([""], ["foo", "bar", 'foobar', 'barbaz' ], can_choose_multiple=True)77 run_prompt_test([" "], ["foo", "bar", 'foobar', 'barbaz' ], can_choose_multiple=True)78 run_prompt_test(["badinput", "all"], ["foo", "bar", 'foobar', 'barbaz' ], can_choose_multiple=True)79 run_prompt_test(["all"], ["foo", "bar", 'foobar', 'barbaz', 'foobaz'], can_choose_multiple=True) 80 run_prompt_test([""], ["foo", "bar", 'foobar', 'barbaz', 'foobaz'], can_choose_multiple=True) 81 run_prompt_test([" "], ["foo", "bar", 'foobar', 'barbaz', 'foobaz'], can_choose_multiple=True) 82 run_prompt_test(["badinput", "all"], ["foo", "bar", 'foobar', 'barbaz', 'foobaz'], can_choose_multiple=True) 79 83 80 84 def test_prompt_with_list(self):
Note: See TracChangeset
for help on using the changeset viewer.