Skip to content

Commit 04684b6

Browse files
committed
refactor(test): standardize on codspeed for benchmarks
- Remove pytest-benchmark in favor of codspeed - Update test scripts to use codspeed exclusively - Narrow init file generation to src/ directory - Clean up test dependencies in pyproject.toml
1 parent edb209a commit 04684b6

4 files changed

Lines changed: 5 additions & 26 deletions

File tree

template/.config/copier/mise/tasks/bench.sh

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,7 @@ set -o errexit
55
set -o nounset
66
set -o pipefail
77

8-
function is-true() {
9-
case "${1,,}" in
10-
1 | on | true | y | yes) return 0 ;;
11-
0 | off | false | n | no | "") return 1 ;;
12-
*)
13-
echo "Invalid boolean: $1." >&2
14-
exit 1
15-
;;
16-
esac
17-
}
18-
198
# ref: <https://github.com/scientific-python/lazy-loader#early-failure>
209
export EAGER_IMPORT=1
2110

22-
if is-true "${CI-}"; then
23-
pytest --codspeed "$@"
24-
else
25-
pytest --benchmark-only --benchmark-autosave --numprocesses="0" "$@"
26-
fi
11+
pytest --codspeed "$@"

template/.config/copier/mise/tasks/gen-init.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ __getattr__, __dir__, __all__ = lazy.attach_stub(__name__, __file__)"
1111
N_LINES=$(echo "$CODE" | wc --lines)
1212

1313
git_root=$(git rev-parse --show-toplevel)
14-
readarray -t files < <(fd --fixed-strings --type file '__init__.pyi' "$git_root")
14+
readarray -t files < <(fd --fixed-strings --type file '__init__.pyi' "$git_root/src/")
1515
for file in "${files[@]}"; do
1616
file="${file/%".pyi"/".py"}"
1717
if [[ ! -f $file ]]; then

template/.config/copier/mise/tasks/test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function is-true() {
2020
export EAGER_IMPORT=1
2121

2222
if is-true "${CI-}"; then
23-
pytest --junit-xml="junit.xml" --cov --cov-branch --benchmark-disable --numprocesses="auto" "$@"
23+
pytest --junit-xml="junit.xml" --cov --cov-branch --numprocesses="auto" "$@"
2424
else
25-
pytest --benchmark-disable --numprocesses="auto" "$@"
25+
pytest --numprocesses="auto" "$@"
2626
fi

template/pyproject.toml.jinja

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,7 @@ docs = [
3131
"pymdown-extensions",
3232
"ruff",
3333
]
34-
test = [
35-
"pytest",
36-
"pytest-benchmark",
37-
"pytest-codspeed",
38-
"pytest-cov",
39-
"pytest-xdist",
40-
]
34+
test = ["pytest", "pytest-codspeed", "pytest-cov", "pytest-xdist"]
4135

4236
[project]
4337
authors = [{ email = "{{ author_email }}", name = "{{ author_name }}" }]

0 commit comments

Comments
 (0)