Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyodide
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
pyodide
Commits
db4e1d02
Commit
db4e1d02
authored
Oct 26, 2018
by
Michael Droettboom
Committed by
GitHub
Oct 26, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #224 from rth/pywasmcross-tests
Add python tests for handle_command in pywasmcross.py
parents
75fe1339
bb53e36a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
82 additions
and
8 deletions
+82
-8
.circleci/config.yml
.circleci/config.yml
+7
-3
pyodide_build/pywasmcross.py
pyodide_build/pywasmcross.py
+30
-5
setup.cfg
setup.cfg
+1
-0
test/pyodide_build/test_pywasmcross.py
test/pyodide_build/test_pywasmcross.py
+44
-0
No files found.
.circleci/config.yml
View file @
db4e1d02
...
@@ -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,16 +67,20 @@ jobs:
...
@@ -67,16 +67,20 @@ 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
steps
:
steps
:
-
checkout
-
checkout
-
run
:
name
:
deps
command
:
|
sudo pip install pytest-cov
-
run
:
-
run
:
name
:
test
name
:
test
command
:
|
command
:
|
pytest test
-v -k 'not (chrome or firefox)'
pytest test
pyodide_build -v -k 'not (chrome or firefox)' --cov=pyodide_build --cov=pyodide
benchmark
:
benchmark
:
<<
:
*defaults
<<
:
*defaults
...
...
pyodide_build/pywasmcross.py
View file @
db4e1d02
...
@@ -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
):
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,9 +178,10 @@ def handle_command(line, args):
...
@@ -156,9 +178,10 @@ def handle_command(line, args):
print
(
' '
.
join
(
new_args
))
print
(
' '
.
join
(
new_args
))
result
=
subprocess
.
run
(
new_args
)
if
not
dryrun
:
if
result
.
returncode
!=
0
:
result
=
subprocess
.
run
(
new_args
)
sys
.
exit
(
result
.
returncode
)
if
result
.
returncode
!=
0
:
sys
.
exit
(
result
.
returncode
)
# Emscripten .so files shouldn't have the native platform slug
# Emscripten .so files shouldn't have the native platform slug
if
shared
:
if
shared
:
...
@@ -169,7 +192,9 @@ def handle_command(line, args):
...
@@ -169,7 +192,9 @@ def handle_command(line, args):
if
renamed
.
endswith
(
ext
):
if
renamed
.
endswith
(
ext
):
renamed
=
renamed
[:
-
len
(
ext
)]
+
'.so'
renamed
=
renamed
[:
-
len
(
ext
)]
+
'.so'
break
break
os
.
rename
(
output
,
renamed
)
if
not
dryrun
:
os
.
rename
(
output
,
renamed
)
return
new_args
def
replay_compile
(
args
):
def
replay_compile
(
args
):
...
...
setup.cfg
View file @
db4e1d02
...
@@ -2,3 +2,4 @@
...
@@ -2,3 +2,4 @@
addopts =
addopts =
-r sxX
-r sxX
--instafail
--instafail
--doctest-modules
test/pyodide_build/test_pywasmcross.py
0 → 100644
View file @
db4e1d02
from
collections
import
namedtuple
from
pathlib
import
Path
import
sys
sys
.
path
.
append
(
str
(
Path
(
__file__
).
parents
[
2
]))
from
pyodide_build.pywasmcross
import
handle_command
# noqa: E402
def
_args_wrapper
(
func
):
"""Convert function to take as input / return a string instead of a
list of arguments
Also sets dryrun=True
"""
def
_inner
(
line
,
*
pargs
):
args
=
line
.
split
()
res
=
func
(
args
,
*
pargs
,
dryrun
=
True
)
if
hasattr
(
res
,
'__len__'
):
return
' '
.
join
(
res
)
else
:
return
res
return
_inner
handle_command_wrap
=
_args_wrapper
(
handle_command
)
# TODO: add f2c here
def
test_handle_command
():
Args
=
namedtuple
(
'args'
,
[
'cflags'
,
'ldflags'
])
args
=
Args
(
cflags
=
''
,
ldflags
=
''
)
assert
handle_command_wrap
(
'gcc -print-multiarch'
,
args
)
is
None
assert
handle_command_wrap
(
'gcc test.c'
,
args
)
==
'emcc test.c'
assert
handle_command_wrap
(
'gcc -shared -c test.o -o test.so'
,
args
)
==
\
'emcc -shared -c test.bc -o test.wasm'
# check ldflags injection
args
=
Args
(
cflags
=
''
,
ldflags
=
'-lm'
)
assert
handle_command_wrap
(
'gcc -shared -c test.o -o test.so'
,
args
)
==
\
'emcc -lm -shared -c test.bc -o test.wasm'
# compilation checks in numpy
assert
handle_command_wrap
(
'gcc /usr/file.c'
,
args
)
is
None
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment