Skip to content

Commit

Permalink
Use --pyargs to select package to test (#191)
Browse files Browse the repository at this point in the history
Also do not switch out of source path when running tests.

- Allow testing src/ layout tests
- Better support editable install tests

See #185
  • Loading branch information
stefanv authored May 22, 2024
2 parents 7bc2468 + 7830aec commit 69b2cb0
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions spin/cmds/meson.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,14 @@ def test(
ctx.invoke(build_cmd)

package = cfg.get("tool.spin.package", None)
if package is None:
print(
"Please specify `package = packagename` under `tool.spin` section of `pyproject.toml`"
)
raise SystemExit(1)

if (not pytest_args) and (not tests):
pytest_args = (package,)
if pytest_args == (None,):
print(
"Please specify `package = packagename` under `tool.spin` section of `pyproject.toml`"
)
sys.exit(1)
tests = package

site_path = _set_pythonpath()
if site_path:
Expand Down Expand Up @@ -496,12 +497,9 @@ def test(
else:
cmd = ["pytest"]

cwd = os.getcwd()
pytest_p = _run(
cmd + ([f"--rootdir={site_path}"] if site_path else []) + list(pytest_args),
cwd=site_path,
cmd + list(pytest_args),
)
os.chdir(cwd)

if gcov:
# Verify the tools are present
Expand Down

0 comments on commit 69b2cb0

Please sign in to comment.