Exemple #1
0
def run_test(config, shell_args, apps_and_args=None, context=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.
    context: Platform specific context. See |mopy.{platform}.Context|.
    run_launcher: |True| is mojo_launcher must be used instead of mojo_shell.
  """
  apps_and_args = apps_and_args or {}
  output = _try_run_test(
      config, shell_args, apps_and_args, context, 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)):
    print "Failed test:"
    print_process_error(
        _build_command_line(config, shell_args, apps_and_args, run_launcher),
        output)
    return False
  _logging.debug("Succeeded with output:\n%s" % output)
  return True
Exemple #2
0
def run_test(config, shell, apptest_dict, shell_args, apps_and_args=None):
  """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.
  """
  apps_and_args = apps_and_args or {}
  output = test_util.try_run_test(config, shell, shell_args, apps_and_args)
  # Fail on output with dart unittests' "FAIL:"/"ERROR:" or a lack of "PASS:"******"Failed test:"
    print_process_error(
        test_util.build_command_line(config, shell_args, apps_and_args),
        output)
    return "Failed test(s) in %r" % apptest_dict
  _logging.debug("Succeeded with output:\n%s" % output)
  return "Succeeded"
def try_run_test(config, shell, shell_args, apps_and_args):
  """Returns the output of a command line or an empty string on error."""
  command_line = build_command_line(config, shell_args, apps_and_args)
  _logger.debug("Running command line: %s" % command_line)
  try:
    return run_test(config, shell, shell_args, apps_and_args)
  except Exception as e:
    print_process_error(command_line, e)
  return None
Exemple #4
0
def try_run_test(config, shell, shell_args, apps_and_args):
    """Returns the output of a command line or an empty string on error."""
    command_line = build_command_line(config, shell_args, apps_and_args)
    _logger.debug("Running command line: %s" % command_line)
    try:
        return run_test(config, shell, shell_args, apps_and_args)
    except Exception as e:
        print_process_error(command_line, e)
    return None
Exemple #5
0
def _try_run_test(config, shell_args, apps_and_args, context, run_launcher):
  """Returns the output of a command line or an empty string on error."""
  command_line = _build_command_line(config, shell_args, apps_and_args,
                                     run_launcher=run_launcher)
  _logging.debug("Running command line: %s" % command_line)
  try:
    return _run_test(config, shell_args, apps_and_args, context, run_launcher)
  except Exception as e:
    print_process_error(command_line, e)
  return None
Exemple #6
0
def get_fixtures(config, shell, 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 = test_util.run_test(config, shell, shell_args, apps_and_args)
    _logger.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(
        test_util.build_command_line(config, shell_args, apps_and_args), e)
  return []
Exemple #7
0
def get_fixtures(config, shell, 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 = test_util.run_test(config, shell, shell_args,
                                         apps_and_args)
        _logger.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(
            test_util.build_command_line(config, shell_args, apps_and_args), e)
    return []