Bug 1227367 - Test exit codes in marionette-client runtests.cli; r=automatedtester
authorMaja Frydrychowicz <mjzffr@gmail.com>
Thu, 31 Mar 2016 00:37:19 -0400
changeset 347777 f115c16a2ce2a9f83a4bc5d47ad751dc1c13cffb
parent 347776 e51b27b501f4db49da2ae2cee87480628a211513
child 347778 1e0b4e27bd511fab8d60a64719a49e65c526c239
push id14654
push userbmo:rail@mozilla.com
push dateTue, 05 Apr 2016 19:30:33 +0000
reviewersautomatedtester
bugs1227367
milestone48.0a1
Bug 1227367 - Test exit codes in marionette-client runtests.cli; r=automatedtester 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