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
670473f2
Commit
670473f2
authored
Jul 09, 2018
by
Michael Droettboom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix webserver
parent
4a9b26b1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
11 deletions
+34
-11
Makefile
Makefile
+5
-1
test/conftest.py
test/conftest.py
+28
-9
test/test_python.py
test/test_python.py
+1
-1
No files found.
Makefile
View file @
670473f2
...
@@ -96,10 +96,14 @@ build/renderedhtml.css: src/renderedhtml.less
...
@@ -96,10 +96,14 @@ build/renderedhtml.css: src/renderedhtml.less
lessc
$<
$@
lessc
$<
$@
test
:
all build/test.html
test
:
all build/test.html
build/test_data.txt
py.test
test
-v
py.test
test
-v
build/test_data.txt
:
test/data.txt
cp test
/data.txt build/test_data.txt
lint
:
lint
:
flake8 src
flake8 src
flake8
test
flake8
test
...
...
test/conftest.py
View file @
670473f2
...
@@ -6,7 +6,8 @@ import atexit
...
@@ -6,7 +6,8 @@ import atexit
import
multiprocessing
import
multiprocessing
import
os
import
os
import
pathlib
import
pathlib
import
time
import
queue
import
sys
try
:
try
:
import
pytest
import
pytest
...
@@ -38,7 +39,7 @@ class SeleniumWrapper:
...
@@ -38,7 +39,7 @@ class SeleniumWrapper:
driver
=
self
.
get_driver
()
driver
=
self
.
get_driver
()
wait
=
WebDriverWait
(
driver
,
timeout
=
20
)
wait
=
WebDriverWait
(
driver
,
timeout
=
20
)
driver
.
get
(
'http://127.0.0.1:8000
/test.html'
)
driver
.
get
(
f'http://127.0.0.1:
{
PORT
}
/test.html'
)
wait
.
until
(
PyodideInited
())
wait
.
until
(
PyodideInited
())
self
.
wait
=
wait
self
.
wait
=
wait
self
.
driver
=
driver
self
.
driver
=
driver
...
@@ -104,27 +105,33 @@ if pytest is not None:
...
@@ -104,27 +105,33 @@ if pytest is not None:
selenium
.
driver
.
quit
()
selenium
.
driver
.
quit
()
PORT
=
0
def
spawn_web_server
():
def
spawn_web_server
():
global
PORT
print
(
"Spawning webserver..."
)
print
(
"Spawning webserver..."
)
p
=
multiprocessing
.
Process
(
target
=
run_web_server
)
q
=
multiprocessing
.
Queue
()
p
=
multiprocessing
.
Process
(
target
=
run_web_server
,
args
=
(
q
,))
def
shutdown_webserver
():
def
shutdown_webserver
():
p
.
terminate
()
q
.
put
(
"TERMINATE"
)
p
.
join
()
atexit
.
register
(
shutdown_webserver
)
atexit
.
register
(
shutdown_webserver
)
p
.
start
()
p
.
start
()
time
.
sleep
(
2
)
PORT
=
q
.
get
(
)
def
run_web_server
():
def
run_web_server
(
q
):
import
http.server
import
http.server
import
socketserver
import
socketserver
print
(
"Running webserver..."
)
print
(
"Running webserver..."
)
os
.
chdir
(
BUILD_PATH
)
os
.
chdir
(
BUILD_PATH
)
PORT
=
8000
Handler
=
http
.
server
.
SimpleHTTPRequestHandler
Handler
=
http
.
server
.
SimpleHTTPRequestHandler
Handler
.
extensions_map
[
'.wasm'
]
=
'application/wasm'
Handler
.
extensions_map
[
'.wasm'
]
=
'application/wasm'
...
@@ -132,8 +139,20 @@ def run_web_server():
...
@@ -132,8 +139,20 @@ def run_web_server():
pass
pass
Handler
.
log_message
=
dummy_log
Handler
.
log_message
=
dummy_log
with
socketserver
.
TCPServer
((
""
,
PORT
),
Handler
)
as
httpd
:
with
socketserver
.
TCPServer
((
""
,
0
),
Handler
)
as
httpd
:
print
(
"serving at port"
,
PORT
)
host
,
port
=
httpd
.
server_address
print
(
"serving at port"
,
port
)
q
.
put
(
port
)
def
service_actions
():
try
:
if
q
.
get
(
False
)
==
"TERMINATE"
:
sys
.
exit
(
0
)
httpd
.
shutdown
()
except
queue
.
Empty
:
pass
httpd
.
service_actions
=
service_actions
httpd
.
serve_forever
()
httpd
.
serve_forever
()
...
...
test/test_python.py
View file @
670473f2
...
@@ -177,7 +177,7 @@ def test_jsproxy(selenium):
...
@@ -177,7 +177,7 @@ def test_jsproxy(selenium):
def
test_open_url
(
selenium
):
def
test_open_url
(
selenium
):
assert
selenium
.
run
(
assert
selenium
.
run
(
"import pyodide
\
n
"
"import pyodide
\
n
"
"pyodide.open_url('
../test/
data.txt').read()
\
n
"
)
==
'HELLO
\
n
'
"pyodide.open_url('
test_
data.txt').read()
\
n
"
)
==
'HELLO
\
n
'
def
test_run_core_python_test
(
python_test
,
selenium
):
def
test_run_core_python_test
(
python_test
,
selenium
):
...
...
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