コード例 #1
0
  def _test_two_distributions(self, os_name=None):
    java7, java8 = _get_two_distributions()
    os_name = os_name or get_os_name()

    self.assertNotEqual(java7.home, java8.home)

    for (one, two) in ((java7, java8), (java8, java7)):
      target_spec = 'testprojects/src/java/org/pantsbuild/testproject/printversion'
      run = self.run_pants(['run', target_spec],
                           config={
                             'jvm-distributions': {
                               'paths': {
                                 os_name: [one.home],
                               }
                             },
                             'jvm-platform': {
                               'default_platform': 'java{}'.format(one.version.components[1]),
                               'compiler': 'javac',
                             }
                           },
                           extra_env={
                             'JDK_HOME': two.home,
                           })
      self.assert_success(run)
      self.assertIn('java.home:{}'.format(os.path.realpath(one.home)), run.stdout_data)
コード例 #2
0
    def test_preferred_jvm_distributions(self):
        with self.fake_distribution(version="9999") as strict_home:
            with self.fake_distribution(version="10000") as non_strict_home:
                options = {
                    JvmPlatform.options_scope: {
                        "default_platform": "java9999",
                        "platforms": {
                            "java9999": {"target": "9999"},
                            "java10000": {"target": "10000"},
                        },
                    },
                    DistributionLocator.options_scope: {
                        "paths": {normalize_os_name(get_os_name()): [strict_home, non_strict_home]}
                    },
                }

                export_json = self.execute_export_json(**options)
                self.assertEqual(
                    strict_home,
                    export_json["preferred_jvm_distributions"]["java9999"]["strict"],
                    "strict home does not match",
                )

                # Since it is non-strict, it can be either.
                self.assertIn(
                    export_json["preferred_jvm_distributions"]["java9999"]["non_strict"],
                    [non_strict_home, strict_home],
                    "non-strict home does not match",
                )
コード例 #3
0
ファイル: test_export.py プロジェクト: whoserepoisthis/pants
    def test_preferred_jvm_distributions(self):
        with self.fake_distribution(version='9999') as strict_home:
            with self.fake_distribution(version='10000') as non_strict_home:
                options = {
                    JvmPlatform.options_scope: {
                        'default_platform': 'java9999',
                        'platforms': {
                            'java9999': {
                                'target': '9999'
                            },
                            'java10000': {
                                'target': '10000'
                            }
                        }
                    },
                    DistributionLocator.options_scope: {
                        'paths': {
                            normalize_os_name(get_os_name()):
                            [strict_home, non_strict_home]
                        }
                    }
                }

                export_json = self.execute_export_json(**options)
                self.assertEqual(
                    {
                        'strict': strict_home,
                        'non_strict': non_strict_home
                    }, export_json['preferred_jvm_distributions']['java9999'])
コード例 #4
0
  def test_preferred_jvm_distributions(self):
    with self.fake_distribution(version='9999') as strict_home:
      with self.fake_distribution(version='10000') as non_strict_home:
        options = {
          JvmPlatform.options_scope: {
            'default_platform': 'java9999',
            'platforms': {
              'java9999': {'target': '9999'},
              'java10000': {'target': '10000'}
            }
          },
          DistributionLocator.options_scope: {
            'paths': {
              normalize_os_name(get_os_name()): [
                strict_home,
                non_strict_home
              ]
            }
          }
        }

        export_json = self.execute_export_json(**options)
        self.assertEqual(strict_home, export_json['preferred_jvm_distributions']['java9999']['strict'],
                         "strict home does not match")

        # Since it is non-strict, it can be either.
        self.assertIn(export_json['preferred_jvm_distributions']['java9999']['non_strict'],
                      [non_strict_home, strict_home],
                      "non-strict home does not match")
