Commit 07f6b70c authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

TEST: make sure entry points exist and are on $PATH

parent a2611afc
...@@ -57,18 +57,16 @@ def test_demo(): ...@@ -57,18 +57,16 @@ def test_demo():
assert not nbproc.is_alive() assert not nbproc.is_alive()
def test_demo_commands(): def create_funpack_entrypoint(path):
with open(path, 'wt') as f:
f.write('#!/usr/bin/env bash\n')
f.write('{} -m funpack "$@"\n'.format(sys.executable))
os.chmod(path, 0o755)
# Issues with pytest-cov 3.0.0 / coveragepy 6.2
# cause coverage to spit out error information
# in subprocess-called invocations. Disabling for
# the time being.
env = os.environ.copy()
for k in list(env.keys()):
if 'COVERAGE' in k or k.startswith('COV_'):
env.pop(k)
def eval_cmd(cmd, out): def test_demo_commands():
def eval_cmd(cmd, out, env):
# TODO extract all funpack calls, and turn # TODO extract all funpack calls, and turn
# them into funpack.main function calls. # them into funpack.main function calls.
...@@ -79,9 +77,23 @@ def test_demo_commands(): ...@@ -79,9 +77,23 @@ def test_demo_commands():
assert result.returncode == 0 assert result.returncode == 0
assert result.stdout.decode().strip() == out.strip() assert result.stdout.decode().strip() == out.strip()
# Issues with pytest-cov 3.0.0 / coveragepy 6.2
# cause coverage to spit out error information
# in subprocess-called invocations. Disabling for
# the time being.
env = os.environ.copy()
for k in list(env.keys()):
if 'COVERAGE' in k or k.startswith('COV_'):
env.pop(k)
with tempdir() as td: with tempdir() as td:
td = op.realpath(td) td = op.realpath(td)
gen_demo_tests(rundir=td) gen_demo_tests(rundir=td)
create_funpack_entrypoint(op.join(td, 'funpack'))
create_funpack_entrypoint(op.join(td, 'fmrib_unpack'))
env['PATH'] = op.pathsep.join((td, env['PATH']))
demodir = op.join(op.dirname(__file__), '..', 'scripts', 'demo') demodir = op.join(op.dirname(__file__), '..', 'scripts', 'demo')
for fname in glob.glob(op.join(demodir, '*.*')): for fname in glob.glob(op.join(demodir, '*.*')):
...@@ -96,7 +108,7 @@ def test_demo_commands(): ...@@ -96,7 +108,7 @@ def test_demo_commands():
print(open(cmd).read()) print(open(cmd).read())
print() print()
eval_cmd(cmd, out) eval_cmd(cmd, out, env)
def gen_demo_tests(outdir=None, rundir=None): def gen_demo_tests(outdir=None, rundir=None):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment