Commit bb53e36a authored by Roman Yurchak's avatar Roman Yurchak

Rename to dryrun, add docstring and doctest

parent 4abdff51
...@@ -56,7 +56,7 @@ jobs: ...@@ -56,7 +56,7 @@ jobs:
- run: - run:
name: test name: test
command: | command: |
pytest test -v -k firefox pytest test pyodide_build -v -k firefox
test-chrome: test-chrome:
<<: *defaults <<: *defaults
...@@ -67,7 +67,7 @@ jobs: ...@@ -67,7 +67,7 @@ jobs:
- run: - run:
name: test name: test
command: | command: |
pytest test -v -k chrome pytest test pyodide_build -v -k chrome
test-python: test-python:
<<: *defaults <<: *defaults
...@@ -80,7 +80,7 @@ jobs: ...@@ -80,7 +80,7 @@ jobs:
- run: - run:
name: test name: test
command: | command: |
pytest test -v -k 'not (chrome or firefox)' --cov=pyodide_build --cov=pyodide pytest test pyodide_build -v -k 'not (chrome or firefox)' --cov=pyodide_build --cov=pyodide
benchmark: benchmark:
<<: *defaults <<: *defaults
......
...@@ -105,7 +105,29 @@ def capture_compile(args): ...@@ -105,7 +105,29 @@ def capture_compile(args):
sys.exit(result.returncode) sys.exit(result.returncode)
def handle_command(line, args, pretend=False): def handle_command(line, args, dryrun=False):
"""Handle a compilation command
Parameters
----------
line : iterable
an iterable with the compilation arguments
args : {object, namedtuple}
an container with additional compilation options,
in particular containing ``args.cflags`` and ``args.ldflags``
dryrun : bool, default=False
if True do not run the resulting command, only return it
Examples
--------
>>> from collections import namedtuple
>>> Args = namedtuple('args', ['cflags', 'ldflags'])
>>> args = Args(cflags='', ldflags='')
>>> handle_command(['gcc', 'test.c'], args, dryrun=True)
emcc test.c
['emcc', 'test.c']
"""
# This is a special case to skip the compilation tests in numpy that aren't # This is a special case to skip the compilation tests in numpy that aren't
# actually part of the build # actually part of the build
for arg in line: for arg in line:
...@@ -156,7 +178,7 @@ def handle_command(line, args, pretend=False): ...@@ -156,7 +178,7 @@ def handle_command(line, args, pretend=False):
print(' '.join(new_args)) print(' '.join(new_args))
if not pretend: if not dryrun:
result = subprocess.run(new_args) result = subprocess.run(new_args)
if result.returncode != 0: if result.returncode != 0:
sys.exit(result.returncode) sys.exit(result.returncode)
...@@ -170,7 +192,7 @@ def handle_command(line, args, pretend=False): ...@@ -170,7 +192,7 @@ def handle_command(line, args, pretend=False):
if renamed.endswith(ext): if renamed.endswith(ext):
renamed = renamed[:-len(ext)] + '.so' renamed = renamed[:-len(ext)] + '.so'
break break
if not pretend: if not dryrun:
os.rename(output, renamed) os.rename(output, renamed)
return new_args return new_args
......
...@@ -2,3 +2,4 @@ ...@@ -2,3 +2,4 @@
addopts = addopts =
-r sxX -r sxX
--instafail --instafail
--doctest-modules
...@@ -11,11 +11,11 @@ def _args_wrapper(func): ...@@ -11,11 +11,11 @@ def _args_wrapper(func):
"""Convert function to take as input / return a string instead of a """Convert function to take as input / return a string instead of a
list of arguments list of arguments
Also sets pretend=True Also sets dryrun=True
""" """
def _inner(line, *pargs): def _inner(line, *pargs):
args = line.split() args = line.split()
res = func(args, *pargs, pretend=True) res = func(args, *pargs, dryrun=True)
if hasattr(res, '__len__'): if hasattr(res, '__len__'):
return ' '.join(res) return ' '.join(res)
else: else:
......
Markdown is supported
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