コード例 #5
0
ファイル: test_export.py プロジェクト: foursquare/pants
  def test_preferred_jvm_distributions(self):
    with self.fake_distribution(version='9999') as strict_home:
      with self.fake_distribution(version='10000') as non_strict_home:
        options = {
          JvmPlatform.options_scope: {
            'default_platform': 'java9999',
            'platforms': {
              'java9999': {'target': '9999'},
              'java10000': {'target': '10000'}
            }
          },
          DistributionLocator.options_scope: {
            'paths': {
              normalize_os_name(get_os_name()): [
                strict_home,
                non_strict_home
              ]
            }
          }
        }

        export_json = self.execute_export_json(**options)
        self.assertEqual(strict_home, export_json['preferred_jvm_distributions']['java9999']['strict'],
                         "strict home does not match")

        # Since it is non-strict, it can be either.
        self.assertIn(export_json['preferred_jvm_distributions']['java9999']['non_strict'],
                      [non_strict_home, strict_home],
                      "non-strict home does not match")
コード例 #6
0
ファイル: test_export.py プロジェクト: neven7/pants
    def test_preferred_jvm_distributions(self):
        self.set_options_for_scope('jvm-platform',
                                   default_platform='java9999',
                                   platforms={
                                       'java9999': {
                                           'target': '9999'
                                       },
                                       'java10000': {
                                           'target': '10000'
                                       }
                                   })

        with self.fake_distribution(version='9999') as strict_home:
            with self.fake_distribution(version='10000') as non_strict_home:
                self.set_options_for_scope(
                    'jvm-distributions',
                    paths={
                        normalize_os_name(get_os_name()):
                        [strict_home, non_strict_home]
                    })
                with subsystem_instance(DistributionLocator) as locator:
                    locator._reset(
                    )  # Make sure we get a fresh read from the options set just above.
                    self.addCleanup(
                        locator._reset
                    )  # And make sure we we clean up the values we cache.

                    export_json = self.execute_export_json()
                    self.assertEqual(
                        {
                            'strict': strict_home,
                            'non_strict': non_strict_home
                        },
                        export_json['preferred_jvm_distributions']['java9999'])
コード例 #7
0
    def _test_two_distributions(self, os_name=None):
        java8, java9 = _get_two_distributions()
        os_name = os_name or get_os_name()

        self.assertNotEqual(java8.home, java9.home)

        for (one, two) in ((java8, java9), (java9, java8)):
            target_spec = "testprojects/src/java/org/pantsbuild/testproject/printversion"
            run = self.run_pants(
                ["run", target_spec],
                config={
                    "jvm-distributions": {
                        "paths": {
                            os_name: [one.home],
                        }
                    },
                    "jvm-platform": {
                        "default_platform": f"java{one.version.components[1]}",
                        "compiler": "javac",
                    },
                },
                extra_env={
                    "JDK_HOME": two.home,
                },
            )
            self.assert_success(run)
            self.assertIn(f"java.home:{os.path.realpath(one.home)}",
                          run.stdout_data)
コード例 #8
0
  def _test_two_distributions(self, os_name=None):
    java7, java8 = _get_two_distributions()
    os_name = os_name or get_os_name()

    self.assertNotEqual(java7.home, java8.home)

    for (one, two) in ((java7, java8), (java8, java7)):
      target_spec = 'testprojects/src/java/org/pantsbuild/testproject/printversion'
      run = self.run_pants(['run', target_spec],
                           config={
                             'jvm-distributions': {
                               'paths': {
                                 os_name: [one.home],
                               }
                             },
                             'jvm-platform': {
                               'default_platform': 'java{}'.format(one.version.components[1]),
                               'compiler': 'javac',
                             }
                           },
                           extra_env={
                             'JDK_HOME': two.home,
                           })
      self.assert_success(run)
      self.assertIn('java.home:{}'.format(os.path.realpath(one.home)), run.stdout_data)
