-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adopt bindep functionality from tox-bindep plugin (#93)
- Loading branch information
Showing
15 changed files
with
141 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"""Bindep check feature implementations.""" | ||
|
||
from __future__ import print_function | ||
|
||
import os | ||
import subprocess | ||
import sys | ||
|
||
|
||
def check_bindep() -> None: | ||
"""Check bindeps requirements or exit.""" | ||
if os.path.isfile("bindep.txt"): | ||
# as 'bindep --profiles' does not show user defined profiles like 'test' | ||
# it makes no sense to list them. | ||
cmd = [sys.executable, "-m", "bindep", "-b", "test"] | ||
# # determine profiles | ||
# result = subprocess.run( | ||
# [sys.executable, "-m", "bindep", "--profiles"], | ||
# check=False, | ||
# universal_newlines=True, | ||
# stdout=subprocess.PIPE, | ||
# ) | ||
# if result.returncode: | ||
# print("Bindep failed to list profiles: %s", result.stdout) | ||
# sys.exit(result.returncode) | ||
# lines = result.stdout.splitlines() | ||
# try: | ||
# profiles = lines[lines.index("Configuration profiles:") + 1 :] | ||
# if "test" in profiles: | ||
# cmd.append("test") | ||
# except ValueError: | ||
# pass | ||
|
||
result = subprocess.run( | ||
cmd, | ||
check=False, | ||
universal_newlines=True, | ||
stderr=subprocess.PIPE, | ||
stdout=subprocess.PIPE, | ||
) | ||
if result.returncode: | ||
print( | ||
f"Running '{' '.join(cmd)}' returned {result.returncode}, " | ||
"likely missing system dependencies." | ||
) | ||
if result.stdout: | ||
print(result.stdout) | ||
if result.stderr: | ||
print(result.stderr, file=sys.stderr) | ||
sys.exit(result.returncode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"""Tests.""" | ||
|
||
import functools | ||
import os | ||
|
||
|
||
def preserve_cwd(function): | ||
"""Decorator for restoring cwd.""" | ||
|
||
@functools.wraps(function) | ||
def decorator(*args, **kwargs): | ||
cwd = os.getcwd() | ||
try: | ||
return function(*args, **kwargs) | ||
finally: | ||
os.chdir(cwd) | ||
|
||
return decorator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
this-package-is-missing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[tox] | ||
skipsdist = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bash [test] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[tox] | ||
skipsdist = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
GARBAGE DATA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[tox] | ||
skipsdist = true |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""Unit tests.""" | ||
|
||
import os | ||
from runpy import run_module | ||
|
||
import pytest | ||
|
||
from . import preserve_cwd | ||
|
||
|
||
@preserve_cwd | ||
@pytest.mark.parametrize( | ||
("folder", "expected_rc"), | ||
( | ||
pytest.param("tests/fixtures/bindep_0", 1, id="0"), | ||
pytest.param("tests/fixtures/bindep_1", 0, id="1"), | ||
pytest.param("tests/fixtures/bindep_2", 1, id="2"), | ||
), | ||
) | ||
def test_bindep(folder: str, expected_rc: int) -> None: | ||
"""Tests that running tox with a bindep file that is missing deps fails.""" | ||
os.chdir(folder) | ||
with pytest.raises(SystemExit) as exc: | ||
run_module("tox", run_name="__main__") | ||
assert exc.type == SystemExit | ||
assert exc.value.code == expected_rc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
[tox] | ||
minversion = 4.0.2 | ||
skipsdist = true | ||
ignore_path = tests | ||
envlist = | ||
lint | ||
|
@@ -10,9 +9,12 @@ envlist = | |
|
||
[testenv] | ||
usedevelop = true | ||
description = | ||
Run tests | ||
devel: using devel branch of tox (unreleased) | ||
skip_install = false | ||
extras = test | ||
deps = | ||
-e ".[test]" | ||
devel: tox @ git+https://github.com/tox-dev/tox.git@main | ||
passenv = | ||
SSH_AUTH_SOCK | ||
|
@@ -25,14 +27,16 @@ setenv = | |
GIT_COMMITTER_EMAIL[email protected] | ||
PIP_DISABLE_PIP_VERSION_CHECK = 1 | ||
commands = | ||
coverage run -m pytest {posargs} | ||
sh -c "coverage combine -q --data-file={env:COVERAGE_FILE} {env:COVERAGE_FILE}.* && coverage xml && coverage report" | ||
python -m coverage run -m pytest {posargs} | ||
sh -c "python -m coverage combine -q --data-file={env:COVERAGE_FILE} {env:COVERAGE_FILE}.* && coverage report && coverage xml" | ||
allowlist_externals = | ||
sh | ||
rm | ||
package = editable | ||
|
||
[testenv:lint] | ||
skip_install = true | ||
description = Run linting | ||
deps = | ||
pre_commit | ||
commands = | ||
|