Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Unified Diff: mojo/tools/mopy/dart_apptest.py

Issue 971083002: Create an apptesting framework for dart. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: msw comments Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/tools/mopy/dart_apptest.py
diff --git a/mojo/tools/mopy/dart_apptest.py b/mojo/tools/mopy/dart_apptest.py
new file mode 100644
index 0000000000000000000000000000000000000000..14a36aaf8f6253886d26dceaa0146f73e09cf3c1
--- /dev/null
+++ b/mojo/tools/mopy/dart_apptest.py
@@ -0,0 +1,46 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import logging
+import os
msw 2015/03/04 21:04:32 nit: not needed
+import re
msw 2015/03/04 21:04:32 nit: not needed
+import subprocess
msw 2015/03/04 21:04:32 nit: not needed
+import sys
msw 2015/03/04 21:04:32 nit: not needed
+
+_logging = logging.getLogger()
+
+from mopy import test_util
+from mopy.config import Config
+from mopy.paths import Paths
msw 2015/03/04 21:04:32 nit: not needed
+from mopy.print_process_error import print_process_error
+
+
+def run_test(config, shell_args, apps_and_args=None, run_launcher=False):
+ """Runs a command line and checks the output for signs of gtest failure.
+
+ Args:
+ config: The mopy.config.Config object for the build.
+ shell_args: The arguments for mojo_shell.
+ apps_and_args: A Dict keyed by application URL associated to the
+ application's specific arguments.
+ run_launcher: |True| is mojo_launcher must be used instead of mojo_shell.
+ """
+ apps_and_args = apps_and_args or {}
+ output = test_util.try_run_test(config, shell_args, apps_and_args,
+ run_launcher)
+ # Fail on output with dart unittests' "FAIL:" or a lack of "PASS:".
+ # The latter condition ensures failure on broken command lines or output.
+ # Check output instead of exit codes because mojo_shell always exits with 0.
+ if (output is None or
+ output.find("FAIL:") != -1 or
msw 2015/03/04 21:04:32 nit: maybe test_util could just have pass and fail
+ output.find("PASS:") == -1):
+ print "Failed test:"
+ print_process_error(
+ test_util.build_command_line(config, shell_args, apps_and_args,
+ run_launcher),
+ output)
+ return False
+ _logging.debug("Succeeded with output:\n%s" % output)
+ return True
+

Powered by Google App Engine
This is Rietveld 408576698