コード例 #9
0
 def test_jdk_paths_with_aliased_os_names(self):
   # NB(gmalmquist): This test will silently no-op and do nothing if the testing machine is running
   # an esoteric os (eg, windows).
   os_name = get_os_name()
   if os_name in OS_ALIASES:
     for other in OS_ALIASES[os_name]:
       if other != os_name:
         self._test_two_distributions(other)
コード例 #10
0
 def test_jdk_paths_with_aliased_os_names(self):
   # NB(gmalmquist): This test will silently no-op and do nothing if the testing machine is running
   # an esoteric os (eg, windows).
   os_name = get_os_name()
   if os_name in OS_ALIASES:
     for other in OS_ALIASES[os_name]:
       if other != os_name:
         self._test_two_distributions(other)
コード例 #11
0
  def _handle_system_specific_libraries(self, libraries):
    general_confs = {'default', 'sources', 'javadoc'}
    specific_confs = set(libraries) - general_confs
    os_name = normalize_os_name(get_os_name())

    for conf in specific_confs:
      for name in known_os_names():
        if name in conf.lower() and normalize_os_name(name) == os_name:
          # Assume this conf actually represents libraries that should be mapped to 'default' on
          # this system.
          libraries['default'].update(libraries[conf])
コード例 #12
0
ファイル: desktop.py プロジェクト: wiwa/pants
def idea_open(file_: str, lookup_paths: list) -> None:
    """Attempts to open the given files using the preferred desktop viewer or editor.

    :raises :class:`OpenError`: if there is a problem opening any of the files.
    """
    if file_:
        osname = get_os_name()
        opener = _IDEA_BY_OS.get(osname)
        if opener:
            opener(file_, lookup_paths)
        else:
            raise OpenError("Open currently not supported for " + osname)
コード例 #13
0
ファイル: desktop.py プロジェクト: cosmicexplorer/pants
def ui_open(*files):
  """Attempts to open the given files using the preferred desktop viewer or editor.

  :raises :class:`OpenError`: if there is a problem opening any of the files.
  """
  if files:
    osname = get_os_name()
    opener = _OPENER_BY_OS.get(osname)
    if opener:
      opener(files)
    else:
      raise OpenError('Open currently not supported for ' + osname)
コード例 #14
0
def ui_open(*files):
    """Attempts to open the given files using the preferred desktop viewer or editor.

  :raises :class:`OpenError`: if there is a problem opening any of the files.
  """
    if files:
        osname = get_os_name()
        opener = _OPENER_BY_OS.get(osname)
        if opener:
            opener(files)
        else:
            raise OpenError('Open currently not supported for ' + osname)
コード例 #15
0
  def _get_platform_specific_subsystems(cls):
    """Return the subsystems used by the native toolchain for this platform."""
    os_name = get_os_name()
    normed_os_name = normalize_os_name(os_name)

    subsystems_for_host = cls._PLATFORM_SPECIFIC_SUBSYSTEMS.get(normed_os_name, None)

    if subsystems_for_host is None:
      raise cls.UnsupportedPlatformError(
        "Pants doesn't support building native code on this platform "
        "(uname: '{}').".format(os_name))

    # NB: path entries for cross-platform subsystems currently take precedence
    # over platform-specific ones -- this could be made configurable.
    all_subsystems_for_toolchain = cls._CROSS_PLATFORM_SUBSYSTEMS + subsystems_for_host

    return all_subsystems_for_toolchain
コード例 #16
0
ファイル: desktop.py プロジェクト: jperkelens/pants
def ui_open(console: Console, runner: InteractiveRunner, files: Iterable[PurePath]) -> None:
    """Opens the given files with the appropriate application for the current operating system.

    Any failures to either locate an appropriate application to open the files with or else execute
    that program are reported to the console stderr.
    """
    osname = get_os_name()
    opener_type = _OPENERS_BY_OSNAME.get(osname)
    if opener_type is None:
        console.print_stderr(f"Could not open {' '.join(map(str, files))} for viewing.")
        console.print_stderr(
            f"Opening files for viewing is currently not supported for the "
            f"{osname} operating system."
        )
        return

    opener = opener_type(console, runner)
    opener.open(files)
