forked from sympy/sympy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dynamically mark tests as slow/veryslow during pytest collection phase
- Loading branch information
Showing
5 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,3 @@ | ||
#!/bin/bash | ||
ABS_REPO_PATH=$(unset CDPATH && cd "$(dirname "$0")/.." && echo $PWD) | ||
python3 -m pytest --durations 0 --slow --veryslow >$ABS_REPO_PATH/.ci/durations.log |
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,39 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import json | ||
|
||
ci_folder = os.path.dirname(__file__) | ||
|
||
def read_log(): | ||
stop_token = '= FAILURES =' | ||
start_token = '= slowest test durations =' | ||
start_token_seen = False | ||
for line in open(os.path.join(ci_folder, 'durations.log')): | ||
if stop_token in line: | ||
return | ||
elif start_token_seen: | ||
time, kind, test_id = line.split() | ||
if kind != 'call': | ||
continue | ||
if time[-1] != 's': | ||
raise NotImplementedError("expected seconds") | ||
yield test_id, float(time[:-1]) | ||
elif start_token in line: | ||
start_token_seen = True | ||
|
||
|
||
def main(limits=(10, .1)): | ||
""" | ||
parses durations.log (see generate_durations_log.sh for how to generate that file) | ||
""" | ||
groupings = [[] for _ in range(len(limits))] | ||
for test_id, time in read_log(): | ||
for idx, lim in enumerate(limits): | ||
if time >= lim: | ||
groupings[idx].append(test_id) | ||
open(os.path.join(ci_folder, 'durations.json'), 'wt').write(json.dumps([sorted(gr) for gr in groupings])) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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 |
---|---|---|
|
@@ -71,3 +71,6 @@ sample.tex | |
|
||
# pytest cache folder | ||
.cache | ||
|
||
# pytest related data file for slow tests | ||
.ci/durations.log |
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