Skip to content

Commit

Permalink
TST: Cleanup and clarify pypy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoZeke committed Dec 2, 2024
1 parent 893e5a1 commit fc0415c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 26 deletions.
6 changes: 6 additions & 0 deletions test/test_environment_bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import pytest

from asv import util

from . import tools

ENVIRONMENTS = []
Expand Down Expand Up @@ -116,6 +118,8 @@ def test_asv_benchmark(asv_project_factory, env):
"""
Test running ASV benchmarks in the specified environment.
"""
if util.IS_PYPY and env in ["rattler", "mamba"]:
pytest.skip("mamba and py-rattler only work for CPython")
project_dir = asv_project_factory(custom_config={})
subprocess.run(["asv", "machine", "--yes"], cwd=project_dir, check=True)
result = subprocess.run(
Expand Down Expand Up @@ -175,6 +179,8 @@ def test_asv_mamba(
Test running ASV benchmarks with various configurations,
checking for specific errors when failures are expected.
"""
if util.IS_PYPY:
pytest.skip("mamba and py-rattler only work for CPython")
project_dir = asv_project_factory(custom_config=config_modifier)
try:
subprocess.run(
Expand Down
43 changes: 17 additions & 26 deletions test/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ def test_profile_python_same(capsys, basic_conf):
assert "Installing" not in text


@pytest.mark.skipif(
util.IS_PYPY,
reason="pypy doesn't support profiles",
)
def test_profile_python_commit(capsys, basic_conf):

tmpdir, local, conf, machine_file = basic_conf
Expand All @@ -35,31 +39,18 @@ def test_profile_python_commit(capsys, basic_conf):
assert "Installing" in text

# Query the previous empty results results; there should be no issues here
if not util.ON_PYPY:
tools.run_asv_with_conf(conf, 'profile', "time_secondary.track_value",
f'{util.git_default_branch()}', _machine_file=machine_file)
text, err = capsys.readouterr()

assert "Profile data does not already exist" in text

tools.run_asv_with_conf(conf, 'run', "--profile",
"--bench=time_secondary.track_value",
f'{util.git_default_branch()}^!', _machine_file=machine_file)
else:
# The ASV main process doesn't use PyPy
with pytest.raises(util.UserError):
tools.run_asv_with_conf(conf, 'profile', "time_secondary.track_value",
f'{util.git_default_branch()}', _machine_file=machine_file)
tools.run_asv_with_conf(conf, 'profile', "time_secondary.track_value",
f'{util.git_default_branch()}', _machine_file=machine_file)
text, err = capsys.readouterr()

assert "Profile data does not already exist" in text

tools.run_asv_with_conf(conf, 'run', "--profile",
"--bench=time_secondary.track_value",
f'{util.git_default_branch()}^!', _machine_file=machine_file)
# Profile results should be present now
if not util.ON_PYPY:
tools.run_asv_with_conf(conf, 'profile', "time_secondary.track_value",
f'{util.git_default_branch()}', _machine_file=machine_file)
text, err = capsys.readouterr()

assert "Profile data does not already exist" not in text
else:
# The ASV main process doesn't use PyPy
with pytest.raises(util.UserError):
tools.run_asv_with_conf(conf, 'profile', "time_secondary.track_value",
f'{util.git_default_branch()}', _machine_file=machine_file)
tools.run_asv_with_conf(conf, 'profile', "time_secondary.track_value",
f'{util.git_default_branch()}', _machine_file=machine_file)
text, err = capsys.readouterr()

assert "Profile data does not already exist" not in text

0 comments on commit fc0415c

Please sign in to comment.