コード例 #17
0
    def _get_platform_specific_subsystems(cls):
        """Return the subsystems used by the native toolchain for this platform."""
        os_name = get_os_name()
        normed_os_name = normalize_os_name(os_name)

        subsystems_for_host = cls._PLATFORM_SPECIFIC_SUBSYSTEMS.get(
            normed_os_name, None)

        if subsystems_for_host is None:
            raise cls.UnsupportedPlatformError(
                "Pants doesn't support building native code on this platform "
                "(uname: '{}').".format(os_name))

        # NB: path entries for cross-platform subsystems currently take precedence
        # over platform-specific ones -- this could be made configurable.
        all_subsystems_for_toolchain = cls._CROSS_PLATFORM_SUBSYSTEMS + subsystems_for_host

        return all_subsystems_for_toolchain
コード例 #18
0
ファイル: test_export.py プロジェクト: UnrememberMe/pants
    def test_preferred_jvm_distributions(self):
        with self.fake_distribution(version="9999") as strict_home:
            with self.fake_distribution(version="10000") as non_strict_home:
                options = {
                    JvmPlatform.options_scope: {
                        "default_platform": "java9999",
                        "platforms": {"java9999": {"target": "9999"}, "java10000": {"target": "10000"}},
                    },
                    DistributionLocator.options_scope: {
                        "paths": {normalize_os_name(get_os_name()): [strict_home, non_strict_home]}
                    },
                }

                export_json = self.execute_export_json(**options)
                self.assertEqual(
                    {"strict": strict_home, "non_strict": non_strict_home},
                    export_json["preferred_jvm_distributions"]["java9999"],
                )
コード例 #19
0
    def _test_two_distributions(self, os_name=None):
        java7, java8 = _get_two_distributions()
        os_name = os_name or get_os_name()

        self.assertNotEqual(java7.home, java8.home)

        for (one, two) in ((java7, java8), (java8, java7)):
            target_spec = "testprojects/src/java/org/pantsbuild/testproject/printversion"
            run = self.run_pants(
                ["run", target_spec],
                config={
                    "jvm-distributions": {"paths": {os_name: [one.home]}},
                    "jvm-platform": {"default_platform": "java{}".format(one.version.components[1])},
                },
                extra_env={"JDK_HOME": two.home},
            )
            self.assert_success(run)
            self.assertIn("java.home:{}".format(os.path.realpath(one.home)), run.stdout_data)
コード例 #20
0
  def _test_two_distributions(self, os_name=None):
    java7, java8 = get_two_distributions()
    os_name = os_name or get_os_name()

    self.assertNotEqual(java7.home, java8.home)

    for (one, two) in ((java7, java8), (java8, java7)):
      target_spec = 'testprojects/src/java/org/pantsbuild/testproject/printversion'
      run = self.run_pants(['run', target_spec], config={
        'jvm': {
          'jdk_paths': {
            os_name: [one.home],
          }
        }
      }, extra_env={
        'JDK_HOME': two.home,
      })
      self.assert_success(run)
      self.assertIn('java.home:{}'.format(one.home), run.stdout_data)
コード例 #21
0
    def test_preferred_jvm_distributions(self):
        self.set_options_for_scope(
            "jvm-platform",
            default_platform="java9999",
            platforms={"java9999": {"target": "9999"}, "java10000": {"target": "10000"}},
        )

        with self.fake_distribution(version="9999") as strict_home:
            with self.fake_distribution(version="10000") as non_strict_home:
                self.set_options_for_scope(
                    "jvm-distributions", paths={normalize_os_name(get_os_name()): [strict_home, non_strict_home]}
                )
                with subsystem_instance(DistributionLocator) as locator:
                    locator._reset()  # Make sure we get a fresh read from the options set just above.
                    self.addCleanup(locator._reset)  # And make sure we we clean up the values we cache.

                    export_json = self.execute_export_json()
                    self.assertEqual(
                        {"strict": strict_home, "non_strict": non_strict_home},
                        export_json["preferred_jvm_distributions"]["java9999"],
                    )
