Skip to content

Commit e7e55b0

Browse files
committed
Add rest of tests
1 parent 86b5db4 commit e7e55b0

2 files changed

Lines changed: 67 additions & 131 deletions

File tree

.github/workflows/test.sh

Lines changed: 0 additions & 122 deletions
This file was deleted.

spin/tests/test_build_cmds.py

Lines changed: 67 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import subprocess
23
import sys
34
import tempfile
@@ -9,17 +10,21 @@
910
from spin.cmds.util import run
1011

1112
skip_on_windows = pytest.mark.skipif(
12-
sys.platform.startswith("win"), reason="Skipped on Windows"
13+
sys.platform.startswith("win"), reason="Skipped; platform is Windows"
1314
)
1415

16+
on_linux = pytest.mark.skipif(
17+
not sys.platform.startswith("linux"), reason="Skipped; platform not Linux"
18+
)
1519

16-
def spin(*args):
17-
return run(
18-
["spin"] + list(args),
19-
stdout=subprocess.PIPE,
20-
stderr=subprocess.PIPE,
21-
sys_exit=False,
22-
)
20+
21+
def spin(*args, **user_kwargs):
22+
default_kwargs = {
23+
"stdout": subprocess.PIPE,
24+
"stderr": subprocess.PIPE,
25+
"sys_exit": True,
26+
}
27+
return run(["spin"] + list(args), **{**default_kwargs, **user_kwargs})
2328

2429

2530
def stdout(p):
@@ -91,7 +96,60 @@ def test_editable_conflict():
9196
def test_recommend_run_python():
9297
"""If `spin run file.py` is called, is `spin run python file.py` recommended?"""
9398
with tempfile.NamedTemporaryFile(suffix=".py") as f:
94-
p = spin("run", f.name)
99+
p = spin("run", f.name, sys_exit=False)
95100
assert "Did you mean to call" in stdout(
96101
p
97102
), "Failed to recommend `python run python file.py`"
103+
104+
105+
def test_test():
106+
"""Does the test command run?"""
107+
spin("test")
108+
109+
110+
def test_test_with_pythonpath():
111+
"""Does `spin test` work when PYTHONPATH is set?"""
112+
spin("test", env={**os.environ, "PYTHONPATH": "/tmp"})
113+
114+
115+
def test_sdist():
116+
spin("sdist")
117+
118+
119+
def test_example():
120+
spin("example")
121+
122+
123+
def test_docs():
124+
run(["pip", "install", "--quiet", "sphinx"])
125+
spin("docs")
126+
127+
128+
def test_spin_install():
129+
cwd = os.getcwd()
130+
spin("install")
131+
try:
132+
with tempfile.TemporaryDirectory() as d:
133+
os.chdir(d)
134+
p = run(
135+
["python", "-c", "import example_pkg; print(example_pkg.__version__)"],
136+
stdout=subprocess.PIPE,
137+
)
138+
assert stdout(p) == "0.0.0dev0"
139+
finally:
140+
os.chdir(cwd)
141+
run(["pip", "uninstall", "-y", "--quiet", "example_pkg"])
142+
143+
144+
@on_linux
145+
def test_gdb():
146+
p = spin(
147+
"gdb",
148+
"-c",
149+
'import example_pkg; example_pkg.echo("hi")',
150+
"--",
151+
"--eval",
152+
"run",
153+
"--batch",
154+
)
155+
assert "hi" in stdout(p)

0 commit comments

Comments
 (0)