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

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: Make the apptest runner work. 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/gtest.py b/mojo/tools/mopy/dart_apptest.py
similarity index 50%
copy from mojo/tools/mopy/gtest.py
copy to mojo/tools/mopy/dart_apptest.py
index 4663c729a14315134003684bc7295a4663a6fe18..dc4cda722150fcb700d97a85a54e534ca51e8fd9 100644
--- a/mojo/tools/mopy/gtest.py
+++ b/mojo/tools/mopy/dart_apptest.py
@@ -10,20 +10,11 @@ import sys
_logging = logging.getLogger()
-from mopy import android
from mopy.config import Config
from mopy.paths import Paths
from mopy.print_process_error import print_process_error
-def set_color():
- """Run gtests with color if we're on a TTY (and we're not being told
- explicitly what to do)."""
- if sys.stdout.isatty() and "GTEST_COLOR" not in os.environ:
- _logging.debug("Setting GTEST_COLOR=yes")
- os.environ["GTEST_COLOR"] = "yes"
-
-
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.
@@ -36,11 +27,8 @@ def run_test(config, shell_args, apps_and_args=None, run_launcher=False):
"""
apps_and_args = apps_and_args or {}
output = _try_run_test(config, shell_args, apps_and_args, run_launcher)
- # Fail on output with gtest's "[ FAILED ]" or a lack of "[ PASSED ]".
- # 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("[ FAILED ]") != -1 or output.find("[ PASSED ]") == -1)):
+ # Fail on output with dart unittests' "FAIL:"
+ if (output is None or output.find("FAIL:") != -1):
msw 2015/03/04 00:49:50 This should fail on lack of "PASS:" or w/e. The GT
print "Failed test:"
print_process_error(
_build_command_line(config, shell_args, apps_and_args, run_launcher),
@@ -50,30 +38,6 @@ def run_test(config, shell_args, apps_and_args=None, run_launcher=False):
return True
-def get_fixtures(config, shell_args, apptest):
- """Returns the "Test.Fixture" list from an apptest using mojo_shell.
-
- Tests are listed by running the given apptest in mojo_shell and passing
- --gtest_list_tests. The output is parsed and reformatted into a list like
- [TestSuite.TestFixture, ... ]
- An empty list is returned on failure, with errors logged.
-
- Args:
- config: The mopy.config.Config object for the build.
- apptest: The URL of the test application to run.
- """
- try:
- apps_and_args = {apptest: ["--gtest_list_tests"]}
- list_output = _run_test(config, shell_args, apps_and_args)
- _logging.debug("Tests listed:\n%s" % list_output)
- return _gtest_list_tests(list_output)
- except Exception as e:
- print "Failed to get test fixtures:"
- print_process_error(
- _build_command_line(config, shell_args, apps_and_args), e)
- return []
-
-
def build_shell_arguments(shell_args, apps_and_args=None):
"""Build the list of arguments for the shell. |shell_args| are the base
arguments, |apps_and_args| is a dictionary that associates each application to
@@ -105,24 +69,11 @@ def _build_command_line(config, shell_args, apps_and_args, run_launcher=False):
shell_args, apps_and_args)]))
-def _run_test_android(shell_args, apps_and_args):
- """Run the given test on the single/default android device."""
- (r, w) = os.pipe()
- with os.fdopen(r, "r") as rf:
- with os.fdopen(w, "w") as wf:
- arguments = build_shell_arguments(shell_args, apps_and_args)
- android.StartShell(arguments, wf, wf.close)
- return rf.read()
-
-
def _run_test(config, shell_args, apps_and_args, run_launcher=False):
"""Run the given test, using mojo_launcher if |run_launcher| is True."""
- if (config.target_os == Config.OS_ANDROID):
- return _run_test_android(shell_args, apps_and_args)
- else:
- executable = _get_shell_executable(config, run_launcher)
- command = ([executable] + build_shell_arguments(shell_args, apps_and_args))
- return subprocess.check_output(command, stderr=subprocess.STDOUT)
+ executable = _get_shell_executable(config, run_launcher)
+ command = ([executable] + build_shell_arguments(shell_args, apps_and_args))
+ return subprocess.check_output(command, stderr=subprocess.STDOUT)
def _try_run_test(config, shell_args, apps_and_args, run_launcher):
@@ -135,29 +86,3 @@ def _try_run_test(config, shell_args, apps_and_args, run_launcher):
except Exception as e:
print_process_error(command_line, e)
return None
-
-
-def _gtest_list_tests(gtest_list_tests_output):
- """Returns a list of strings formatted as TestSuite.TestFixture from the
- output of running --gtest_list_tests on a GTEST application."""
-
- # Remove log lines.
- gtest_list_tests_output = (
- re.sub("^\[.*\n", "", gtest_list_tests_output, flags=re.MULTILINE))
-
- if not re.match("^(\w*\.\r?\n( \w*\r?\n)+)+", gtest_list_tests_output):
- raise Exception("Unrecognized --gtest_list_tests output:\n%s" %
- gtest_list_tests_output)
-
- output_lines = gtest_list_tests_output.split("\n")
-
- test_list = []
- for line in output_lines:
- if not line:
- continue
- if line[0] != " ":
- suite = line.strip()
- continue
- test_list.append(suite + line.strip())
-
- return test_list
« mojo/tools/data/apptests ('K') | « mojo/tools/data/apptests ('k') | services/dart/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698