コード例 #22
0
ファイル: test_export.py プロジェクト: jayantak/pants
  def test_preferred_jvm_distributions(self):
    self.set_options_for_scope('jvm-platform',
                               default_platform='java9999',
                               platforms={
                                 'java9999': {'target': '9999'},
                                 'java10000': {'target': '10000'}
                               })

    with self.fake_distribution(version='9999') as strict_home:
      with self.fake_distribution(version='10000') as non_strict_home:
        self.set_options_for_scope('jvm-distributions',
                                   paths={
                                     normalize_os_name(get_os_name()): [
                                       strict_home,
                                       non_strict_home
                                     ]
                                   })
        with subsystem_instance(DistributionLocator) as locator:
          locator._reset()  # Make sure we get a fresh read from the options set just above.

          export_json = self.execute_export_json()
          self.assertEqual({'strict': strict_home, 'non_strict': non_strict_home},
                           export_json['preferred_jvm_distributions']['java9999'])
コード例 #23
0
ファイル: test_export.py プロジェクト: grimreaper/pants
  def test_preferred_jvm_distributions(self):
    with self.fake_distribution(version='9999') as strict_home:
      with self.fake_distribution(version='10000') as non_strict_home:
        options = {
          JvmPlatform.options_scope: {
            'default_platform': 'java9999',
            'platforms': {
              'java9999': {'target': '9999'},
              'java10000': {'target': '10000'}
            }
          },
          DistributionLocator.options_scope: {
            'paths': {
              normalize_os_name(get_os_name()): [
                strict_home,
                non_strict_home
              ]
            }
          }
        }

        export_json = self.execute_export_json(**options)
        self.assertEqual({'strict': strict_home, 'non_strict': non_strict_home},
                         export_json['preferred_jvm_distributions']['java9999'])
コード例 #24
0
  def test_java_home_extraction_missing_distributions(self):
    # This will need to be bumped if java ever gets to major version one million.
    far_future_version = '999999.1'
    farer_future_version = '999999.2'

    os_name = normalize_os_name(get_os_name())

    @contextmanager
    def fake_distributions(versions):
      """Create a fake JDK for each java version in the input, and yield the list of java_homes.

      :param list versions: List of java version strings.
      """
      fakes = []
      for version in versions:
        fakes.append(distribution(
          executables=[EXE('bin/java', version), EXE('bin/javac', version)],
        ))
      yield [d.__enter__() for d in fakes]
      for d in fakes:
        d.__exit__(None, None, None)

    @contextmanager
    def fake_distribution_locator(*versions):
      """Sets up a fake distribution locator with fake distributions.

      Creates one distribution for each java version passed as an argument, and yields a list of
      paths to the java homes for each distribution.
      """
      with fake_distributions(versions) as paths:
        path_options = {
          'jvm-distributions': {
            'paths': {
              os_name: paths,
            }
          }
        }
        with subsystem_instance(DistributionLocator, **path_options) as locator:
          yield paths
          locator._reset()

    # Completely missing a usable distribution.
    with fake_distribution_locator(far_future_version):
      with self.assertRaises(DistributionLocator.Error):
        ZincCompile._get_zinc_arguments(JvmPlatformSettings(
          source_level=farer_future_version,
          target_level=farer_future_version,
          args=['$JAVA_HOME/foo'],
        ))

    # Missing a strict distribution.
    with fake_distribution_locator(farer_future_version) as paths:
      results = ZincCompile._get_zinc_arguments(JvmPlatformSettings(
        source_level=far_future_version,
        target_level=far_future_version,
        args=['$JAVA_HOME/foo', '$JAVA_HOME'],
      ))
      self.assertEquals(paths[0], results[-1])
      self.assertEquals('{}/foo'.format(paths[0]), results[-2])

    # Make sure we pick up the strictest possible distribution.
    with fake_distribution_locator(farer_future_version, far_future_version) as paths:
      farer_path, far_path = paths
      results = ZincCompile._get_zinc_arguments(JvmPlatformSettings(
        source_level=far_future_version,
        target_level=far_future_version,
        args=['$JAVA_HOME/foo', '$JAVA_HOME'],
      ))
      self.assertEquals(far_path, results[-1])
      self.assertEquals('{}/foo'.format(far_path), results[-2])

    # Make sure we pick the higher distribution when the lower one doesn't work.
    with fake_distribution_locator(farer_future_version, far_future_version) as paths:
      farer_path, far_path = paths
      results = ZincCompile._get_zinc_arguments(JvmPlatformSettings(
        source_level=farer_future_version,
        target_level=farer_future_version,
        args=['$JAVA_HOME/foo', '$JAVA_HOME'],
      ))
      self.assertEquals(farer_path, results[-1])
      self.assertEquals('{}/foo'.format(farer_path), results[-2])
