Bug 1146218 - Harden taskcluster platform parser r=wcosta
authorjlal@mozilla.com
Sun, 22 Mar 2015 20:02:20 -0700
changeset 235143 b88348b238c53af7808cd8b9e322285e657fedb7
parent 235142 8caf11065ad1501c97537017520c339cf9fb74a3
child 235144 3b3570efe52e3ac8aa956c73441bd4dcd0137d5b
push id57353
push userkwierso@gmail.com
push dateMon, 23 Mar 2015 23:51:33 +0000
treeherdermozilla-inbound@7f5abc27fd53 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswcosta
bugs1146218
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1146218 - Harden taskcluster platform parser r=wcosta
testing/taskcluster/taskcluster_graph/try_test_parser.py
testing/taskcluster/tests/test_try_test_parser.py
--- a/testing/taskcluster/taskcluster_graph/try_test_parser.py
+++ b/testing/taskcluster/taskcluster_graph/try_test_parser.py
@@ -12,16 +12,18 @@ def parse_test_opts(input_str):
     token = ''
     in_platforms = False
 
     def add_test(value):
         cur_test['test'] = value.strip()
         tests.insert(0, cur_test)
 
     def add_platform(value):
+        # Ensure platforms exists...
+        cur_test['platforms'] = cur_test.get('platforms', [])
         cur_test['platforms'].insert(0, value.strip())
 
     # This might be somewhat confusing but we parse the string _backwards_ so
     # there is no ambiguity over what state we are in.
     for char in reversed(input_str):
 
         # , indicates exiting a state
         if char == ',':
@@ -40,17 +42,16 @@ def parse_test_opts(input_str):
         elif char == '[':
             # Exiting platform state entering test state.
             add_platform(token)
             token = ''
             in_platforms = False
         elif char == ']':
             # Entering platform state.
             in_platforms = True
-            cur_test['platforms'] = []
         else:
             # Accumulator.
             token = char + token
 
     # Handle any left over tokens.
     if token:
         add_test(token)
 
--- a/testing/taskcluster/tests/test_try_test_parser.py
+++ b/testing/taskcluster/tests/test_try_test_parser.py
@@ -25,15 +25,27 @@ class TryTestParserTest(unittest.TestCas
                 { 'test': 'bar', 'platforms': ['b'] },
                 { 'test': 'baz' },
                 { 'test': 'qux', 'platforms': ['z'] },
                 { 'test': 'a' }
             ]
         )
 
         self.assertEquals(
+            parse_test_opts('mochitest-3[Ubuntu,10.6,10.8,Windows XP,Windows 7,Windows 8]'),
+            [
+                {
+                    'test': 'mochitest-3',
+                    'platforms': [
+                        'Ubuntu', '10.6', '10.8', 'Windows XP', 'Windows 7', 'Windows 8'
+                    ]
+                }
+            ]
+        )
+
+        self.assertEquals(
             parse_test_opts(''),
             []
         )
 
 if __name__ == '__main__':
     mozunit.main()