Bug 1538201 - Correctly extract subtest_lower_is_better value r=rwood
authorIonut Goldan <igoldan@mozilla.com>
Wed, 03 Apr 2019 20:07:38 +0000
changeset 467928 4fc66ecdfa1633868673913533d23f0ef377da4f
parent 467927 f7f603959f6cc3fecc7984d808f1829c3293be8a
child 467929 65082301659031124bb713ea8ae547abbc6681ee
push id112667
push useraiakab@mozilla.com
push dateThu, 04 Apr 2019 16:12:45 +0000
treeherdermozilla-inbound@230bb363f2f3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrwood
bugs1538201
milestone68.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 1538201 - Correctly extract subtest_lower_is_better value r=rwood Differential Revision: https://phabricator.services.mozilla.com/D25781
testing/raptor/raptor/manifest.py
--- a/testing/raptor/raptor/manifest.py
+++ b/testing/raptor/raptor/manifest.py
@@ -129,30 +129,31 @@ def write_test_settings_json(args, test_
             # alert_on was already converted to list above
             test_settings['raptor-options']['alert_on'] = test_details['alert_on']
 
     if test_details.get("page_timeout", None) is not None:
         test_settings['raptor-options']['page_timeout'] = int(test_details['page_timeout'])
 
     test_settings['raptor-options']['unit'] = test_details.get("unit", "ms")
 
-    if test_details.get("lower_is_better", "true") == "false":
-        test_settings['raptor-options']['lower_is_better'] = False
-    else:
-        test_settings['raptor-options']['lower_is_better'] = True
+    test_settings['raptor-options']['lower_is_better'] = bool_from_str(
+        test_details.get("lower_is_better", "true"))
 
-    # support optional subtest unit/lower_is_better fields, default to main test values if not set
+    # support optional subtest unit/lower_is_better fields
     val = test_details.get('subtest_unit', test_settings['raptor-options']['unit'])
     test_settings['raptor-options']['subtest_unit'] = val
-    val = test_details.get('subtest_lower_is_better',
-                           test_settings['raptor-options']['lower_is_better'])
-    if val == "false":
-        test_settings['raptor-options']['subtest_lower_is_better'] = False
+    subtest_lower_is_better = test_details.get('subtest_lower_is_better', None)
+
+    if subtest_lower_is_better is None:
+        # default to main test values if not set
+        test_settings['raptor-options']['subtest_lower_is_better'] = (
+            test_settings['raptor-options']['lower_is_better'])
     else:
-        test_settings['raptor-options']['subtest_lower_is_better'] = True
+        test_settings['raptor-options']['subtest_lower_is_better'] = bool_from_str(
+            subtest_lower_is_better)
 
     if test_details.get("alert_threshold", None) is not None:
         test_settings['raptor-options']['alert_threshold'] = float(test_details['alert_threshold'])
 
     if test_details.get("screen_capture", None) is not None:
         test_settings['raptor-options']['screen_capture'] = test_details.get("screen_capture")
 
     # if gecko profiling is enabled, write profiling settings for webext
@@ -304,8 +305,17 @@ def get_raptor_test_list(args, oskey):
             else:
                 # test doesn't have valid settings, remove it from available list
                 LOG.info("test %s is not valid due to missing settings" % test['name'])
                 tests_to_run.remove(test)
     else:
         LOG.critical("abort: specified test name doesn't exist")
 
     return tests_to_run
+
+
+def bool_from_str(boolean_string):
+    if boolean_string == 'true':
+        return True
+    elif boolean_string == 'false':
+        return False
+    else:
+        raise ValueError("Expected either 'true' or 'false'")