コード例 #25
0
ファイル: build_symbols.py プロジェクト: ericzundel/mvn2pants
 def arch(self):
   name = normalize_os_name(get_os_name())
   return self.__architectures.get(name, 'unknown')
コード例 #26
0
  def test_java_home_extraction_missing_distributions(self):
    # This will need to be bumped if java ever gets to major version one million.
    far_future_version = '999999.1'
    farer_future_version = '999999.2'

    os_name = normalize_os_name(get_os_name())

    @contextmanager
    def fake_distributions(versions):
      """Create a fake JDK for each java version in the input, and yield the list of java_homes.

      :param list versions: List of java version strings.
      """
      fakes = []
      for version in versions:
        fakes.append(distribution(
          executables=[EXE('bin/java', version), EXE('bin/javac', version)],
        ))
      yield [d.__enter__() for d in fakes]
      for d in fakes:
        d.__exit__(None, None, None)

    @contextmanager
    def fake_distribution_locator(*versions):
      """Sets up a fake distribution locator with fake distributions.

      Creates one distribution for each java version passed as an argument, and yields a list of
      paths to the java homes for each distribution.
      """
      with fake_distributions(versions) as paths:
        path_options = {
          DistributionLocator.options_scope: {
            'paths': {
              os_name: paths,
            }
          }
        }
        Subsystem.reset()
        init_subsystem(DistributionLocator, options=path_options)
        yield paths

    # Completely missing a usable distribution.
    with fake_distribution_locator(far_future_version):
      with self.assertRaises(DistributionLocator.Error):
        ZincCompile._get_zinc_arguments(JvmPlatformSettings(
          source_level=farer_future_version,
          target_level=farer_future_version,
          args=['$JAVA_HOME/foo'],
        ))

    # Missing a strict distribution.
    with fake_distribution_locator(farer_future_version) as paths:
      results = ZincCompile._get_zinc_arguments(JvmPlatformSettings(
        source_level=far_future_version,
        target_level=far_future_version,
        args=['$JAVA_HOME/foo', '$JAVA_HOME'],
      ))
      self.assertEquals(paths[0], results[-1])
      self.assertEquals('{}/foo'.format(paths[0]), results[-2])

    # Make sure we pick up the strictest possible distribution.
    with fake_distribution_locator(farer_future_version, far_future_version) as paths:
      farer_path, far_path = paths
      results = ZincCompile._get_zinc_arguments(JvmPlatformSettings(
        source_level=far_future_version,
        target_level=far_future_version,
        args=['$JAVA_HOME/foo', '$JAVA_HOME'],
      ))
      self.assertEquals(far_path, results[-1])
      self.assertEquals('{}/foo'.format(far_path), results[-2])

    # Make sure we pick the higher distribution when the lower one doesn't work.
    with fake_distribution_locator(farer_future_version, far_future_version) as paths:
      farer_path, far_path = paths
      results = ZincCompile._get_zinc_arguments(JvmPlatformSettings(
        source_level=farer_future_version,
        target_level=farer_future_version,
        args=['$JAVA_HOME/foo', '$JAVA_HOME'],
      ))
      self.assertEquals(farer_path, results[-1])
      self.assertEquals('{}/foo'.format(farer_path), results[-2])
