コード例 #1
0
def missing_jvm(version):
    with subsystem_instance(DistributionLocator):
        try:
            DistributionLocator.locate(minimum_version=version, maximum_version="{}.9999".format(version))
            return False
        except DistributionLocator.Error:
            return True
コード例 #2
0
def missing_jvm(version):
  with subsystem_instance(DistributionLocator):
    try:
      DistributionLocator.locate(minimum_version=version, maximum_version='{}.9999'.format(version))
      return False
    except DistributionLocator.Error:
      return True
コード例 #3
0
def get_two_distributions():
  with subsystem_instance(DistributionLocator):
    try:
      java7 = DistributionLocator.locate(minimum_version='1.7', maximum_version='1.7.9999')
      java8 = DistributionLocator.locate(minimum_version='1.8', maximum_version='1.8.9999')
      return java7, java8
    except DistributionLocator.Error:
      return None
コード例 #4
0
def get_two_distributions():
  with subsystem_instance(DistributionLocator):
    try:
      java7 = DistributionLocator.locate(minimum_version='1.7', maximum_version='1.7.9999')
      java8 = DistributionLocator.locate(minimum_version='1.8', maximum_version='1.8.9999')
      return java7, java8
    except DistributionLocator.Error:
      return None
コード例 #5
0
 def test_default_to_path(self):
   with self.java_home_exe() as (jdk1_home, jdk2_home):
     with distribution(executables=EXE('bin/java', version='3')) as path_jdk:
       with env(PATH=os.path.join(path_jdk, 'bin')):
         dist = DistributionLocator.locate(minimum_version='2')
         self.assertEqual(path_jdk, dist.home)
         dist = DistributionLocator.locate(maximum_version='2')
         self.assertEqual(jdk1_home, dist.home)
コード例 #6
0
ファイル: test_distribution.py プロジェクト: youprofit/pants
 def test_locate_trumps_path(self):
     with self.java_home_exe() as (jdk1_home, jdk2_home):
         with distribution(
                 executables=exe('bin/java', version='3')) as path_jdk:
             with env(PATH=os.path.join(path_jdk, 'bin')):
                 dist = DistributionLocator.locate()
                 self.assertEqual(jdk1_home, dist.home)
                 dist = DistributionLocator.locate(minimum_version='3')
                 self.assertEqual(path_jdk, dist.home)
コード例 #7
0
 def test_locate_java_home_trumps(self):
   with self.java_home_exe() as (jdk1_home, jdk2_home):
     with distribution(executables=EXE('bin/java', version='3')) as java_home:
       with env(JAVA_HOME=java_home):
         dist = DistributionLocator.locate()
         self.assertEqual(java_home, dist.home)
         dist = DistributionLocator.locate(maximum_version='1.1')
         self.assertEqual(jdk1_home, dist.home)
         dist = DistributionLocator.locate(minimum_version='1.1', maximum_version='2')
         self.assertEqual(jdk2_home, dist.home)
コード例 #8
0
ファイル: test_distribution.py プロジェクト: youprofit/pants
 def test_locate_java_home_trumps(self):
     with self.java_home_exe() as (jdk1_home, jdk2_home):
         with distribution(
                 executables=exe('bin/java', version='3')) as java_home:
             with env(JAVA_HOME=java_home):
                 dist = DistributionLocator.locate()
                 self.assertEqual(java_home, dist.home)
                 dist = DistributionLocator.locate(maximum_version='1.1')
                 self.assertEqual(jdk1_home, dist.home)
                 dist = DistributionLocator.locate(minimum_version='1.1',
                                                   maximum_version='2')
                 self.assertEqual(jdk2_home, dist.home)
コード例 #9
0
  def test_validate_live(self):
    with self.assertRaises(Distribution.Error):
      Distribution(bin_path=os.path.dirname(self.JAVA), minimum_version='999.9.9').validate()
    with self.assertRaises(Distribution.Error):
      Distribution(bin_path=os.path.dirname(self.JAVA), maximum_version='0.0.1').validate()

    Distribution(bin_path=os.path.dirname(self.JAVA)).validate()
    Distribution(bin_path=os.path.dirname(self.JAVA), minimum_version='1.3.1').validate()
    Distribution(bin_path=os.path.dirname(self.JAVA), maximum_version='999.999.999').validate()
    Distribution(bin_path=os.path.dirname(self.JAVA), minimum_version='1.3.1',
                 maximum_version='999.999.999').validate()
    with subsystem_instance(DistributionLocator):
      DistributionLocator.locate(jdk=False)
