Bug 1284238 - Test that manifest tests are filtered with correct settings; r=maja_zf
authorAnjana Vakil <anjanavakil@gmail.com>
Thu, 08 Sep 2016 14:20:28 +0200
changeset 354496 c0804fb00f7043440e9a317b5f5bca7660ab1440
parent 354495 f58548c8be5435349920d00eebce9d471c118ee4
child 354497 5d854c8d076533b9426bc3040979ccf8e0b2404b
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf
bugs1284238
milestone51.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 1284238 - Test that manifest tests are filtered with correct settings; r=maja_zf Add tests to ensure that the arguments passed to the call to `manifest.active_tests` from within `runner.add_test` are correct, based on the runner's settings for e.g. e10s and test tags. Add helper function for setup for these tests to avoid duplication. MozReview-Commit-ID: CsaDm7cSyZf
testing/marionette/harness/marionette/tests/harness_unit/test_marionette_runner.py
--- a/testing/marionette/harness/marionette/tests/harness_unit/test_marionette_runner.py
+++ b/testing/marionette/harness/marionette/tests/harness_unit/test_marionette_runner.py
@@ -303,16 +303,52 @@ def test_add_test_manifest(mock_runner, 
             for test in mock_runner.tests:
                 assert test['filepath'].endswith(test['expected'] + '.py')
         else:
             pytest.raises(IOError, "mock_runner.add_test(manifest_with_tests.filepath)")
     assert manifest_with_tests.manifest_class().read.called
     assert manifest_with_tests.manifest_class().active_tests.called
 
 
+def get_kwargs_passed_to_manifest(mock_runner, manifest, monkeypatch, **kwargs):
+    '''Helper function for test_manifest_* tests.
+    Returns the kwargs passed to the call to manifest.active_tests.'''
+    monkeypatch.setattr('marionette.runner.base.TestManifest', manifest.manifest_class)
+    monkeypatch.setattr('marionette.runner.base.mozinfo.info', {'mozinfo_key': 'mozinfo_val'})
+    for attr in kwargs:
+        setattr(mock_runner, attr, kwargs[attr])
+    with patch('marionette.runner.base.os.path.exists', return_value=True):
+        mock_runner.add_test(manifest.filepath)
+    call_args, call_kwargs = manifest.manifest_class().active_tests.call_args
+    return call_kwargs
+
+
+def test_manifest_basic_args(mock_runner, manifest, monkeypatch):
+    kwargs = get_kwargs_passed_to_manifest(mock_runner, manifest, monkeypatch)
+    assert kwargs['exists'] is False
+    assert kwargs['disabled'] is True
+    assert kwargs['app'] == 'fake_app'
+    assert 'mozinfo_key' in kwargs and kwargs['mozinfo_key'] == 'mozinfo_val'
+
+
+@pytest.mark.parametrize('e10s', (True, False))
+def test_manifest_with_e10s(mock_runner, manifest, monkeypatch, e10s):
+    kwargs = get_kwargs_passed_to_manifest(mock_runner, manifest, monkeypatch, e10s=e10s)
+    assert kwargs['e10s'] == e10s
+
+
+@pytest.mark.parametrize('test_tags', (None, ['tag', 'tag2']))
+def test_manifest_with_test_tags(mock_runner, manifest, monkeypatch, test_tags):
+    kwargs = get_kwargs_passed_to_manifest(mock_runner, manifest, monkeypatch, test_tags=test_tags)
+    if test_tags is None:
+        assert kwargs['filters'] == []
+    else:
+        assert len(kwargs['filters']) == 1 and kwargs['filters'][0].tags == test_tags
+
+
 def test_cleanup_with_manifest(mock_runner, manifest_with_tests, monkeypatch):
     monkeypatch.setattr('marionette.runner.base.TestManifest', manifest_with_tests.manifest_class)
     if manifest_with_tests.n_enabled > 0:
         context = patch('marionette.runner.base.os.path.exists', return_value=True)
     else:
         context = pytest.raises(Exception)
     with context:
         mock_runner.run_tests([manifest_with_tests.filepath])