Bug 1491097 - Add utils unit test; r=ahal
authorRob Wood <rwood@mozilla.com>
Wed, 28 Nov 2018 18:44:02 +0000
changeset 509188 310c63548b11d71fd4737e40efa1b02ae47e5366
parent 509187 31af9d535ba638fda58a3720ec543f51c2ee7470
child 509189 6c185cbc16ecd264634a37aa2c93c4fcc9bb8f53
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)
reviewersahal
bugs1491097
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 1491097 - Add utils unit test; r=ahal Differential Revision: https://phabricator.services.mozilla.com/D13153
testing/raptor/test/python.ini
testing/raptor/test/test_utils.py
--- a/testing/raptor/test/python.ini
+++ b/testing/raptor/test/python.ini
@@ -1,9 +1,10 @@
 [DEFAULT]
 subsuite = raptor
 skip-if = python == 3
 
 [test_cmdline.py]
 [test_manifest.py]
 [test_control_server.py]
+[test_utils.py]
 [test_playback.py]
 [test_raptor.py]
new file mode 100644
--- /dev/null
+++ b/testing/raptor/test/test_utils.py
@@ -0,0 +1,48 @@
+from __future__ import absolute_import, unicode_literals
+
+import mozunit
+import os
+import pytest
+import sys
+
+# need this so raptor imports work both from /raptor and via mach
+here = os.path.abspath(os.path.dirname(__file__))
+if os.environ.get('SCRIPTSPATH', None) is not None:
+    # in production it is env SCRIPTS_PATH
+    mozharness_dir = os.environ['SCRIPTSPATH']
+else:
+    # locally it's in source tree
+    mozharness_dir = os.path.join(here, '../../mozharness')
+sys.path.insert(1, mozharness_dir)
+
+raptor_dir = os.path.join(os.path.dirname(here), 'raptor')
+sys.path.insert(0, raptor_dir)
+
+from utils import transform_platform
+
+
+@pytest.mark.parametrize('platform', ['win', 'mac', 'linux64'])
+def test_transform_platform(platform):
+    transformed = transform_platform("mitmproxy-rel-bin-{platform}.manifest", platform)
+    assert "{platform}" not in transformed
+    if platform == 'mac':
+        assert "osx" in transformed
+    else:
+        assert platform in transformed
+
+
+def test_transform_platform_no_change():
+    starting_string = "nothing-in-here-to-transform"
+    assert transform_platform(starting_string, 'mac') == starting_string
+
+
+@pytest.mark.parametrize('processor', ['x86_64', 'other'])
+def test_transform_platform_processor(processor):
+    transformed = transform_platform("string-with-processor-{x64}.manifest", 'win', processor)
+    assert "{x64}" not in transformed
+    if processor == 'x86_64':
+        assert "_x64" in transformed
+
+
+if __name__ == '__main__':
+    mozunit.main()