コード例 #10
0
 def test_no_jvm_restriction(self):
   with subsystem_instance(DistributionLocator):
     distribution = DistributionLocator.locate()
   target_spec = 'testprojects/src/java/org/pantsbuild/testproject/printversion'
   run = self.run_pants(['run', target_spec])
   self.assert_success(run)
   self.assertIn('java.home:{}'.format(distribution.home), run.stdout_data)
コード例 #11
0
 def test_no_jvm_restriction(self):
     with subsystem_instance(DistributionLocator):
         distribution = DistributionLocator.locate()
     target_spec = 'testprojects/src/java/org/pantsbuild/testproject/printversion'
     run = self.run_pants(['run', target_spec])
     self.assert_success(run)
     self.assertIn('java.home:{}'.format(distribution.home),
                   run.stdout_data)
コード例 #12
0
ファイル: test_distribution.py プロジェクト: youprofit/pants
    def test_validate_live(self):
        with self.assertRaises(Distribution.Error):
            Distribution(bin_path=os.path.dirname(self.JAVA),
                         minimum_version='999.9.9').validate()
        with self.assertRaises(Distribution.Error):
            Distribution(bin_path=os.path.dirname(self.JAVA),
                         maximum_version='0.0.1').validate()

        Distribution(bin_path=os.path.dirname(self.JAVA)).validate()
        Distribution(bin_path=os.path.dirname(self.JAVA),
                     minimum_version='1.3.1').validate()
        Distribution(bin_path=os.path.dirname(self.JAVA),
                     maximum_version='999.999.999').validate()
        Distribution(bin_path=os.path.dirname(self.JAVA),
                     minimum_version='1.3.1',
                     maximum_version='999.999.999').validate()
        with subsystem_instance(DistributionLocator):
            DistributionLocator.locate(jdk=False)
コード例 #13
0
 def test_jvm_meets_min_and_max_distribution(self):
   with subsystem_instance(DistributionLocator):
     distribution = DistributionLocator.locate()
   target_spec = 'testprojects/src/java/org/pantsbuild/testproject/printversion'
   run = self.run_pants(['run', target_spec], config={
     'jvm-distributions': {
       'minimum_version': str(distribution.version),
       'maximum_version': str(distribution.version)
     }
   })
   self.assert_success(run)
   self.assertIn('java.home:{}'.format(distribution.home), run.stdout_data)
コード例 #14
0
 def test_jvm_meets_min_and_max_distribution(self):
     with subsystem_instance(DistributionLocator):
         distribution = DistributionLocator.locate()
     target_spec = 'testprojects/src/java/org/pantsbuild/testproject/printversion'
     run = self.run_pants(
         ['run', target_spec],
         config={
             'jvm-distributions': {
                 'minimum_version': str(distribution.version),
                 'maximum_version': str(distribution.version)
             }
         })
     self.assert_success(run)
     self.assertIn('java.home:{}'.format(distribution.home),
                   run.stdout_data)
コード例 #15
0
ファイル: test_distribution.py プロジェクト: youprofit/pants
 def test_locate_java_not_executable(self):
     with distribution(files='bin/java') as dist_root:
         with env(PATH=os.path.join(dist_root, 'bin')):
             with self.assertRaises(Distribution.Error):
                 DistributionLocator.locate()
コード例 #16
0
ファイル: test_distribution.py プロジェクト: youprofit/pants
 def test_locate_version_to_high(self):
     with distribution(executables=exe('bin/java', '1.8.0')) as dist_root:
         with env(PATH=os.path.join(dist_root, 'bin')):
             with self.assertRaises(Distribution.Error):
                 DistributionLocator.locate(maximum_version='1.7.999')
コード例 #17
0
 def test_locate_jdk1(self):
   with env():
     with self.java_home_exe() as (jdk1_home, _):
       dist = DistributionLocator.locate()
       self.assertEqual(jdk1_home, dist.home)
