Skip to content

Commit

Permalink
Relocate task tests from tests/python/pants_test/task/ to the appropr…
Browse files Browse the repository at this point in the history
…iate backend

These tests have been here since before the legendary patrick refactor and belong in the backend pacakage corresponding to where the source module is defined.  It omits moving test_detect_duplicates and test_ivy_resolution_integration.py which currently have RB's in flight.

These are simple file moves, except for:
  - One orphaned test was removed (test_java_library_with_overrides.py) which was testing a feature that doesn't exist any more.
  - The tests in test_jar_publish_unit.py were rolled into test_jar_publish.py

Testing Done:
CI green at https://travis-ci.org/pantsbuild/pants/builds/93342067

Bugs closed: 2630

Reviewed at https://rbcommons.com/s/twitter/r/3183/
  • Loading branch information
ericzundel committed Nov 27, 2015
1 parent 471ed96 commit 6d5481d
Show file tree
Hide file tree
Showing 20 changed files with 237 additions and 297 deletions.
18 changes: 18 additions & 0 deletions tests/python/pants_test/backend/codegen/tasks/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ python_tests(
],
)

python_tests(
name = 'antlr_integration',
sources = ['test_antlr_integration.py'],
dependencies = [
'src/python/pants/fs',
'src/python/pants/util:contextutil',
'tests/python/pants_test:int-test',
]
)

python_tests(
name = 'jaxb_gen',
sources = ['test_jaxb_gen.py'],
Expand All @@ -63,6 +73,14 @@ python_tests(
],
)

python_tests(
name = 'protobuf_integration',
sources = ['test_protobuf_integration.py'],
dependencies = [
'tests/python/pants_test:int-test',
],
)

