示例#1
0
    def fill_xctest_run(self, egtests_app):
        """Fills xctestrun file by egtests.

    Args:
      egtests_app: (EgtestsApp) An Egetsts_app to run.

    Returns:
      A path to xctestrun file.

    Raises:
      AppNotFoundError if egtests is empty.
    """
        if not egtests_app:
            raise test_runner.AppNotFoundError('Egtests is not found!')
        xctestrun = os.path.join(
            os.path.abspath(os.path.join(self.out_dir, os.pardir)),
            'run_%d.xctestrun' % int(time.time()))
        if not os.path.exists(xctestrun):
            with open(xctestrun, 'w'):
                pass
        # Creates a dict with data about egtests to run - fill all required fields:
        # egtests_module, egtest_app_path, egtests_xctest_path and
        # filtered tests if filter is specified.
        # Write data in temp xctest run file.
        plistlib.writePlist(egtests_app.xctestrun_node(), xctestrun)
        return xctestrun
示例#2
0
    def __init__(self,
                 egtests_app,
                 filtered_tests=None,
                 invert=False,
                 test_args=None,
                 env_vars=None,
                 host_app_path=None):
        """Initialize Egtests.

    Args:
      egtests_app: (str) full path to egtests app.
      filtered_tests: (list) Specific tests to run
        (it can inclusive/exclusive based on invert parameter).
         E.g.
          [ 'TestCaseClass1/testMethod1', 'TestCaseClass2/testMethod2']
      invert: type of filter(True - inclusive, False - exclusive).
      test_args: List of strings to pass as arguments to the test when
        launching.
      env_vars: List of environment variables to pass to the test itself.
      host_app_path: (str) full path to host app.

    Raises:
      AppNotFoundError: If the given app does not exist
    """
        if not os.path.exists(egtests_app):
            raise test_runner.AppNotFoundError(egtests_app)
        self.egtests_path = egtests_app
        self.project_path = os.path.dirname(self.egtests_path)
        self.module_name = os.path.splitext(os.path.basename(egtests_app))[0]
        self.filter = filtered_tests
        self.invert = invert
        self.test_args = test_args
        self.env_vars = env_vars
        self.host_app_path = host_app_path
    def __init__(self,
                 egtests_app,
                 included_tests=None,
                 excluded_tests=None,
                 test_args=None,
                 env_vars=None,
                 host_app_path=None):
        """Initialize Egtests.

    Args:
      egtests_app: (str) full path to egtests app.
      included_tests: (list) Specific tests to run
         E.g.
          [ 'TestCaseClass1/testMethod1', 'TestCaseClass2/testMethod2']
      excluded_tests: (list) Specific tests not to run
         E.g.
          [ 'TestCaseClass1', 'TestCaseClass2/testMethod2']
      test_args: List of strings to pass as arguments to the test when
        launching.
      env_vars: List of environment variables to pass to the test itself.
      host_app_path: (str) full path to host app.

    Raises:
      AppNotFoundError: If the given app does not exist
    """
        if not os.path.exists(egtests_app):
            raise test_runner.AppNotFoundError(egtests_app)
        self.egtests_path = egtests_app
        self.project_path = os.path.dirname(self.egtests_path)
        self.module_name = os.path.splitext(os.path.basename(egtests_app))[0]
        self.included_tests = included_tests or []
        self.excluded_tests = excluded_tests or []
        self.test_args = test_args
        self.env_vars = env_vars
        self.host_app_path = host_app_path
示例#4
0
    def __init__(self,
                 egtests_app,
                 udid,
                 shards,
                 retries,
                 out_dir=os.path.basename(os.getcwd()),
                 use_clang_coverage=False,
                 env=None):
        """Initialize launch command.

    Args:
      egtests_app: (EgtestsApp) An egtests_app to run.
      udid: (str) UDID of a device/simulator.
      shards: (int) A number of shards.
      retries: (int) A number of retries.
      out_dir: (str) A folder in which xcodebuild will generate test output.
        By default it is a current directory.
      env: (dict) Environment variables.

    Raises:
      LaunchCommandCreationError: if one of parameters was not set properly.
    """
        if not isinstance(egtests_app, test_apps.EgtestsApp):
            raise test_runner.AppNotFoundError(
                'Parameter `egtests_app` is not EgtestsApp: %s' % egtests_app)
        self.egtests_app = egtests_app
        self.udid = udid
        self.shards = shards
        self.retries = retries
        self.out_dir = out_dir
        self.logs = collections.OrderedDict()
        self.test_results = collections.OrderedDict()
        self.use_clang_coverage = use_clang_coverage
        self.env = env
        self._log_parser = xcode_log_parser.get_parser()
