Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoke test runner at a more granular level for pypy shard. #513

Merged
merged 2 commits into from
Jun 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ install:
- pip install -U tox "setuptools<34"

script:
- tox -v
- ./scripts/ci.sh
10 changes: 10 additions & 0 deletions scripts/ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -euo pipefail

if [[ "$TOXENV" == "pypy" ]]; then
echo "pypy shard detected. invoking workaround for https://github.com/travis-ci/travis-ci/issues/9706"
tox -e list-tests | grep ^"RUNNABLE" | grep -v "tests/test_integration.py" | awk -F'\t' '{print $NF}' | xargs -L1 tox -v
else
tox -v
fi
37 changes: 37 additions & 0 deletions scripts/list_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python

import sys
import pytest


class Collector(object):

RUN_INDIVIDUALLY = ['tests/test_pex.py']

def __init__(self):
self._collected = set()

def iter_collected(self):
for collected in sorted(self._collected):
yield collected

def pytest_collectreport(self, report):
if report.failed:
raise pytest.UsageError('Errors during collection, aborting!')

def pytest_collection_modifyitems(self, items):
for item in items:
test_file = item.location[0]
if test_file in self.RUN_INDIVIDUALLY:
self._collected.add(item.nodeid)
else:
self._collected.add(test_file)


collector = Collector()
rv = pytest.main(['--collect-only'] + sys.argv[1:], plugins=[collector])

for test_target in collector.iter_collected():
print('RUNNABLE\t"{}"'.format(test_target))

sys.exit(rv)
8 changes: 6 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ deps =
wheel==0.29.0
packaging==16.8
setuptools<34.0
py27: mock
pypy: mock
list-tests: mock==2.0.0
py27: mock==2.0.0
pypy: mock==2.0.0
run: requests
requests: requests
requests: responses
Expand Down Expand Up @@ -55,6 +56,9 @@ commands =
# This is necessary due to https://bitbucket.org/hpk42/tox/issue/175/cant-do-substitution-base-commands
bash scripts/coverage.sh

[testenv:list-tests]
commands = python scripts/list_tests.py

[testenv:py27-coverage]
commands = {[integration]commands}

Expand Down