Bug 1227367 - Test exit codes in marionette-client runtests.cli; r=automatedtester a=test-only
authorMaja Frydrychowicz <mjzffr@gmail.com>
Thu, 31 Mar 2016 00:37:19 -0400
changeset 324089 e6fa8f2ec11c0bf1fddfb05477181b7f34264783
parent 324088 f5bf1f129e87d478ec8d03f8e34d6d47fc1aee4d
child 324090 87d6d3fa59cff319f197c5773be6b097e8438173
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersautomatedtester, test-only
bugs1227367
milestone47.0a2
Bug 1227367 - Test exit codes in marionette-client runtests.cli; r=automatedtester a=test-only Initial tests for the Marionette Python runner/harness. MozReview-Commit-ID: 9KSSOOmpzUF
testing/marionette/harness/marionette/tests/harness_unit/test_marionette_runner.py
new file mode 100644
--- /dev/null
+++ b/testing/marionette/harness/marionette/tests/harness_unit/test_marionette_runner.py
@@ -0,0 +1,32 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+import pytest
+
+from marionette import runtests
+
+@pytest.fixture
+def harness_class(request):
+    failures = request.getfuncargvalue('num_failures')
+
+    class Harness(object):
+        def __init__(*args, **kwargs):
+            pass
+
+        def run(*args, **kwargs):
+            if failures is None:
+                raise Exception
+            else:
+                return failures
+
+    return Harness
+
+
+@pytest.mark.parametrize(
+    "num_failures,exit_code",
+    [(0, 0), (1, 10), (None, 1)],
+)
+def test_cli_exit_code(num_failures, exit_code, harness_class):
+    with pytest.raises(SystemExit) as err:
+        runtests.cli(harness_class=harness_class)
+    assert err.value.code == exit_code