python_tests(
name = 'ragel_gen',
sources = ['test_ragel_gen.py'],
Expand Down
1 change: 1 addition & 0 deletions tests/python/pants_test/backend/jvm/targets/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ target(
name='targets',
dependencies=[
':jar_dependency',
':jar_library',
':jvm_app',
':jvm_binary',
':jvm_target',
Expand Down
187 changes: 158 additions & 29 deletions tests/python/pants_test/backend/jvm/tasks/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,21 @@ target(
':bootstrap_jvm_tools',
':bundle_create',
':checkstyle',
':check_published_deps',
':classpath_products',
':classpath_util',
':ivy_imports',
':ivy_resolve',
':ivy_utils',
':jar_publish_unit_test',
':jar_create',
':jar_publish',
':jar_task',
':junit_run',
':jvm_dependency_usage',
':jvm_platform_analysis',
':jvm_run',
':jvm_task',
':jvmdoc_gen',
':resources_task',
':prepare_resources',
':prepare_services',
Expand Down Expand Up @@ -129,6 +134,21 @@ python_tests(
]
)

python_tests(
name = 'check_published_deps',
sources = ['test_check_published_deps.py'],
dependencies = [
'src/python/pants/backend/core/targets:common',
'src/python/pants/backend/jvm:artifact',
'src/python/pants/backend/jvm:repository',
'src/python/pants/backend/jvm/targets:java',
'src/python/pants/backend/jvm/targets:jvm',
'src/python/pants/backend/jvm/tasks:check_published_deps',
'src/python/pants/build_graph',
'tests/python/pants_test/tasks:task_test_base',
]
)

python_tests(
name = 'classpath_products',
sources = ['test_classpath_products.py'],
Expand Down Expand Up @@ -196,14 +216,115 @@ python_tests(
)

python_tests(
name = 'jar_publish_unit_test',
sources = ['test_jar_publish_unit.py'],
name = 'jar_create',
sources = ['test_jar_create.py'],
dependencies = [
'src/python/pants/backend/android/targets:android',
'src/python/pants/backend/codegen/targets:java',
'src/python/pants/backend/core/targets:common',
'src/python/pants/backend/jvm/targets:java',
'src/python/pants/backend/jvm/targets:jvm',
'src/python/pants/backend/jvm/targets:scala',
'src/python/pants/backend/jvm/tasks:jar_create',
'src/python/pants/base:build_environment',
'src/python/pants/build_graph',
'src/python/pants/java/jar:manifest',
'src/python/pants/util:contextutil',
'src/python/pants/util:dirutil',
'tests/python/pants_test/base:context_utils',
'tests/python/pants_test/jvm:jar_task_test_base',
'tests/python/pants_test/tasks:task_test_base',
],
)

python_tests(
name = 'jar_publish',
sources = ['test_jar_publish.py'],
dependencies = [
'3rdparty/python:mock',
'src/python/pants/backend/jvm/targets:java',
'src/python/pants/backend/jvm/targets:jvm',
'src/python/pants/backend/jvm/tasks:jar_publish',
'src/python/pants/base:generator',
'src/python/pants/base:source_root',
'src/python/pants/build_graph',
'src/python/pants/scm:scm',
'src/python/pants/util:contextutil',
'src/python/pants/util:dirutil',
'tests/python/pants_test/tasks:task_test_base',
'tests/python/pants_test/testutils',
],
)

python_tests(
name = 'jar_publish_integration',
sources = ['test_jar_publish_integration.py'],
dependencies = [
'src/python/pants/base:build_environment',
'src/python/pants/util:contextutil',
'src/python/pants/util:dirutil',
'tests/python/pants_test:int-test',
],
)

python_tests(
name = 'jar_task',
sources = ['test_jar_task.py'],
dependencies = [
'3rdparty/python/twitter/commons:twitter.common.collections',
'3rdparty/python:six',
'src/python/pants/backend/jvm/targets:java',
'src/python/pants/backend/jvm/targets:jvm',
'src/python/pants/backend/jvm/tasks:jar_task',
'src/python/pants/base:source_root',
'src/python/pants/build_graph',
'src/python/pants/util:contextutil',
'src/python/pants/util:dirutil',
'tests/python/pants_test/jvm:jvm_tool_task_test_base',
]
)

python_tests(
name = 'junit_run',
sources = ['test_junit_run.py'],
dependencies = [
'3rdparty/python:mock',
'src/python/pants/backend/core/targets:common',
'src/python/pants/backend/jvm/targets:java',
'src/python/pants/backend/jvm/tasks:junit_run',
'src/python/pants/backend/python/tasks:python',
'src/python/pants/base:exceptions',
'src/python/pants/build_graph',
'src/python/pants/goal:products',
'src/python/pants/ivy',
'src/python/pants/java/distribution:distribution',
'src/python/pants/java:executor',
'src/python/pants/util:dirutil',
'src/python/pants/util:timeout',
'tests/python/pants_test/jvm:jvm_tool_task_test_base',
'tests/python/pants_test/subsystem:subsystem_utils',
]
)

python_tests(
name = 'junit_run_integration',
sources = ['test_junit_run_integration.py'],
dependencies = [
'src/python/pants/java/distribution',
'tests/python/pants_test:int-test',
'tests/python/pants_test/subsystem:subsystem_utils',
]
)

python_tests(
name = 'junit_tests_integration',
sources = ['test_junit_tests_integration.py'],
dependencies = [
'src/python/pants/util:contextutil',
'tests/python/pants_test:int-test',
],
)

python_library(
name = 'jvm_binary_task_test_base',
sources = ['jvm_binary_task_test_base.py'],
Expand All @@ -214,6 +335,16 @@ python_library(
]
)

python_tests(
name = 'jvm_bundle_integration',
sources = ['test_jvm_bundle_integration.py'],
dependencies = [
'src/python/pants/fs',
'src/python/pants/util:contextutil',
'tests/python/pants_test:int-test',
],
)

python_tests(
name = 'jvm_dependency_usage',
sources = ['test_jvm_dependency_usage.py'],
Expand Down Expand Up @@ -259,35 +390,15 @@ python_tests(
]
)

python_tests(
name = 'junit_run',
sources = ['test_junit_run.py'],
dependencies = [
'3rdparty/python:mock',
'src/python/pants/backend/core/targets:common',
'src/python/pants/backend/jvm/targets:java',
'src/python/pants/backend/jvm/tasks:junit_run',
'src/python/pants/backend/python/tasks:python',
'src/python/pants/base:exceptions',
'src/python/pants/build_graph',
'src/python/pants/goal:products',
'src/python/pants/ivy',
'src/python/pants/java/distribution:distribution',
'src/python/pants/java:executor',
'src/python/pants/util:dirutil',
'src/python/pants/util:timeout',
'tests/python/pants_test/jvm:jvm_tool_task_test_base',
'tests/python/pants_test/subsystem:subsystem_utils',
]
)

python_tests(
name = 'junit_run_integration',
sources = ['test_junit_run_integration.py'],
name = 'jvm_task',
sources = ['test_jvm_task.py'],
dependencies = [
'src/python/pants/java/distribution',
'tests/python/pants_test:int-test',
'tests/python/pants_test/subsystem:subsystem_utils',
'src/python/pants/backend/jvm/tasks:classpath_products',
'src/python/pants/backend/jvm/tasks:jvm_task',
'tests/python/pants_test/jvm:jvm_task_test_base',
'tests/python/pants_test/tasks:task_test_base',
]
)

Expand All @@ -302,6 +413,24 @@ python_tests(
]
)

python_tests(
name = 'jvm_run_integration',
sources = ['test_jvm_run_integration.py'],
dependencies = [
'tests/python/pants_test:int-test',
],
)

python_tests(
name = 'jvmdoc_gen',
sources = ['test_jvmdoc_gen.py'],
dependencies = [
'src/python/pants/backend/jvm/tasks:jvmdoc_gen',
'src/python/pants/base:exceptions',
'tests/python/pants_test/jvm:jvm_task_test_base'
]
)

python_tests(
name = 'resources_task',
sources = ['test_resources_task.py'],
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,63 @@ def test_fail_n_times(self):
foo.bar()

foo.bar()


class JarPublishAuthTest(TaskTestBase):
"""Tests for backend jvm JarPublish class"""

def _default_jvm_opts(self):
"""Return a fresh copy of this list every time."""
return ['jvm_opt_1', 'jvm_opt_2']

@classmethod
def task_type(cls):
return JarPublish

def setUp(self):
super(JarPublishAuthTest, self).setUp()

self.set_options(
jvm_options=['-Dfoo=bar'],
repos={
'some_ext_repo': {
'resolver': 'artifactory.foobar.com',
'confs': ['default', 'sources'],
'auth': '',
'help': 'You break it, you bought it',
}
}
)
context = self.context()
self._jar_publish = self.create_task(context)

def test_options_with_no_auth(self):
"""When called without authentication credentials, `JarPublish._ivy_jvm_options()` shouldn't
modify any options.
"""
self._jar_publish._jvm_options = self._default_jvm_opts()
repo = {}
modified_opts = self._jar_publish._ivy_jvm_options(repo)
self.assertEqual(modified_opts, self._default_jvm_opts())

def test_options_with_auth(self):
"""`JarPublish._ivy_jvm_options()` should produce the same list, when called multiple times
with authentication credentials.
"""
self._jar_publish._jvm_options = self._default_jvm_opts()

username = 'mjk'
password = 'h.'
creds_options = ['-Dlogin={}'.format(username), '-Dpassword={}'.format(password)]

repo = {
'auth': 'blah',
'username': username,
'password': password,
}
modified_opts = self._jar_publish._ivy_jvm_options(repo)
self.assertEqual(modified_opts, self._default_jvm_opts() + creds_options)

# Now run it again, and make sure we don't get dupes.
modified_opts = self._jar_publish._ivy_jvm_options(repo)
self.assertEqual(modified_opts, self._default_jvm_opts() + creds_options)
Loading

0 comments on commit 6d5481d

Please sign in to comment.