コード例 #1
0
 def test_no_warnings_on_known_names(self):
     for name in known_os_names():
         with self.warnings() as warning_list:
             normalize_os_name(name)
             self.assertEqual(
                 0, len(warning_list),
                 'Recieved unexpected warnings: {}'.format(warning_list))
コード例 #2
0
 def test_no_warnings_on_known_names(self) -> None:
     for name in known_os_names():
         with self.captured_logging(logging.WARNING) as captured:
             normalize_os_name(name)
             self.assertEqual(
                 0, len(captured.warnings()),
                 f'Recieved unexpected warnings: {captured.warnings()}')
コード例 #3
0
ファイル: test_osutil.py プロジェクト: jdewald/pants
 def test_no_warnings_on_known_names(self):
     for name in known_os_names():
         with self.captured_logging() as captured:
             normalize_os_name(name)
             self.assertEqual(
                 0, len(captured.warnings()),
                 'Recieved unexpected warnings: {}'.format(
                     captured.warnings()))
コード例 #4
0
 def test_warnings_on_unknown_names(self):
     name = 'I really hope no one ever names an operating system with this string.'
     with self.captured_logging(logging.WARNING) as captured:
         normalize_os_name(name)
         self.assertEqual(
             1, len(captured.warnings()),
             'Expected exactly one warning, but got: {}'.format(
                 captured.warnings()))
コード例 #5
0
 def test_warnings_on_unknown_names(self):
     name = 'I really hope no one ever names an operating system with this string.'
     with self.warnings() as warning_list:
         normalize_os_name(name)
         self.assertEqual(
             1, len(warning_list),
             'Expected exactly one warning, but got: {}'.format(
                 warning_list))
コード例 #6
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])
コード例 #7
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",
                )
コード例 #8
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")
コード例 #9
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")
コード例 #10
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'])
コード例 #11
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'])
コード例 #12
0
ファイル: distribution.py プロジェクト: zvikihouzz/pants
 def _get_explicit_jdk_paths(self):
   if not self._normalized_jdk_paths:
     return ()
   os_name = normalize_os_name(os.uname()[0].lower())
   if os_name not in self._normalized_jdk_paths:
     logger.warning('--jvm-distributions-paths was specified, but has no entry for "{}".'
                    .format(os_name))
   return self._normalized_jdk_paths.get(os_name, ())
コード例 #13
0
ファイル: distribution.py プロジェクト: CaitieM20/pants
 def _get_explicit_jdk_paths(self):
   if not self._normalized_jdk_paths:
     return ()
   os_name = normalize_os_name(os.uname()[0].lower())
   if os_name not in self._normalized_jdk_paths:
     logger.warning('--jvm-distributions-paths was specified, but has no entry for "{}".'
                    .format(os_name))
   return self._normalized_jdk_paths.get(os_name, ())
コード例 #14
0
 def get_jdk_paths(self, os_name=None):
   jdk_paths = self._normalized_jdk_paths
   if not jdk_paths:
     return ()
   if os_name is None:
     os_name = os.uname()[0].lower()
   os_name = normalize_os_name(os_name)
   if os_name not in jdk_paths:
     logger.warning('--jvm-jdk-paths was specified, but has no entry for "{}".'.format(os_name))
   return jdk_paths.get(os_name, ())
コード例 #15
0
ファイル: distribution.py プロジェクト: Gointer/pants
 def _normalized_jdk_paths(self):
   jdk_paths = self.get_options().paths or {}
   normalized = {}
   for name, paths in sorted(jdk_paths.items()):
     rename = normalize_os_name(name)
     if rename in normalized:
       logger.warning('Multiple OS names alias to "{}"; combining results.'.format(rename))
       normalized[rename].extend(paths)
     else:
       normalized[rename] = paths
   return normalized
