Skip to content

Commit 8a9787f

Browse files
anmyachevpbchekin
andauthored
Switch to pytest-skip instead of pytest-select (#3861)
Signed-off-by: Anatoly Myachev <anatoly.myachev@intel.com> Co-authored-by: Pavel Chekin <pavel.chekin@intel.com>
1 parent ed88733 commit 8a9787f

File tree

12 files changed

+24
-5380
lines changed

12 files changed

+24
-5380
lines changed

.github/workflows/auto-update-translator-cid.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
- name: Install test dependencies
6060
if: ${{ env.TARGET_PRID == null }}
6161
run: |
62-
pip install pytest pytest-xdist pytest-rerunfailures pytest-select pytest-timeout expecttest
62+
pip install pytest pytest-xdist pytest-rerunfailures pytest-skip pytest-timeout expecttest
6363
pip install git+https://github.com/kwasd/pytest-capturewarnings-ng.git@v1.2.0
6464
6565
- name: Get commit ID from Triton's spirv-llvm-translator.conf

.github/workflows/build-test-reusable.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,9 @@ jobs:
227227
- name: Pass rate
228228
run: |
229229
source ./scripts/capture-hw-details.sh
230-
python scripts/pass_rate.py --reports reports ${{ env.SKIPLIST }}
231-
python scripts/pass_rate.py --reports reports --json ${{ env.SKIPLIST }} > pass_rate.json
232-
python scripts/pass_rate.py --reports reports --suite tutorials --json ${{ env.SKIPLIST }} > pass_rate_tutorials.json
230+
python scripts/pass_rate.py --reports reports
231+
python scripts/pass_rate.py --reports reports --json > pass_rate.json
232+
python scripts/pass_rate.py --reports reports --suite tutorials --json > pass_rate_tutorials.json
233233
234234
- name: Upload pass rate report
235235
# upload reports only for the default branch

.github/workflows/build-test-windows.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ jobs:
152152
pip install defusedxml
153153
bash -c "\
154154
source ./scripts/capture-hw-details.sh; \
155-
python scripts/pass_rate.py --reports reports ${{ env.SKIPLIST }}; \
156-
python scripts/pass_rate.py --reports reports --json ${{ env.SKIPLIST }} > pass_rate.json; \
157-
python scripts/pass_rate.py --reports reports --suite tutorials --json ${{ env.SKIPLIST }} > pass_rate_tutorials.json; \
155+
python scripts/pass_rate.py --reports reports; \
156+
python scripts/pass_rate.py --reports reports --json > pass_rate.json; \
157+
python scripts/pass_rate.py --reports reports --suite tutorials --json > pass_rate_tutorials.json; \
158158
"
159159
160160
- name: Upload pass rate report

.github/workflows/pip-test-windows.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ jobs:
159159
cd ${{ env.NEW_WORKSPACE }}
160160
bash -c "\
161161
source ./scripts/capture-hw-details.sh; \
162-
python scripts/pass_rate.py --reports reports ${{ env.SKIPLIST }}; \
163-
python scripts/pass_rate.py --reports reports --json ${{ env.SKIPLIST }} > pass_rate.json; \
164-
python scripts/pass_rate.py --reports reports --suite tutorials --json ${{ env.SKIPLIST }} > pass_rate_tutorials.json; \
162+
python scripts/pass_rate.py --reports reports; \
163+
python scripts/pass_rate.py --reports reports --json > pass_rate.json; \
164+
python scripts/pass_rate.py --reports reports --suite tutorials --json > pass_rate_tutorials.json; \
165165
"
166166
167167
- name: Upload pass rate report

scripts/docs-triton.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export TRITON_PROJ=$BASE/intel-xpu-backend-for-triton
3636
export TRITON_PROJ_BUILD=$TRITON_PROJ/python/build
3737
export SCRIPTS_DIR=$(cd $(dirname "$0") && pwd)
3838

39-
python3 -m pip install lit pytest pytest-xdist pytest-rerunfailures pytest-select
39+
python3 -m pip install lit pytest pytest-xdist pytest-rerunfailures pytest-skip
4040

4141
source $SCRIPTS_DIR/pytest-utils.sh
4242
$SCRIPTS_DIR/install-pytorch.sh $([ $VENV = true ] && echo "--venv")

scripts/pass_rate.py

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import pathlib
99
import platform
1010
import sys
11-
from typing import Dict, List, Optional
11+
from typing import Dict, List
1212

1313
from defusedxml.ElementTree import parse
1414

@@ -66,30 +66,9 @@ def create_argument_parser() -> argparse.ArgumentParser:
6666
default='all',
6767
help='name of the test suite, default: %(default)s',
6868
)
69-
argument_parser.add_argument(
70-
'--skip-list',
71-
type=str,
72-
help='an exclude list dir used in pass rate calculation',
73-
)
7469
return argument_parser
7570

7671