コード例 #18
0
 def test_locate_via_java_home(self):
   with distribution(executables=EXE('bin/java')) as dist_root:
     with env(JAVA_HOME=dist_root):
       DistributionLocator.locate()
コード例 #19
0
 def test_locate_version_less_then_or_equal(self):
   with distribution(executables=EXE('bin/java', '1.7.0')) as dist_root:
     with env(PATH=os.path.join(dist_root, 'bin')):
       DistributionLocator.locate(maximum_version='1.7.999')
コード例 #20
0
 def test_locate_jdk_by_path(self):
   with distribution(executables=[EXE('bin/java'), EXE('bin/javac')]) as dist_root:
     with env(PATH=os.path.join(dist_root, 'bin')):
       DistributionLocator.locate(jdk=True)
コード例 #21
0
 def test_locate_invalid_java_home(self):
   with distribution(executables=EXE('java')) as dist_root:
     with env(JAVA_HOME=dist_root):
       with self.assertRaises(Distribution.Error):
         DistributionLocator.locate()
コード例 #22
0
ファイル: test_distribution.py プロジェクト: youprofit/pants
 def test_locate_jdk_by_path(self):
     with distribution(executables=[exe('bin/java'),
                                    exe('bin/javac')]) as dist_root:
         with env(PATH=os.path.join(dist_root, 'bin')):
             DistributionLocator.locate(jdk=True)
コード例 #23
0
ファイル: test_distribution.py プロジェクト: youprofit/pants
 def test_locate_jdk_via_jre_path(self):
     with distribution(executables=[exe('jre/bin/java'),
                                    exe('bin/javac')],
                       java_home='jre') as dist_root:
         with env(PATH=os.path.join(dist_root, 'jre', 'bin')):
             DistributionLocator.locate(jdk=True)
コード例 #24
0
ファイル: test_distribution.py プロジェクト: youprofit/pants
 def test_locate_version_less_then_or_equal(self):
     with distribution(executables=exe('bin/java', '1.7.0')) as dist_root:
         with env(PATH=os.path.join(dist_root, 'bin')):
             DistributionLocator.locate(maximum_version='1.7.999')
コード例 #25
0
ファイル: test_distribution.py プロジェクト: youprofit/pants
 def test_validate_live_jdk(self):
     Distribution(bin_path=os.path.dirname(self.JAVAC), jdk=True).validate()
     Distribution(bin_path=os.path.dirname(self.JAVAC),
                  jdk=True).binary('javap')
     with subsystem_instance(DistributionLocator):
         DistributionLocator.locate(jdk=True)
コード例 #26
0
ファイル: test_distribution.py プロジェクト: youprofit/pants
 def test_locate_version_within_range(self):
     with distribution(executables=exe('bin/java', '1.7.0')) as dist_root:
         with env(PATH=os.path.join(dist_root, 'bin')):
             DistributionLocator.locate(minimum_version='1.6.0',
                                        maximum_version='1.7.999')
コード例 #27
0
ファイル: test_distribution.py プロジェクト: youprofit/pants
 def test_locate_via_java_home(self):
     with distribution(executables=exe('bin/java')) as dist_root:
         with env(JAVA_HOME=dist_root):
             DistributionLocator.locate()
コード例 #28
0
ファイル: test_distribution.py プロジェクト: youprofit/pants
 def test_locate_jdk1(self):
     with env():
         with self.java_dist_dir() as (jdk1_home, _):
             dist = DistributionLocator.locate(maximum_version='1')
             self.assertEqual(jdk1_home, dist.home)
コード例 #29
0
ファイル: test_distribution.py プロジェクト: youprofit/pants
 def test_locate_jdk2(self):
     with env():
         with self.java_home_exe() as (_, jdk2_home):
             dist = DistributionLocator.locate(minimum_version='2')
             self.assertEqual(jdk2_home, dist.home)
コード例 #30
0
 def test_locate_version_to_high(self):
   with distribution(executables=EXE('bin/java', '1.8.0')) as dist_root:
     with env(PATH=os.path.join(dist_root, 'bin')):
       with self.assertRaises(Distribution.Error):
         DistributionLocator.locate(maximum_version='1.7.999')
