-
Notifications
You must be signed in to change notification settings - Fork 983
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
run tests in parallel locally with makefile
- Loading branch information
1 parent
91798e1
commit 0d3115f
Showing
20 changed files
with
1,287 additions
and
1,195 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
SHELL := /bin/bash | ||
|
||
PY_MODULE := slither | ||
|
||
ALL_PY_SRCS := $(shell find $(PY_MODULE) -name '*.py') \ | ||
$(shell find test -name '*.py') | ||
|
||
# Optionally overriden by the user, if they're using a virtual environment manager. | ||
VENV ?= env | ||
|
||
# On Windows, venv scripts/shims are under `Scripts` instead of `bin`. | ||
VENV_BIN := $(VENV)/bin | ||
ifeq ($(OS),Windows_NT) | ||
VENV_BIN := $(VENV)/Scripts | ||
endif | ||
|
||
# Optionally overridden by the user in the `release` target. | ||
BUMP_ARGS := | ||
|
||
# Optionally overridden by the user in the `test` target. | ||
TESTS := | ||
|
||
# Optionally overridden by the user/CI, to limit the installation to a specific | ||
# subset of development dependencies. | ||
SLITHER_EXTRA := dev | ||
|
||
# If the user selects a specific test pattern to run, set `pytest` to fail fast | ||
# and only run tests that match the pattern. | ||
# Otherwise, run all tests and enable coverage assertions, since we expect | ||
# complete test coverage. | ||
ifneq ($(TESTS),) | ||
TEST_ARGS := -x -k $(TESTS) | ||
COV_ARGS := | ||
else | ||
TEST_ARGS := -n auto | ||
COV_ARGS := --cov-append # --fail-under 100 | ||
endif | ||
|
||
.PHONY: all | ||
all: | ||
@echo "Run my targets individually!" | ||
|
||
.PHONY: dev | ||
dev: $(VENV)/pyvenv.cfg | ||
|
||
.PHONY: run | ||
run: $(VENV)/pyvenv.cfg | ||
@. $(VENV_BIN)/activate && slither $(ARGS) | ||
|
||
$(VENV)/pyvenv.cfg: pyproject.toml | ||
# Create our Python 3 virtual environment | ||
python3 -m venv env | ||
$(VENV_BIN)/python -m pip install --upgrade pip | ||
$(VENV_BIN)/python -m pip install -e .[$(SLITHER_EXTRA)] | ||
|
||
.PHONY: lint | ||
lint: $(VENV)/pyvenv.cfg | ||
. $(VENV_BIN)/activate && \ | ||
black --check $(ALL_PY_SRCS) && \ | ||
pylint $(ALL_PY_SRCS) | ||
# ruff $(ALL_PY_SRCS) && \ | ||
# mypy $(PY_MODULE) && | ||
|
||
.PHONY: reformat | ||
reformat: | ||
. $(VENV_BIN)/activate && \ | ||
black $(PY_MODULE) | ||
|
||
.PHONY: test tests | ||
test tests: $(VENV)/pyvenv.cfg | ||
. $(VENV_BIN)/activate && \ | ||
pytest --cov=$(PY_MODULE) $(T) $(TEST_ARGS) && \ | ||
python -m coverage report -m $(COV_ARGS) | ||
|
||
.PHONY: doc | ||
doc: $(VENV)/pyvenv.cfg | ||
. $(VENV_BIN)/activate && \ | ||
PDOC_ALLOW_EXEC=1 pdoc -o html slither '!slither.tools' | ||
|
||
.PHONY: package | ||
package: $(VENV)/pyvenv.cfg | ||
. $(VENV_BIN)/activate && \ | ||
python3 -m build | ||
|
||
.PHONY: edit | ||
edit: | ||
$(EDITOR) $(ALL_PY_SRCS) |
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,27 @@ | ||
import pytest | ||
from filelock import FileLock | ||
from solc_select import solc_select | ||
|
||
@pytest.fixture(scope="session") | ||
def solc_versions_installed(): | ||
"""List of solc versions available in the test environment.""" | ||
return [] | ||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def register_solc_versions_installed(solc_versions_installed): | ||
solc_versions_installed.extend(solc_select.installed_versions()) | ||
|
||
@pytest.fixture(scope="session") | ||
def use_solc_version(request, solc_versions_installed): | ||
def _use_solc_version(version): | ||
print(version) | ||
if version not in solc_versions_installed: | ||
print("Installing solc version", version) | ||
solc_select.install_artifacts([version]) | ||
artifact_path = solc_select.artifact_path(version) | ||
lock = FileLock(artifact_path) | ||
try: | ||
yield artifact_path | ||
finally: | ||
lock.release() | ||
return _use_solc_version |
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
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
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
Oops, something went wrong.