コード例 #16
0
ファイル: distribution.py プロジェクト: Gointer/pants
  def get_jdk_paths(self, os_name=None):
    """Get the list of explicitly configured JDK paths for this os.

    :param os_name: Os name to lookup. If None, use the currently detected os name.
    :return: Paths of explicitly configured JDK's from the --jvm-distribution-paths option
    :rtype: list of strings
    """
    jdk_paths = self._normalized_jdk_paths
    if not jdk_paths:
      return ()
    if os_name is None:
      os_name = os.uname()[0].lower()
    os_name = normalize_os_name(os_name)
    if os_name not in jdk_paths:
      logger.warning('--jvm-distributions-paths was specified, but has no entry for "{}".'
                     .format(os_name))
    return jdk_paths.get(os_name, ())
コード例 #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 _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
コード例 #20
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"],
                    )
コード例 #21
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'])
コード例 #22
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'])
コード例 #23
0
ファイル: osutil_test.py プロジェクト: patricklaw/pants
def test_alias_normalization() -> None:
    for normal_os, aliases in OS_ALIASES.items():
        for alias in aliases:
            assert normal_os == normalize_os_name(alias)
コード例 #24
0
ファイル: build_symbols.py プロジェクト: ericzundel/mvn2pants
 def arch(self):
   name = normalize_os_name(get_os_name())
   return self.__architectures.get(name, 'unknown')
コード例 #25
0
 def test_alias_normalization(self):
     for normal_os, aliases in OS_ALIASES.items():
         for alias in aliases:
             self.assertEqual(normal_os, normalize_os_name(alias))
コード例 #26
0
ファイル: test_osutil.py プロジェクト: CaitieM20/pants
 def test_no_warnings_on_known_names(self):
   for name in known_os_names():
     with self.warnings() as warning_list:
       normalize_os_name(name)
       self.assertEqual(0, len(warning_list),
                        'Recieved unexpected warnings: {}'.format(warning_list))
コード例 #27
0
ファイル: test_osutil.py プロジェクト: CaitieM20/pants
 def test_warnings_on_unknown_names(self):
   name = 'I really hope no one ever names an operating system with this string.'
   with self.warnings() as warning_list:
     normalize_os_name(name)
     self.assertEqual(1, len(warning_list),
                      'Expected exactly one warning, but got: {}'.format(warning_list))
コード例 #28
0
ファイル: test_osutil.py プロジェクト: baroquebobcat/pants
 def test_warnings_on_unknown_names(self):
   name = 'I really hope no one ever names an operating system with this string.'
   with self.captured_logging(logging.WARNING) as captured:
     normalize_os_name(name)
     self.assertEqual(1, len(captured.warnings()),
                      'Expected exactly one warning, but got: {}'.format(captured.warnings()))
コード例 #29
0
ファイル: test_osutil.py プロジェクト: baroquebobcat/pants
 def test_no_warnings_on_known_names(self):
   for name in known_os_names():
     with self.captured_logging(logging.WARNING) as captured:
       normalize_os_name(name)
       self.assertEqual(0, len(captured.warnings()),
                        'Recieved unexpected warnings: {}'.format(captured.warnings()))
コード例 #30
0
ファイル: test_osutil.py プロジェクト: baroquebobcat/pants
 def test_alias_normalization(self):
   for normal_os, aliases in OS_ALIASES.items():
     for alias in aliases:
       self.assertEqual(normal_os, normalize_os_name(alias))
コード例 #31
0
ファイル: osutil_test.py プロジェクト: patricklaw/pants
def test_no_warnings_on_known_names(caplog) -> None:
    for name in _values(OS_ALIASES):
        normalize_os_name(name)
        assert len(caplog.records) == 0
コード例 #32
0
ファイル: osutil_test.py プロジェクト: patricklaw/pants
def test_warnings_on_unknown_names(caplog) -> None:
    name = "I really hope no one ever names an operating system with this string."
    normalize_os_name(name)
    assert len(caplog.records) == 1
    assert "Unknown operating system name" in caplog.text
コード例 #33
0
ファイル: osutil_test.py プロジェクト: zomglings/pants
def test_no_warnings_on_known_names(caplog) -> None:
    for name in known_os_names():
        normalize_os_name(name)
        assert len(caplog.records) == 0
コード例 #34
0
 def arch(self):
     name = normalize_os_name(get_os_name())
     return self.__architectures.get(name, 'unknown')
コード例 #35
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])
コード例 #36
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])
コード例 #37
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])