示例#5
0
    def __init__(self,
                 egtests_app,
                 destination,
                 shards,
                 retries,
                 out_dir=os.path.basename(os.getcwd()),
                 env=None):
        """Initialize launch command.

    Args:
      egtests_app: (EgtestsApp) An egtests_app to run.
      destination: (str) A destination.
      shards: (int) A number of shards.
      retries: (int) A number of retries.
      out_dir: (str) A folder in which xcodebuild will generate test output.
        By default it is a current directory.
      env: (dict) Environment variables.

    Raises:
      LaunchCommandCreationError: if one of parameters was not set properly.
    """
        if not isinstance(egtests_app, EgtestsApp):
            raise test_runner.AppNotFoundError(
                'Parameter `egtests_app` is not EgtestsApp: %s' % egtests_app)
        self.egtests_app = egtests_app
        self.destination = destination
        self.shards = shards
        self.retries = retries
        self.out_dir = out_dir
        self.logs = collections.OrderedDict()
        self.test_results = collections.OrderedDict()
        self.env = env
示例#6
0
    def __init__(self, app_path, host_app_path, iossim_path, replay_path,
                 platform, version, wpr_tools_path, out_dir, **kwargs):
        """Initializes a new instance of this class.

    Args:
      app_path: Path to the compiled .app or .ipa to run.
      host_app_path: A path to the host app for EG2.
      iossim_path: Path to the compiled iossim binary to use.
      replay_path: Path to the folder where WPR replay and recipe files live.
      platform: Name of the platform to simulate. Supported values can be found
        by running "iossim -l". e.g. "iPhone 5s", "iPad Retina".
      version: Version of iOS the platform should be running. Supported values
        can be found by running "iossim -l". e.g. "9.3", "8.2", "7.1".
      wpr_tools_path: Path to pre-installed (from CIPD) WPR-related tools
      out_dir: Directory to emit test data into.
      (Following are potential args in **kwargs)
      env_vars: List of environment variables to pass to the test itself.
      retries: Number of times to retry failed test cases.
      test_args: List of strings to pass as arguments to the test when
        launching.
      test_cases: List of tests to be included in the test run. None or [] to
        include all tests.
      xctest: Whether or not this is an XCTest.

    Raises:
      AppNotFoundError: If the given app does not exist.
      ReplayPathNotFoundError: If the replay path was not found.
      WprToolsNotFoundError: If wpr_tools_path is not specified.
    """
        super(WprProxySimulatorTestRunner,
              self).__init__(app_path, iossim_path, platform, version, out_dir,
                             **kwargs)
        self.host_app_path = None
        if host_app_path is not None and host_app_path != 'NO_PATH':
            self.host_app_path = os.path.abspath(host_app_path)
            if not os.path.exists(self.host_app_path):
                raise test_runner.AppNotFoundError(self.host_app_path)

        self.use_trusted_cert = True

        self.test_attempt_count = {}

        replay_path = os.path.abspath(replay_path)
        if not os.path.exists(replay_path):
            raise ReplayPathNotFoundError(replay_path)
        self.replay_path = replay_path

        if not os.path.exists(wpr_tools_path):
            raise WprToolsNotFoundError(wpr_tools_path)
        self.wpr_tools_path = wpr_tools_path

        self.proxy_process = None
        self.wprgo_process = None
示例#7
0
    def __init__(self,
                 test_app,
                 included_tests=None,
                 excluded_tests=None,
                 test_args=None,
                 env_vars=None,
                 release=False,
                 host_app_path=None,
                 inserted_libs=None):
        """Initialize Egtests.

    Args:
      test_app: (str) full path to egtests app.
      included_tests: (list) Specific tests to run
         E.g.
          [ 'TestCaseClass1/testMethod1', 'TestCaseClass2/testMethod2']
      excluded_tests: (list) Specific tests not to run
         E.g.
          [ 'TestCaseClass1', 'TestCaseClass2/testMethod2']
      test_args: List of strings to pass as arguments to the test when
        launching.
      env_vars: List of environment variables to pass to the test itself.
      release: (bool) Whether the app is release build.
      inserted_libs: List of libraries to insert when running the test.

    Raises:
      AppNotFoundError: If the given app does not exist
    """
        if not os.path.exists(test_app):
            raise test_runner.AppNotFoundError(test_app)
        self.test_app_path = test_app
        self.project_path = os.path.dirname(self.test_app_path)
        self.test_args = test_args or []
        self.env_vars = {}
        for env_var in env_vars or []:
            env_var = env_var.split('=', 1)
            self.env_vars[env_var[0]] = None if len(
                env_var) == 1 else env_var[1]
        self.included_tests = included_tests or []
        self.excluded_tests = excluded_tests or []
        self.disabled_tests = []
        self.module_name = os.path.splitext(os.path.basename(test_app))[0]
        self.release = release
        self.host_app_path = host_app_path
        self.inserted_libs = inserted_libs or []
