Skip to content

Commit

Permalink
Add some jdk tests for execution modes (pantsbuild#6631)
Browse files Browse the repository at this point in the history
Follow up for pantsbuild#6502
  • Loading branch information
wisechengyi authored Oct 15, 2018
1 parent f679089 commit aa656d6
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@

import os

from pants.backend.jvm.subsystems.zinc import Zinc
from pants.backend.jvm.targets.java_library import JavaLibrary
from pants.backend.jvm.tasks.classpath_products import ClasspathProducts
from pants.backend.jvm.tasks.jvm_compile.jvm_compile import JvmCompile
from pants.backend.jvm.tasks.jvm_compile.zinc.zinc_compile import BaseZincCompile
from pants.backend.jvm.tasks.nailgun_task import NailgunTaskBase
from pants.base.build_environment import get_buildroot
from pants_test.task_test_base import TaskTestBase


Expand Down Expand Up @@ -44,3 +48,30 @@ def test_if_runtime_classpath_exists(self):
resulting_classpath = task.create_runtime_classpath()
self.assertEqual([('default', pre_init_runtime_entry), ('default', compile_entry)],
resulting_classpath.get_for_target(target))


class BaseZincCompileJDKTest(TaskTestBase):
DEFAULT_CONF = 'default'
old_cwd = os.getcwd()

@classmethod
def task_type(cls):
return BaseZincCompile

def setUp(self):
os.chdir(get_buildroot())
super(BaseZincCompileJDKTest, self).setUp()

def tearDown(self):
os.chdir(self.old_cwd)
super(BaseZincCompileJDKTest, self).tearDown()

def test_subprocess_compile_jdk_being_symlink(self):
context = self.context(target_roots=[])
zinc = Zinc.Factory.global_instance().create(context.products, NailgunTaskBase.SUBPROCESS)
self.assertTrue(os.path.islink(zinc.dist.home))

def test_hermetic_jdk_being_underlying_dist(self):
context = self.context(target_roots=[])
zinc = Zinc.Factory.global_instance().create(context.products, NailgunTaskBase.HERMETIC)
self.assertFalse(os.path.islink(zinc.dist.home))

0 comments on commit aa656d6

Please sign in to comment.