Skip to content

Commit

Permalink
More work trying to get linting working again
Browse files Browse the repository at this point in the history
  • Loading branch information
mdboom committed Jun 15, 2018
1 parent af3a0a1 commit b8b9519
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ jobs:
- run:
name: dependencies
command: |
sudo apt-get install node-less cmake build-essential clang-format flake8
# We need at least g++-8, but stretch comes with g++-6
# Set up the Debian testing repo, and then install g++ from there...
sudo bash -c "echo \"deb http://ftp.us.debian.org/debian testing main contrib non-free\" >> /etc/apt/sources.list"
sudo apt-get update
sudo apt-get install node-less cmake build-essential clang-format-6.0 flake8
sudo apt-get install -t testing g++-8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80 --slave /usr/bin/g++ g++ /usr/bin/g++-8
Expand Down
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ charset = utf-8
indent_size = 2
indent_style = space

[*.py]
indent_size = 4

[Makefile]
indent_style = tab
indent_style = tab
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ test: all build/test.html

lint:
flake8 src

flake8 test
clang-format -output-replacements-xml src/*.c src/*.h src/*.js | (! grep '<replacement ')

benchmark: all build/test.html
python benchmark/benchmark.py $(HOSTPYTHON) build/benchmarks.json
Expand Down
4 changes: 2 additions & 2 deletions src/pyodide.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ var languagePluginLoader = new Promise((resolve, reject) => {
// Package loading
const packages = {
'dateutil' : [],
'kiwisolver': [],
'kiwisolver' : [],
'matplotlib' : [ 'numpy', 'dateutil', 'pytz', 'kiwisolver' ],
'numpy' : [],
'pandas' : [ 'numpy', 'dateutil', 'pytz' ],
'pytz' : [],
'test': []
'test' : []
};
let loadedPackages = new Set();
let loadPackage = (names) => {
Expand Down
6 changes: 3 additions & 3 deletions src/pyproxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ _pyproxy_apply(int ptrobj, int idargs)
}

EM_JS(int, pyproxy_new, (int ptrobj), {
var target = function() {};
target['$$'] = { ptr: ptrobj, type: 'PyProxy' };
var target = function(){};
target['$$'] = { ptr : ptrobj, type : 'PyProxy' };
return Module.hiwire_new_value(new Proxy(target, Module.PyProxy));
});

Expand Down Expand Up @@ -208,5 +208,5 @@ EM_JS(int, pyproxy_init, (), {
};

return 0;
// clang-format on
// clang-format on
});
6 changes: 4 additions & 2 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def __init__(self):

options = Options()
options.add_argument('-headless')
driver = Firefox(executable_path='geckodriver', firefox_options=options)
driver = Firefox(
executable_path='geckodriver', firefox_options=options)
wait = WebDriverWait(driver, timeout=20)
driver.get((BUILD_PATH / "test.html").as_uri())
wait.until(PyodideInited())
Expand All @@ -58,7 +59,8 @@ def run_js(self, code):
def load_package(self, packages):
self.run_js(
'window.done = false\n'
'pyodide.loadPackage({!r}).then(window.done = true)'.format(packages))
'pyodide.loadPackage({!r}).then(window.done = true)'.format(
packages))
time.sleep(2)
self.wait.until(PackageLoaded())

Expand Down
3 changes: 2 additions & 1 deletion test/make_test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
tests = []

TEST_DIR = "../cpython/build/3.6.4/host/lib/python3.6/test"
for root, dirs, files in os.walk("../cpython/build/3.6.4/host/lib/python3.6/test"):
for root, dirs, files in os.walk(
"../cpython/build/3.6.4/host/lib/python3.6/test"):
root = os.path.relpath(root, TEST_DIR)
if root == '.':
root = ''
Expand Down
16 changes: 9 additions & 7 deletions test/test_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def test_pyproxy(selenium):
)
assert selenium.run_js("return pyodide.pyimport('f').get_value(2)") == 128
assert selenium.run_js("return pyodide.pyimport('f').bar") == 42
assert selenium.run_js("return ('bar' in pyodide.pyimport('f'))") == True
assert selenium.run_js("return ('bar' in pyodide.pyimport('f'))")
selenium.run_js("f = pyodide.pyimport('f'); f.baz = 32")
assert selenium.run("f.baz") == 32
assert set(selenium.run_js(
Expand All @@ -124,10 +124,11 @@ def test_pyproxy(selenium):
'__reduce_ex__', '__repr__', '__setattr__', '__sizeof__',
'__str__', '__subclasshook__', '__weakref__', 'bar', 'baz',
'get_value', 'toString', 'prototype'])
assert selenium.run("hasattr(f, 'baz')") == True
assert selenium.run("hasattr(f, 'baz')")
selenium.run_js("delete pyodide.pyimport('f').baz")
assert selenium.run("hasattr(f, 'baz')") == False
assert selenium.run_js("return pyodide.pyimport('f').toString()").startswith('<Foo')
assert not selenium.run("hasattr(f, 'baz')")
assert selenium.run_js(
"return pyodide.pyimport('f').toString()").startswith('<Foo')


def test_jsproxy(selenium):
Expand Down Expand Up @@ -171,16 +172,17 @@ def pytest_generate_tests(metafunc):
if 'python_test' in metafunc.fixturenames:
test_modules = []
with open(
str(pathlib.Path(__file__).parents[0] / "python_tests.txt")) as fp:
str(pathlib.Path(__file__).parents[0] /
"python_tests.txt")) as fp:
for line in fp:
line = line.strip()
if line.startswith('#'):
continue
parts = line.split()
if len(parts) == 1:
test_modules.append(parts[0])
# XXX: The tests take too long to run, so we're just doing a
# sanity check on the first 25
# XXX: The tests take too long to run, so we're just doing
# a sanity check on the first 25
if 'TRAVIS' in os.environ and len(test_modules) > 25:
break
metafunc.parametrize("python_test", test_modules)

0 comments on commit b8b9519

Please sign in to comment.