def locator(self): with distribution(executables=EXE('bin/java', version='1')) as jdk1_home: with distribution(executables=EXE('bin/java', version='2')) as jdk2_home: with temporary_dir() as java_dist_dir1, temporary_dir() as java_dist_dir2: locator = _Locator(_UnknownEnvironment(_EnvVarEnvironment(), _LinuxEnvironment(java_dist_dir1, java_dist_dir2))) jdk1_home_link = os.path.join(java_dist_dir1, 'jdk1_home') jdk2_home_link = os.path.join(java_dist_dir2, 'jdk2_home') os.symlink(jdk1_home, jdk1_home_link) os.symlink(jdk2_home, jdk2_home_link) yield locator, jdk1_home_link, jdk2_home_link
def locator(self): with distribution(executables=EXE('bin/java', version='1')) as jdk1_home: with distribution(executables=EXE('bin/java', version='2')) as jdk2_home: with temporary_dir() as java_dist_dir1, temporary_dir() as java_dist_dir2: locator = _Locator(_UnknownEnvironment(_EnvVarEnvironment(), _LinuxEnvironment(java_dist_dir1, java_dist_dir2))) jdk1_home_link = os.path.join(java_dist_dir1, 'jdk1_home') jdk2_home_link = os.path.join(java_dist_dir2, 'jdk2_home') os.symlink(jdk1_home, jdk1_home_link) os.symlink(jdk2_home, jdk2_home_link) yield locator, jdk1_home_link, jdk2_home_link
def locator(self): with temporary_dir() as java_dist_dir1, temporary_dir() as java_dist_dir2, distribution( executables=EXE("bin/java", version="1"), dist_dir=java_dist_dir1 ) as jdk1_home, distribution( executables=EXE("bin/java", version="2"), dist_dir=java_dist_dir2 ) as jdk2_home: locator = _Locator( _UnknownEnvironment( _EnvVarEnvironment(), _LinuxEnvironment(java_dist_dir1, java_dist_dir2) ) ) yield locator, jdk1_home, jdk2_home
def test_locate_java_home_cache_uses_lub(self): # NB this ensures that looking into the cache follows a consistent ordering # it looks up min=1, min=3, which puts both dists into the cache # then it looks for min=1;max=3. Because traversing the cached dists goes lowest first, # it finds 1. with temporary_dir() as dist_dir, distribution( executables=EXE("bin/java", version="1"), dist_dir=dist_dir ) as jdk1_home, distribution( executables=EXE("bin/java", version="3"), dist_dir=dist_dir ) as jdk3_home: locator = _Locator( _UnknownEnvironment(_EnvVarEnvironment(), _LinuxEnvironment(dist_dir)) ) with env(JAVA_HOME=jdk1_home): dist = locator.locate(minimum_version="1") self.assertEqual(jdk1_home, dist.home) dist = locator.locate(minimum_version="3") self.assertEqual(jdk3_home, dist.home) dist = locator.locate(minimum_version="1", maximum_version="3") self.assertEqual(jdk1_home, dist.home)