def __init__(self, app_path, xcode_version, out_dir, test_args=None):
    """Initializes a new instance of this class.

    Args:
      app_path: Path to the compiled .app to run.
      xcode_version: Version of Xcode to use when running the test.
      out_dir: Directory to emit test data into.
      test_args: List of strings to pass as arguments to the test when
        launching.

    Raises:
      AppNotFoundError: If the given app does not exist.
      XcodeVersionNotFoundError: If the given Xcode version does not exist.
    """
    if not os.path.exists(app_path):
      raise AppNotFoundError(app_path)

    if not find_xcode.find_xcode(xcode_version)['found']:
      raise XcodeVersionNotFoundError(xcode_version)

    if not os.path.exists(out_dir):
      os.makedirs(out_dir)

    self.app_name = os.path.splitext(os.path.split(app_path)[-1])[0]
    self.app_path = app_path
    self.cfbundleid = subprocess.check_output([
        '/usr/libexec/PlistBuddy',
        '-c', 'Print:CFBundleIdentifier',
        os.path.join(app_path, 'Info.plist'),
    ]).rstrip()
    self.logs = collections.OrderedDict()
    self.out_dir = out_dir
    self.test_args = test_args or []
Exemple #2
0
    def __init__(
        self,
        app_path,
        xcode_version,
        out_dir,
        env_vars=None,
        test_args=None,
        xctest=False,
    ):
        """Initializes a new instance of this class.

    Args:
      app_path: Path to the compiled .app to run.
      xcode_version: Version of Xcode to use when running the test.
      out_dir: Directory to emit test data into.
      env_vars: List of environment variables to pass to the test itself.
      test_args: List of strings to pass as arguments to the test when
        launching.
      xctest: Whether or not this is an XCTest.

    Raises:
      AppNotFoundError: If the given app does not exist.
      PlugInsNotFoundError: If the PlugIns directory does not exist for XCTests.
      XcodeVersionNotFoundError: If the given Xcode version does not exist.
      XCTestPlugInNotFoundError: If the .xctest PlugIn does not exist.
    """
        app_path = os.path.abspath(app_path)
        if not os.path.exists(app_path):
            raise AppNotFoundError(app_path)

        if not find_xcode.find_xcode(xcode_version)['found']:
            raise XcodeVersionNotFoundError(xcode_version)

        if not os.path.exists(out_dir):
            os.makedirs(out_dir)

        self.app_name = os.path.splitext(os.path.split(app_path)[-1])[0]
        self.app_path = app_path
        self.cfbundleid = subprocess.check_output([
            '/usr/libexec/PlistBuddy',
            '-c',
            'Print:CFBundleIdentifier',
            os.path.join(app_path, 'Info.plist'),
        ]).rstrip()
        self.env_vars = env_vars or []
        self.logs = collections.OrderedDict()
        self.out_dir = out_dir
        self.test_args = test_args or []
        self.xcode_version = xcode_version
        self.xctest_path = ''

        if xctest:
            plugins_dir = os.path.join(self.app_path, 'PlugIns')
            if not os.path.exists(plugins_dir):
                raise PlugInsNotFoundError(plugins_dir)
            for plugin in os.listdir(plugins_dir):
                if plugin.endswith('.xctest'):
                    self.xctest_path = os.path.join(plugins_dir, plugin)
            if not os.path.exists(self.xctest_path):
                raise XCTestPlugInNotFoundError(self.xctest_path)
Exemple #3
0
    def __init__(self, app_path, xcode_version, out_dir, test_args=None):
        """Initializes a new instance of this class.

    Args:
      app_path: Path to the compiled .app to run.
      xcode_version: Version of Xcode to use when running the test.
      out_dir: Directory to emit test data into.
      test_args: List of strings to pass as arguments to the test when
        launching.

    Raises:
      AppNotFoundError: If the given app does not exist.
      XcodeVersionNotFoundError: If the given Xcode version does not exist.
    """
        if not os.path.exists(app_path):
            raise AppNotFoundError(app_path)

        if not find_xcode.find_xcode(xcode_version)['found']:
            raise XcodeVersionNotFoundError(xcode_version)

        if not os.path.exists(out_dir):
            os.makedirs(out_dir)

        self.app_name = os.path.splitext(os.path.split(app_path)[-1])[0]
        self.app_path = app_path
        self.cfbundleid = subprocess.check_output([
            '/usr/libexec/PlistBuddy',
            '-c',
            'Print:CFBundleIdentifier',
            os.path.join(app_path, 'Info.plist'),
        ]).rstrip()
        self.logs = collections.OrderedDict()
        self.out_dir = out_dir
        self.test_args = test_args or []