コード例 #27
0
    def test_java_home_extraction_missing_distributions(self):
        # This will need to be bumped if java ever gets to major version one million.
        far_future_version = "999999.1"
        farther_future_version = "999999.2"

        os_name = normalize_os_name(get_os_name())

        @contextmanager
        def fake_distributions(versions):
            """Create a fake JDK for each java version in the input, and yield the list of
            java_homes.

            :param list versions: List of java version strings.
            """
            fakes = []
            for version in versions:
                fakes.append(
                    distribution(executables=[
                        EXE("bin/java", version),
                        EXE("bin/javac", version)
                    ], ))
            yield [d.__enter__() for d in fakes]
            for d in fakes:
                d.__exit__(None, None, None)

        @contextmanager
        def fake_distribution_locator(*versions):
            """Sets up a fake distribution locator with fake distributions.

            Creates one distribution for each java version passed as an argument, and yields a list
            of paths to the java homes for each distribution.
            """
            with fake_distributions(versions) as paths:
                path_options = {
                    DistributionLocator.options_scope: {
                        "paths": {
                            os_name: paths
                        }
                    }
                }
                Subsystem.reset()
                init_subsystem(DistributionLocator, options=path_options)
                yield paths

        # Completely missing a usable distribution.
        with fake_distribution_locator(far_future_version):
            with self.assertRaises(DistributionLocator.Error):
                self._get_zinc_arguments(
                    JvmPlatformSettings(
                        source_level=farther_future_version,
                        target_level=farther_future_version,
                        args=["$JAVA_HOME/foo"],
                        jvm_options=[],
                    ))

        # Missing a strict distribution.
        with fake_distribution_locator(farther_future_version) as paths:
            results = self._get_zinc_arguments(
                JvmPlatformSettings(
                    source_level=far_future_version,
                    target_level=far_future_version,
                    args=["$JAVA_HOME/foo", "$JAVA_HOME"],
                    jvm_options=[],
                ))
            self.assertEqual(paths[0], results[-1])
            self.assertEqual(f"{paths[0]}/foo", results[-2])

        # Make sure we pick up the strictest possible distribution.
        with fake_distribution_locator(farther_future_version,
                                       far_future_version) as paths:
            farer_path, far_path = paths
            results = self._get_zinc_arguments(
                JvmPlatformSettings(
                    source_level=far_future_version,
                    target_level=far_future_version,
                    args=["$JAVA_HOME/foo", "$JAVA_HOME"],
                    jvm_options=[],
                ))
            self.assertEqual(far_path, results[-1])
            self.assertEqual(f"{far_path}/foo", results[-2])

        # Make sure we pick the higher distribution when the lower one doesn't work.
        with fake_distribution_locator(farther_future_version,
                                       far_future_version) as paths:
            farer_path, far_path = paths
            results = self._get_zinc_arguments(
                JvmPlatformSettings(
                    source_level=farther_future_version,
                    target_level=farther_future_version,
                    args=["$JAVA_HOME/foo", "$JAVA_HOME"],
                    jvm_options=[],
                ))
            self.assertEqual(farer_path, results[-1])
            self.assertEqual(f"{farer_path}/foo", results[-2])
コード例 #28
0
 def arch(self):
     name = normalize_os_name(get_os_name())
     return self.__architectures.get(name, 'unknown')