77-
def get_deselected(report_path: pathlib.Path, skiplist_dir: pathlib.Path) -> int:
78-
"""Calculates deselected (via skiplist) tests."""
79-
skiplist_path = skiplist_dir / f'{report_path.stem}.txt'
80-
if not skiplist_path.exists():
81-
return 0
82-
with skiplist_path.open('r') as f:
83-
count = 0
84-
for line in f.readlines():
85-
# `strip` allows to skip lines with only '\n' character
86-
line = line.strip()
87-
# skip empty lines and comments
88-
if line and not line.startswith('#'):
89-
count += 1
90-
return count
91-
92-
9372
def get_warnings(reports_path: pathlib.Path, suite: str) -> List[TestWarning]:
9473
"""Returns a list of warnings for the specified suite."""
9574
path = reports_path / f'{suite}-warnings.json'
@@ -101,10 +80,10 @@ def get_warnings(reports_path: pathlib.Path, suite: str) -> List[TestWarning]:
10180

10281

10382
def get_missing_tests(warnings: List[TestWarning]) -> List[str]:
104-
"""Searches warnings for PytestSelectWarning and returns a list of missing tests."""
83+
"""Searches warnings for UserWarning and returns a list of missing tests."""
10584
tests = set()
10685
for warning in warnings:
107-
if 'PytestSelectWarning: pytest-select: Not all deselected' not in warning.message:
86+
if 'UserWarning: pytest-skip: Not all deselected' not in warning.message:
10887
continue
10988
for line in warning.message.splitlines():
11089
if line.startswith(' - '):
@@ -124,7 +103,7 @@ def get_all_missing_tests(reports_path: pathlib.Path) -> Dict[str, List[str]]:
124103
return all_missing_tests
125104

126105

127-
def parse_report(report_path: pathlib.Path, skiplist_dir: Optional[pathlib.Path]) -> ReportStats:
106+
def parse_report(report_path: pathlib.Path) -> ReportStats:
128107
"""Parses the specified report."""
129108
stats = ReportStats(name=report_path.stem)
130109
root = parse(report_path).getroot()
@@ -145,13 +124,6 @@ def parse_report(report_path: pathlib.Path, skiplist_dir: Optional[pathlib.Path]
145124
testsuite_fixme_tests.add(warning.location)
146125
stats.fixme += len(testsuite_fixme_tests)
147126

148-
test_unskip = os.getenv('TEST_UNSKIP', 'false')
149-
if test_unskip not in ('true', 'false'):
150-
raise ValueError('Error: please set TEST_UNSKIP true or false')
151-
if skiplist_dir and test_unskip == 'false':
152-
deselected = get_deselected(report_path, skiplist_dir)
153-
stats.skipped += deselected
154-
stats.total += deselected
155127
stats.passed = stats.total - stats.failed - stats.skipped - stats.xfailed
156128
return stats
157129

@@ -180,7 +152,7 @@ def find_stats(stats: List[ReportStats], name: str) -> ReportStats:
180152
def parse_junit_reports(args: argparse.Namespace) -> List[ReportStats]:
181153
"""Parses junit report in the specified directory."""
182154
reports_path = pathlib.Path(args.reports)
183-
return [parse_report(report, args.skiplist_dir) for report in reports_path.glob('*.xml')]
155+
return [parse_report(report) for report in reports_path.glob('*.xml')]
184156

185157

186158
def parse_tutorials_reports(args: argparse.Namespace) -> List[ReportStats]:
@@ -248,10 +220,6 @@ def main():
248220
"""Main."""
249221
args = create_argument_parser().parse_args()
250222
args.report_path = pathlib.Path(args.reports)
251-
if args.skip_list:
252-
args.skiplist_dir = pathlib.Path(args.skip_list)
253-
else:
254-
args.skiplist_dir = None
255223

256224
missing_tests = get_all_missing_tests(args.report_path)
257225
if missing_tests:

scripts/pytest-utils.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pytest() {
3939
sed -e '/^#/d' -e '/^\s*$/d' "$TRITON_TEST_SKIPLIST_DIR/$TRITON_TEST_SUITE.txt" > "$CURRENT_SKIPLIST_DIR/$TRITON_TEST_SUITE.txt"
4040
if [[ $TEST_UNSKIP = false ]]; then
4141
pytest_extra_args+=(
42-
"--deselect-from-file=$CURRENT_SKIPLIST_DIR/$TRITON_TEST_SUITE.txt"
42+
"--skip-from-file=$CURRENT_SKIPLIST_DIR/$TRITON_TEST_SUITE.txt"
4343
)
4444
else
4545
pytest_extra_args+=(

scripts/requirements-test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ tabulate
1414
pytest-xdist
1515
pytest-forked
1616
pytest-rerunfailures
17-
pytest-select
17+
pytest-skip
1818
pytest-timeout

0 commit comments

Comments
 (0)