Exemple #4
0
  def __init__(
    self,
    app_path,
    xcode_version,
    out_dir,
    env_vars=None,
    test_args=None,
    xctest=False,
  ):
    """Initializes a new instance of this class.

    Args:
      app_path: Path to the compiled .app to run.
      xcode_version: Version of Xcode to use when running the test.
      out_dir: Directory to emit test data into.
      env_vars: List of environment variables to pass to the test itself.
      test_args: List of strings to pass as arguments to the test when
        launching.
      xctest: Whether or not this is an XCTest.

    Raises:
      AppNotFoundError: If the given app does not exist.
      PlugInsNotFoundError: If the PlugIns directory does not exist for XCTests.
      XcodeVersionNotFoundError: If the given Xcode version does not exist.
      XCTestPlugInNotFoundError: If the .xctest PlugIn does not exist.
    """
    app_path = os.path.abspath(app_path)
    if not os.path.exists(app_path):
      raise AppNotFoundError(app_path)

    if not find_xcode.find_xcode(xcode_version)['found']:
      raise XcodeVersionNotFoundError(xcode_version)

    if not os.path.exists(out_dir):
      os.makedirs(out_dir)

    self.app_name = os.path.splitext(os.path.split(app_path)[-1])[0]
    self.app_path = app_path
    self.cfbundleid = subprocess.check_output([
        '/usr/libexec/PlistBuddy',
        '-c', 'Print:CFBundleIdentifier',
        os.path.join(app_path, 'Info.plist'),
    ]).rstrip()
    self.env_vars = env_vars or []
    self.logs = collections.OrderedDict()
    self.out_dir = out_dir
    self.test_args = test_args or []
    self.xcode_version = xcode_version
    self.xctest_path = ''

    if xctest:
      plugins_dir = os.path.join(self.app_path, 'PlugIns')
      if not os.path.exists(plugins_dir):
        raise PlugInsNotFoundError(plugins_dir)
      for plugin in os.listdir(plugins_dir):
        if plugin.endswith('.xctest'):
          self.xctest_path = os.path.join(plugins_dir, plugin)
      if not os.path.exists(self.xctest_path):
        raise XCTestPlugInNotFoundError(self.xctest_path)
Exemple #5
0
    def __init__(
        self,
        app_path,
        xcode_version,
        xcode_build_version,
        out_dir,
        env_vars=None,
        mac_toolchain='',
        retries=None,
        test_args=None,
        test_cases=None,
        xcode_path='',
        xctest=False,
    ):
        """Initializes a new instance of this class.

    Args:
      app_path: Path to the compiled .app to run.
      xcode_version: (deprecated by xcode_build_version) Version of Xcode to use
        when running the test.
      xcode_build_version: Xcode build version to install before running tests.
      out_dir: Directory to emit test data into.
      env_vars: List of environment variables to pass to the test itself.
      mac_toolchain: Command to run `mac_toolchain` tool.
      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.
      xcode_path: Path to Xcode.app folder where its contents will be installed.
      xctest: Whether or not this is an XCTest.

    Raises:
      AppNotFoundError: If the given app does not exist.
      PlugInsNotFoundError: If the PlugIns directory does not exist for XCTests.
      XcodeVersionNotFoundError: If the given Xcode version does not exist.
      XCTestPlugInNotFoundError: If the .xctest PlugIn does not exist.
    """
        app_path = os.path.abspath(app_path)
        if not os.path.exists(app_path):
            raise AppNotFoundError(app_path)

        if xcode_build_version:
            if not install_xcode(xcode_build_version, mac_toolchain,
                                 xcode_path):
                raise XcodeVersionNotFoundError(xcode_build_version)
        elif not find_xcode.find_xcode(xcode_version)['found']:
            raise XcodeVersionNotFoundError(xcode_version)

        xcode_info = find_xcode.get_current_xcode_info()
        print 'Using Xcode version %s build %s at %s' % (
            xcode_info['version'], xcode_info['build'], xcode_info['path'])

        if not os.path.exists(out_dir):
            os.makedirs(out_dir)

        self.app_name = os.path.splitext(os.path.split(app_path)[-1])[0]
        self.app_path = app_path
        self.cfbundleid = subprocess.check_output([
            '/usr/libexec/PlistBuddy',
            '-c',
            'Print:CFBundleIdentifier',
            os.path.join(app_path, 'Info.plist'),
        ]).rstrip()
        self.env_vars = env_vars or []
        self.logs = collections.OrderedDict()
        self.out_dir = out_dir
        self.retries = retries or 0
        self.test_args = test_args or []
        self.test_cases = test_cases or []
        self.xcode_version = xcode_version
        self.xctest_path = ''

        self.test_results = {}
        self.test_results['version'] = 3
        self.test_results['path_delimiter'] = '.'
        self.test_results['seconds_since_epoch'] = int(time.time())
        # This will be overwritten when the tests complete successfully.
        self.test_results['interrupted'] = True

        if xctest:
            plugins_dir = os.path.join(self.app_path, 'PlugIns')
            if not os.path.exists(plugins_dir):
                raise PlugInsNotFoundError(plugins_dir)
            for plugin in os.listdir(plugins_dir):
                if plugin.endswith('.xctest'):
                    self.xctest_path = os.path.join(plugins_dir, plugin)
            if not os.path.exists(self.xctest_path):
                raise XCTestPlugInNotFoundError(self.xctest_path)