Skip to content

Commit

Permalink
fix up testing to conform to the new snapshot versioning for local dists
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicexplorer committed Jul 3, 2018
1 parent 7fbc9f1 commit 14e2f0f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 26 deletions.
19 changes: 2 additions & 17 deletions tests/python/pants_test/backend/python/tasks/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ python_library(
)

python_native_code_test_files = [
# TODO: This test does not have any platform-specific testing right now, but that will be
# changed when #5815 is merged.
'test_build_local_python_distributions.py',
'test_python_distribution_integration.py',
'test_ctypes_integration.py',
]

python_tests(
Expand All @@ -38,7 +37,7 @@ python_tests(
'tests/python/pants_test:int-test',
'tests/python/pants_test/engine:scheduler_test_base',
],
tags={'platform_specific_behavior'},
tags={'platform_specific_behavior', 'integration'},
timeout=2400,
)

Expand Down Expand Up @@ -91,20 +90,6 @@ python_tests(
timeout=2400
)

python_tests(
name='ctypes_integration',
sources=['test_ctypes_integration.py', 'test_python_distribution_integration.py'],
dependencies=[
'src/python/pants/base:build_environment',
'src/python/pants/util:contextutil',
'src/python/pants/util:process_handler',
'tests/python/pants_test:int-test',
'tests/python/pants_test/backend/python/tasks:python_task_test_base',
],
tags={'integration'},
timeout=2400,
)

python_tests(
name='python_isort_integration',
sources=['test_python_isort_integration.py'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

import glob
import os
import re
from zipfile import ZipFile

from pants.backend.native.config.environment import Platform
from pants.option.scope import GLOBAL_SCOPE_CONFIG_SECTION
from pants.util.collections import assert_single_element
from pants.util.contextutil import temporary_dir
from pants.util.dirutil import is_executable
from pants.util.process_handler import subprocess
Expand Down Expand Up @@ -47,23 +49,26 @@ def test_binary(self):
pex = os.path.join(tmp_dir, 'bin.pex')
self.assertTrue(is_executable(pex))

wheel_glob = os.path.join(tmp_dir, 'ctypes_test-0.0.1-*.whl')
globbed_wheel = glob.glob(wheel_glob)
self.assertEqual(len(globbed_wheel), 1)
wheel_dist = globbed_wheel[0]
# The + is because we append the target's fingerprint to the version. We test this version
# string in test_build_local_python_distributions.py.
wheel_glob = os.path.join(tmp_dir, 'ctypes_test-1.0.0+*.whl')
wheel_dist_with_path = assert_single_element(glob.glob(wheel_glob))
wheel_dist = re.sub('^{}{}'.format(re.escape(tmp_dir), os.path.sep), '', wheel_dist_with_path)

_, _, wheel_platform = name_and_platform(wheel_dist)
dist_name, dist_version, wheel_platform = name_and_platform(wheel_dist)
self.assertEqual(dist_name, 'ctypes_test')
contains_current_platform = Platform.create().resolve_platform_specific({
'darwin': lambda: wheel_platform.startswith('macosx'),
'linux': lambda: wheel_platform.startswith('linux'),
})
self.assertTrue(contains_current_platform)

# Verify that the wheel contains our shared libraries.
wheel_files = ZipFile(wheel_dist).namelist()
wheel_files = ZipFile(wheel_dist_with_path).namelist()

dist_versioned_name = '{}-{}.data'.format(dist_name, dist_version)
for shared_lib_filename in ['libasdf-c.so', 'libasdf-cpp.so']:
full_path_in_wheel = os.path.join('ctypes_test-0.0.1.data', 'data', shared_lib_filename)
full_path_in_wheel = os.path.join(dist_versioned_name, 'data', shared_lib_filename)
self.assertIn(full_path_in_wheel, wheel_files)

# Execute the binary and ensure its output is correct.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ def _assert_native_greeting(self, output):
def test_pants_binary(self):
with temporary_dir() as tmp_dir:
pex = os.path.join(tmp_dir, 'main.pex')
wheel_glob = os.path.join(tmp_dir, 'fasthello-1.0.0-*.whl')
# The + is because we append the target's fingerprint to the version. We test this version
# string in test_build_local_python_distributions.py.
wheel_glob = os.path.join(tmp_dir, 'fasthello-1.0.0+*.whl')
command=[
'--pants-distdir={}'.format(tmp_dir), 'binary', '{}:main'.format(self.fasthello_project)]
pants_run = self.run_pants(command=command)
Expand Down Expand Up @@ -73,7 +75,7 @@ def test_invalidation(self):

def test_pants_test(self):
with temporary_dir() as tmp_dir:
wheel_glob = os.path.join(tmp_dir, 'fasthello-1.0.0-*.whl')
wheel_glob = os.path.join(tmp_dir, '*.whl')
command=[
'--pants-distdir={}'.format(tmp_dir),
'test',
Expand Down

0 comments on commit 14e2f0f

Please sign in to comment.