示例#1
0
    def get_launch_command(self, test_app, out_dir, destination, shards=1):
        """Returns the command that can be used to launch the test app.

    Args:
      test_app: An app that stores data about test required to run.
      out_dir: (str) A path for results.
      destination: (str) A destination of device/simulator.
      shards: (int) How many shards the tests should be divided into.

    Returns:
      A list of strings forming the command to launch the test.
    """
        # TODO(crbug.com/1085603): Remove self.xctest_path check when device unit
        # tests have xctest in configs.
        if self.xctest_path or self.xctest:
            return test_app.command(out_dir, destination, shards)

        cmd = [
            'idevice-app-runner',
            '--udid',
            self.udid,
            '--start',
            self.cfbundleid,
        ]
        args = []
        gtest_filter = []
        kif_filter = []

        if test_app.included_tests:
            kif_filter = test_apps.get_kif_test_filter(test_app.included_tests,
                                                       invert=False)
            gtest_filter = test_apps.get_gtest_filter(test_app.included_tests,
                                                      invert=False)
        elif test_app.excluded_tests:
            kif_filter = test_apps.get_kif_test_filter(test_app.excluded_tests,
                                                       invert=True)
            gtest_filter = test_apps.get_gtest_filter(test_app.excluded_tests,
                                                      invert=True)

        if kif_filter:
            cmd.extend(['-D', 'GKIF_SCENARIO_FILTER=%s' % kif_filter])
        if gtest_filter:
            args.append('--gtest_filter=%s' % gtest_filter)

        for env_var in self.env_vars:
            cmd.extend(['-D', env_var])

        if args or self.test_args:
            cmd.append('--args')
            cmd.extend(self.test_args)
            cmd.extend(args)

        return cmd
示例#2
0
    def test_correct(self):
        """Ensures correctness of filter."""
        tests = [
            'test.1',
            'test.2',
        ]
        expected = 'test.1:test.2'

        self.assertEqual(test_apps.get_gtest_filter(tests), expected)
示例#3
0
  def test_correct_inverted(self):
    """Ensures correctness of inverted filter."""
    tests = [
      'test.1',
      'test.2',
    ]
    expected = '-test.1:test.2'

    self.assertEqual(test_apps.get_gtest_filter(tests, invert=True), expected)