Skip to content

Commit

Permalink
test:modify regex pattern that matches test files
Browse files Browse the repository at this point in the history
  • Loading branch information
Raine-Yang-UofT committed Dec 28, 2024
1 parent 665b8dd commit 61df7b7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ jobs:
- name: Run tests
run: |
if [[ "${{ matrix.dependency }}" == "z3-solver" ]]; then
pytest tests -vv --cov python_ta --cov-config=.coveragerc --cov-report lcov \
pytest -vv --cov python_ta --cov-config=.coveragerc --cov-report lcov \
--ignore=tests/test_type_constraints --ignore=tests/test_type_inference \
--ignore=tests/test_debug/test_accumulation_table.py \
--ignore=tests/test_debug/test_recursion_table.py \
--ignore=tests/test_debug/test_snapshot_tracer.py
--ignore=tests/test_debug/test_snapshot_tracer.py tests
pytest -vv \
tests/test_debug/test_accumulation_table.py \
tests/test_debug/test_recursion_table.py \
tests/test_debug/test_snapshot_tracer.py
else
pytest tests -vv --cov python_ta --cov-config=.coveragerc --cov-report lcov --exclude-z3 \
pytest -vv --cov python_ta --cov-config=.coveragerc --cov-report lcov --exclude-z3 \
--ignore=tests/test_type_constraints --ignore=tests/test_type_inference \
--ignore=tests/test_debug/test_accumulation_table.py \
--ignore=tests/test_debug/test_recursion_table.py \
Expand Down
34 changes: 14 additions & 20 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
import python_ta.contracts

Z3_RELATED_TESTS = {
r"test_z3_constraints.py",
r"test_edge_feasibility.py",
r"test_impossible_condition_checker.py",
r"test_redundant_condition_checker.py",
r"TestInconsistentReturnCheckerZ3Option",
r"TestMissingReturnCheckerZ3Option",
r"TestOneIterationCheckerZ3Option",
r"TestPossiblyUndefinedCheckerZ3Option",
r"TestRedundantAssignmentCheckerZ3Option",
r"test_z3_parser.py",
r"tests/test_z3_constraints\.py",
r"tests/test_edge_feasibility\.py",
r"tests/test_impossible_condition_checker\.py",
r"tests/test_redundant_condition_checker\.py",
r"tests/test_z3_parser\.py",
r".*TestInconsistentReturnCheckerZ3Option.*",
r".*TestMissingReturnCheckerZ3Option.*",
r".*TestOneIterationCheckerZ3Option.*",
r".*TestPossiblyUndefinedCheckerZ3Option.*",
r".*TestRedundantAssignmentCheckerZ3Option.*",
}


Expand Down Expand Up @@ -55,14 +55,8 @@ def pytest_addoption(parser):

def pytest_collection_modifyitems(config, items):
"""Modify collected test items to exclude certain tests based on configuration."""
excluded_tests = []

if config.getoption("--exclude-z3"):
excluded_tests.extend(Z3_RELATED_TESTS)

# filter out excluded tests
items[:] = [
item
for item in items
if not any(re.search(pattern, item.nodeid) for pattern in excluded_tests)
]
skip_z3 = pytest.mark.skip(reason="Test requires z3-solver")
for item in items:
if any(re.search(pattern, item.nodeid) for pattern in Z3_RELATED_TESTS):
item.add_marker(skip_z3)

0 comments on commit 61df7b7

Please sign in to comment.