Skip to content

Commit 69b2cb0

Browse files
authored
Use --pyargs to select package to test (#191)
Also do not switch out of source path when running tests. - Allow testing src/ layout tests - Better support editable install tests See #185
2 parents 7bc2468 + 7830aec commit 69b2cb0

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

spin/cmds/meson.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -441,13 +441,14 @@ def test(
441441
ctx.invoke(build_cmd)
442442

443443
package = cfg.get("tool.spin.package", None)
444+
if package is None:
445+
print(
446+
"Please specify `package = packagename` under `tool.spin` section of `pyproject.toml`"
447+
)
448+
raise SystemExit(1)
449+
444450
if (not pytest_args) and (not tests):
445-
pytest_args = (package,)
446-
if pytest_args == (None,):
447-
print(
448-
"Please specify `package = packagename` under `tool.spin` section of `pyproject.toml`"
449-
)
450-
sys.exit(1)
451+
tests = package
451452

452453
site_path = _set_pythonpath()
453454
if site_path:
@@ -496,12 +497,9 @@ def test(
496497
else:
497498
cmd = ["pytest"]
498499

499-
cwd = os.getcwd()
500500
pytest_p = _run(
501-
cmd + ([f"--rootdir={site_path}"] if site_path else []) + list(pytest_args),
502-
cwd=site_path,
501+
cmd + list(pytest_args),
503502
)
504-
os.chdir(cwd)
505503

506504
if gcov:
507505
# Verify the tools are present

0 commit comments

Comments
 (0)