示例#8
0
    def __init__(self, test_app, **kwargs):
        """Initialize Egtests.

    Args:
      test_app: (str) full path to egtests app.
      (Following are potential args in **kwargs)
      included_tests: (list) Specific tests to run
         E.g.
          [ 'TestCaseClass1/testMethod1', 'TestCaseClass2/testMethod2']
      excluded_tests: (list) Specific tests not to run
         E.g.
          [ 'TestCaseClass1', 'TestCaseClass2/testMethod2']
      test_args: List of strings to pass as arguments to the test when
        launching.
      env_vars: List of environment variables to pass to the test itself.
      release: (bool) Whether the app is release build.
      repeat_count: (int) Number of times to run each test case.
      inserted_libs: List of libraries to insert when running the test.

    Raises:
      AppNotFoundError: If the given app does not exist
    """
        if not os.path.exists(test_app):
            raise test_runner.AppNotFoundError(test_app)
        self.test_app_path = test_app
        self.project_path = os.path.dirname(self.test_app_path)
        self.test_args = kwargs.get('test_args') or []
        self.env_vars = {}
        for env_var in kwargs.get('env_vars') or []:
            env_var = env_var.split('=', 1)
            self.env_vars[env_var[0]] = None if len(
                env_var) == 1 else env_var[1]
        # Keep the initial included tests since creating target. Do not modify.
        self.initial_included_tests = kwargs.get('included_tests') or []
        # This may be modified between test launches.
        self.included_tests = kwargs.get('included_tests') or []
        # This may be modified between test launches.
        self.excluded_tests = kwargs.get('excluded_tests') or []
        self.disabled_tests = []
        self.module_name = os.path.splitext(os.path.basename(test_app))[0]
        self.release = kwargs.get('release')
        self.repeat_count = kwargs.get('repeat_count') or 1
        self.host_app_path = kwargs.get('host_app_path')
        self.inserted_libs = kwargs.get('inserted_libs') or []
示例#9
0
    def __init__(self,
                 test_app,
                 included_tests=None,
                 excluded_tests=None,
                 test_args=None,
                 env_vars=None,
                 release=False,
                 host_app_path=None):
        """Initialize Egtests.

    Args:
      test_app: (str) full path to egtests app.
      included_tests: (list) Specific tests to run
         E.g.
          [ 'TestCaseClass1/testMethod1', 'TestCaseClass2/testMethod2']
      excluded_tests: (list) Specific tests not to run
         E.g.
          [ 'TestCaseClass1', 'TestCaseClass2/testMethod2']
      test_args: List of strings to pass as arguments to the test when
        launching.
      env_vars: List of environment variables to pass to the test itself.
      release: (bool) Whether the app is release build.

    Raises:
      AppNotFoundError: If the given app does not exist
    """
        if not os.path.exists(test_app):
            raise test_runner.AppNotFoundError(test_app)
        self.test_app_path = test_app
        self.project_path = os.path.dirname(self.test_app_path)
        self.test_args = test_args or []
        # TODO(crbug.com/1092583): Move this switch as a test variant running only
        # in selected builder that should output disabled tests.
        self.test_args.append('--write-compiled-tests-json-to-writable-path')
        self.env_vars = {}
        for env_var in env_vars or []:
            env_var = env_var.split('=', 1)
            self.env_vars[env_var[0]] = None if len(
                env_var) == 1 else env_var[1]
        self.included_tests = included_tests or []
        self.excluded_tests = excluded_tests or []
        self.module_name = os.path.splitext(os.path.basename(test_app))[0]
        self.release = release
        self.host_app_path = host_app_path
    def __init__(self, egtests_app, filtered_tests=None, invert=False):
        """Initialize Egtests.

    Args:
      egtests_app: (str) full path to egtests app.
      filtered_tests: (list) Specific tests to run
        (it can inclusive/exclusive based on invert parameter).
         E.g.
          [ 'TestCaseClass1/testMethod1', 'TestCaseClass2/testMethod2']
      invert: type of filter(True - inclusive, False - exclusive).

    Raises:
      AppNotFoundError: If the given app does not exist
    """
        if not os.path.exists(egtests_app):
            raise test_runner.AppNotFoundError(egtests_app)
        self.egtests_path = egtests_app
        self.project_path = os.path.dirname(self.egtests_path)
        self.module_name = os.path.splitext(os.path.basename(egtests_app))[0]
        self.filter = filtered_tests
        self.invert = invert
示例#11
0
    def fill_xctest_run(self, egtests_app):
        """Fills xctestrun file by egtests.

    Args:
      egtests_app: (EgtestsApp) An Egetsts_app to run.

    Returns:
      A path to xctestrun file.

    Raises:
      AppNotFoundError if egtests is empty.
    """
        if not egtests_app:
            raise test_runner.AppNotFoundError('Egtests is not found!')
        xctestrun = tempfile.mkstemp()[1]
        # Creates a dict with data about egtests to run - fill all required fields:
        # egtests_module, egtest_app_path, egtests_xctest_path and
        # filtered tests if filter is specified.
        # Write data in temp xctest run file.
        plistlib.writePlist(egtests_app.xctestrun_node(), xctestrun)
        return xctestrun