コード例 #31
0
ファイル: test_distribution.py プロジェクト: youprofit/pants
 def test_locate_none(self):
     with env():
         with self.assertRaises(Distribution.Error):
             with subsystem_instance(DistributionLocator):
                 DistributionLocator.locate()
コード例 #32
0
 def test_locate_jre_by_path(self):
   with distribution(executables=EXE('bin/java')) as dist_root:
     with env(PATH=os.path.join(dist_root, 'bin')):
       DistributionLocator.locate()
コード例 #33
0
ファイル: test_distribution.py プロジェクト: youprofit/pants
 def test_locate_jre_by_path(self):
     with distribution(executables=exe('bin/java')) as dist_root:
         with env(PATH=os.path.join(dist_root, 'bin')):
             DistributionLocator.locate()
コード例 #34
0
 def test_locate_jdk_via_jre_path(self):
   with distribution(executables=[EXE('jre/bin/java'), EXE('bin/javac')],
                     java_home='jre') as dist_root:
     with env(PATH=os.path.join(dist_root, 'jre', 'bin')):
       DistributionLocator.locate(jdk=True)
コード例 #35
0
ファイル: test_distribution.py プロジェクト: jduan/pants
 def test_locate_version_greater_then_or_equal(self):
   with distribution(executables=exe('bin/java', '1.7.0')) as dist_root:
     with env(PATH=os.path.join(dist_root, 'bin')):
       DistributionLocator.locate(minimum_version='1.6.0')
コード例 #36
0
 def test_locate_version_within_range(self):
   with distribution(executables=EXE('bin/java', '1.7.0')) as dist_root:
     with env(PATH=os.path.join(dist_root, 'bin')):
       DistributionLocator.locate(minimum_version='1.6.0', maximum_version='1.7.999')
コード例 #37
0
ファイル: test_distribution.py プロジェクト: youprofit/pants
 def test_locate_invalid_java_home(self):
     with distribution(executables=exe('java')) as dist_root:
         with env(JAVA_HOME=dist_root):
             with self.assertRaises(Distribution.Error):
                 DistributionLocator.locate()
コード例 #38
0
 def test_locate_jdk1(self):
   with env():
     with self.java_dist_dir() as (jdk1_home, _):
       dist = DistributionLocator.locate(maximum_version='1')
       self.assertEqual(jdk1_home, dist.home)
コード例 #39
0
 def test_locate_none(self):
   with env():
     with self.assertRaises(Distribution.Error):
       with subsystem_instance(DistributionLocator):
         DistributionLocator.locate()
コード例 #40
0
 def test_locate_jdk2(self):
   with env():
     with self.java_home_exe() as (_, jdk2_home):
       dist = DistributionLocator.locate(minimum_version='2')
       self.assertEqual(jdk2_home, dist.home)
コード例 #41
0
 def test_locate_java_not_executable(self):
   with distribution(files='bin/java') as dist_root:
     with env(PATH=os.path.join(dist_root, 'bin')):
       with self.assertRaises(Distribution.Error):
         DistributionLocator.locate()
コード例 #42
0
ファイル: test_distribution.py プロジェクト: youprofit/pants
 def test_locate_jdk_is_jre(self):
     with distribution(executables=exe('bin/java')) as dist_root:
         with env(PATH=os.path.join(dist_root, 'bin')):
             with self.assertRaises(Distribution.Error):
                 DistributionLocator.locate(jdk=True)
コード例 #43
0
 def test_locate_jdk_is_jre(self):
   with distribution(executables=EXE('bin/java')) as dist_root:
     with env(PATH=os.path.join(dist_root, 'bin')):
       with self.assertRaises(Distribution.Error):
         DistributionLocator.locate(jdk=True)
コード例 #44
0
 def test_validate_live_jdk(self):
   Distribution(bin_path=os.path.dirname(self.JAVAC), jdk=True).validate()
   Distribution(bin_path=os.path.dirname(self.JAVAC), jdk=True).binary('javap')
   with subsystem_instance(DistributionLocator):
     DistributionLocator.locate(jdk=True)
コード例 #45
0
ファイル: test_distribution.py プロジェクト: youprofit/pants
 def test_locate_jdk1(self):
     with env():
         with self.java_home_exe() as (jdk1_home, _):
             dist = DistributionLocator.locate()
             self.assertEqual(jdk1_home, dist.home)