Пример #1
0
  def test_xvfb(self):
    args = ['xvfb-run', '--auto-servernum', '--server-args',
            '-screen 0 640x480x24',
            '--error-file', '/some/output.log', '/bin/sh', 'launch_chrome',
            'run', 'this-app.apk', '--with-this-option']
    self.assertTrue(launch_chrome_util.is_launch_chrome_command(args))
    self.assertEqual(['run', 'this-app.apk', '--with-this-option'],
                     launch_chrome_util.remove_leading_launch_chrome_args(args))

    args = ['xvfb-run', '--auto-servernum', '--server-args',
            '-screen 0 640x480x24',
            '--error-file', '/some/output.log', 'do-something-else']
    self.assertFalse(launch_chrome_util.is_launch_chrome_command(args))
Пример #2
0
    def test_xvfb(self):
        args = [
            'xvfb-run', '--auto-servernum', '--server-args',
            '-screen 0 640x480x24', '--error-file', '/some/output.log',
            '/bin/sh', 'launch_chrome', 'run', 'this-app.apk',
            '--with-this-option'
        ]
        self.assertTrue(launch_chrome_util.is_launch_chrome_command(args))
        self.assertEqual(
            ['run', 'this-app.apk', '--with-this-option'],
            launch_chrome_util.remove_leading_launch_chrome_args(args))

        args = [
            'xvfb-run', '--auto-servernum', '--server-args',
            '-screen 0 640x480x24', '--error-file', '/some/output.log',
            'do-something-else'
        ]
        self.assertFalse(launch_chrome_util.is_launch_chrome_command(args))
Пример #3
0
  def run_subprocess_test(self, scoreboard, test_name, command, env=None):
    """Runs a test which runs subprocess and sets status appropriately.

    - test_name: The name of this test. This should be
      'test_fixter#test_method' style.
    - command: A list of strings. Command line to run subprocess.
    - env: Environment dict for the subprocess. Maybe None.
    """
    assert not launch_chrome_util.is_launch_chrome_command(command), (
        'For testing with ./launch_chrome, you should use run_subprocess() '
        'method instead.: %s' % str(command))

    scoreboard.start_test(test_name)
    try:
      self.run_subprocess(command, env=env)
      status = test_method_result.TestMethodResult.PASS
    except subprocess.CalledProcessError:
      status = test_method_result.TestMethodResult.FAIL
    result = test_method_result.TestMethodResult(test_name, status)
    scoreboard.update([result])
Пример #4
0
  def _write_args_if_needed(self, args):
    """Writes args to a file if it is too long and returns a new args."""
    # Do not rewrite args of the commands other than launch_chrome because
    # the commands do not necessarily support the syntax of reading arguments
    # from a file.
    if not launch_chrome_util.is_launch_chrome_command(args):
      return args
    remaining_args = launch_chrome_util.remove_leading_launch_chrome_args(args)
    args_string = '\n'.join(remaining_args)
    # Do not rewrite args to file if the argument list is short enough.
    if len(args_string) < SuiteRunnerBase.WRITE_ARGS_MIN_LENGTH:
      return args

    args_dir = os.path.join(build_common.get_build_dir(), 'integration_tests')
    file_util.makedirs_safely(args_dir)

    args_file = os.path.join(args_dir, self._name + '_args')
    with open(args_file, 'w') as f:
      f.write(args_string)
    return args[:-len(remaining_args)] + ['@' + args_file]
Пример #5
0
    def run_subprocess_test(self, scoreboard, test_name, command, env=None):
        """Runs a test which runs subprocess and sets status appropriately.

    - test_name: The name of this test. This should be
      'test_fixter#test_method' style.
    - command: A list of strings. Command line to run subprocess.
    - env: Environment dict for the subprocess. Maybe None.
    """
        assert not launch_chrome_util.is_launch_chrome_command(command), (
            'For testing with ./launch_chrome, you should use run_subprocess() '
            'method instead.: %s' % str(command))

        scoreboard.start_test(test_name)
        try:
            self.run_subprocess(command, env=env)
            status = test_method_result.TestMethodResult.PASS
        except subprocess.CalledProcessError:
            status = test_method_result.TestMethodResult.FAIL
        result = test_method_result.TestMethodResult(test_name, status)
        scoreboard.update([result])
Пример #6
0
    def _write_args_if_needed(self, args):
        """Writes args to a file if it is too long and returns a new args."""
        # Do not rewrite args of the commands other than launch_chrome because
        # the commands do not necessarily support the syntax of reading arguments
        # from a file.
        if not launch_chrome_util.is_launch_chrome_command(args):
            return args
        remaining_args = launch_chrome_util.remove_leading_launch_chrome_args(
            args)
        args_string = '\n'.join(remaining_args)
        # Do not rewrite args to file if the argument list is short enough.
        if len(args_string) < SuiteRunnerBase.WRITE_ARGS_MIN_LENGTH:
            return args

        args_dir = os.path.join(build_common.get_build_dir(),
                                'integration_tests')
        file_util.makedirs_safely(args_dir)

        args_file = os.path.join(args_dir, self._name + '_args')
        with open(args_file, 'w') as f:
            f.write(args_string)
        return args[:-len(remaining_args)] + ['@' + args_file]
Пример #7
0
 def test_not_launch_chrome(self):
     args = ['gcc', '-c', 'whatever']
     self.assertFalse(launch_chrome_util.is_launch_chrome_command(args))
Пример #8
0
 def test_normal(self):
     args = ['/bin/sh', 'launch_chrome', 'run', 'whatever']
     self.assertTrue(launch_chrome_util.is_launch_chrome_command(args))
     self.assertEqual(
         ['run', 'whatever'],
         launch_chrome_util.remove_leading_launch_chrome_args(args))
Пример #9
0
 def test_not_launch_chrome(self):
   args = ['gcc', '-c', 'whatever']
   self.assertFalse(launch_chrome_util.is_launch_chrome_command(args))
Пример #10
0
 def test_normal(self):
   args = ['/bin/sh', 'launch_chrome', 'run', 'whatever']
   self.assertTrue(launch_chrome_util.is_launch_chrome_command(args))
   self.assertEqual(['run', 'whatever'],
                    launch_chrome_util.remove_leading_launch_chrome_args(args))