Bug 1517270 - Add pageload measurement types to --print-tests output; r=rwood
authorDave Hunt <dhunt@mozilla.com>
Fri, 04 Jan 2019 17:04:27 +0000
changeset 509733 689de183c7619741db70d37451e2cd2655909ba4
parent 509732 64ae1fbfe96463284ad62bc0bbf42e9828e7e21f
child 509738 ab2bdfc3132a2f88658b554ca12fae9fd2977928
child 509739 12cbaacf5a6c5bc2018f4bf52c8c9c37b3757a2e
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrwood
bugs1517270
milestone66.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 1517270 - Add pageload measurement types to --print-tests output; r=rwood Differential Revision: https://phabricator.services.mozilla.com/D15642
testing/raptor/raptor/cmdline.py
testing/raptor/test/python.ini
testing/raptor/test/test_print_tests.py
--- a/testing/raptor/raptor/cmdline.py
+++ b/testing/raptor/raptor/cmdline.py
@@ -150,17 +150,21 @@ class _PrintTests(_StopAction):
                 if suite not in test_list:
                     test_list[suite] = {'type': None, 'subtests': []}
 
                 # for page-load tests we want to list every subtest, so we
                 # can see which pages are available in which tp6-* sets
                 if next_test.get("type", None) is not None:
                     test_list[suite]['type'] = next_test['type']
                     if next_test['type'] == "pageload":
-                        test_list[suite]['subtests'].append(next_test['name'])
+                        subtest = next_test['name']
+                        measure = next_test.get("measure")
+                        if measure is not None:
+                            subtest = "{0} ({1})".format(subtest, measure)
+                        test_list[suite]['subtests'].append(subtest)
 
             # print the list in a nice readable format
             for key in sorted(test_list.iterkeys()):
                 print("\n%s" % key)
                 print("  type: %s" % test_list[key]['type'])
                 if len(test_list[key]['subtests']) != 0:
                     print("  subtests:")
                     for _sub in sorted(test_list[key]['subtests']):
--- a/testing/raptor/test/python.ini
+++ b/testing/raptor/test/python.ini
@@ -2,9 +2,10 @@
 subsuite = raptor
 skip-if = python == 3
 
 [test_cmdline.py]
 [test_manifest.py]
 [test_control_server.py]
 [test_utils.py]
 [test_playback.py]
+[test_print_tests.py]
 [test_raptor.py]
new file mode 100644
--- /dev/null
+++ b/testing/raptor/test/test_print_tests.py
@@ -0,0 +1,45 @@
+import os
+
+import mozunit
+import pytest
+
+from raptor import cmdline
+
+
+def test_pageload_subtests(capsys, monkeypatch, tmpdir):
+    # cmdline.py is hard-coded to use raptor.ini from the same directory so we need
+    # to monkey patch os.dirname, which is not ideal. If we could make --print-tests
+    # respect the --test path that would be much better.
+    def mock(path):
+        return str(tmpdir)
+    monkeypatch.setattr(os.path, "dirname", mock)
+    manifest = tmpdir.join("raptor.ini")
+    manifest.write("""
+[DEFAULT]
+type = pageload
+apps = firefox
+
+[raptor-subtest-1]
+measure = foo, bar
+
+[raptor-subtest-2]
+""")
+    with pytest.raises(SystemExit):
+        cmdline.parse_args(["--print-tests"])
+    captured = capsys.readouterr()
+    assert captured.out == """
+Raptor Tests Available for Firefox Desktop
+==========================================
+
+raptor
+  type: pageload
+  subtests:
+    raptor-subtest-1 (foo, bar)
+    raptor-subtest-2
+
+Done.
+"""
+
+
+if __name__ == '__main__':
+    mozunit.main()