Skip to content

Commit

Permalink
tests: Add @requires_ninja decorator. NFC (#17110)
Browse files Browse the repository at this point in the history
Also rename the existing `require_node` and `require_v8` decorators.

See #17101
  • Loading branch information
sbc100 authored Jun 1, 2022
1 parent 597502b commit 5312576
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 46 deletions.
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ commands:
- emsdk-env
- npm-install
- pip-install
- run: apt-get install ninja-build
run-tests:
description: "Runs emscripten tests"
parameters:
Expand Down Expand Up @@ -509,6 +510,7 @@ jobs:
HOMEBREW_NO_AUTO_UPDATE: "1"
command: |
brew list cmake || brew install cmake
brew list ninja || brew install ninja
brew list python3 || brew install python3
brew list pkg-config || brew install pkg-config
- checkout
Expand Down
4 changes: 2 additions & 2 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def decorated(self, *args, **kwargs):
return decorated


def require_node(func):
def requires_node(func):
assert callable(func)

def decorated(self, *args, **kwargs):
Expand All @@ -188,7 +188,7 @@ def decorated(self, *args, **kwargs):
return decorated


def require_v8(func):
def requires_v8(func):
assert callable(func)

def decorated(self, *args, **kwargs):
Expand Down
8 changes: 4 additions & 4 deletions tests/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from common import BrowserCore, RunnerCore, path_from_root, has_browser, EMTEST_BROWSER, Reporting
from common import create_file, parameterized, ensure_dir, disabled, test_file, WEBIDL_BINDER
from common import read_file, require_v8, also_with_minimal_runtime
from common import read_file, requires_v8, also_with_minimal_runtime
from tools import shared
from tools import ports
from tools.shared import EMCC, WINDOWS, FILE_PACKAGER, PIPE
Expand Down Expand Up @@ -5262,7 +5262,7 @@ def test_wasm_worker_semaphore_try_acquire(self):
self.btest(test_file('wasm_worker/semaphore_try_acquire.c'), expected='0', args=['-sWASM_WORKERS'])

@no_firefox('no 4GB support yet')
@require_v8
@requires_v8
def test_zzz_zzz_4gb(self):
# TODO Convert to an actual browser test when it reaches stable.
# For now, keep this in browser as this suite runs serially, which
Expand Down Expand Up @@ -5328,7 +5328,7 @@ def test_zzz_zzz_emmalloc_memgrowth(self, *args):
self.btest(test_file('browser/emmalloc_memgrowth.cpp'), expected='0', args=['-sMALLOC=emmalloc', '-sALLOW_MEMORY_GROWTH=1', '-sABORTING_MALLOC=0', '-sASSERTIONS=2', '-sMINIMAL_RUNTIME=1', '-sMAXIMUM_MEMORY=4GB'])

@no_firefox('no 4GB support yet')
@require_v8
@requires_v8
def test_zzz_zzz_2gb_fail(self):
# TODO Convert to an actual browser test when it reaches stable.
# For now, keep this in browser as this suite runs serially, which
Expand All @@ -5342,7 +5342,7 @@ def test_zzz_zzz_2gb_fail(self):
self.do_run_in_out_file_test('browser', 'test_2GB_fail.cpp')

@no_firefox('no 4GB support yet')
@require_v8
@requires_v8
def test_zzz_zzz_4gb_fail(self):
# TODO Convert to an actual browser test when it reaches stable.
# For now, keep this in browser as this suite runs serially, which
Expand Down
30 changes: 15 additions & 15 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from common import RunnerCore, path_from_root, requires_native_clang, test_file, create_file
from common import skip_if, needs_dylink, no_windows, no_mac, is_slow_test, parameterized
from common import env_modify, with_env_modify, disabled, node_pthreads, also_with_wasm_bigint
from common import read_file, read_binary, require_v8, require_node
from common import read_file, read_binary, requires_v8, requires_node
from common import NON_ZERO, WEBIDL_BINDER, EMBUILDER
import clang_native

Expand Down Expand Up @@ -562,7 +562,7 @@ def test_i64_varargs(self):

@no_wasm2js('wasm_bigint')
@no_wasm64('MEMORY64 does not yet support exceptions')
@require_node
@requires_node
def test_i64_invoke_bigint(self):
self.set_setting('WASM_BIGINT')
self.emcc_args += ['-fexceptions']
Expand Down Expand Up @@ -5790,7 +5790,7 @@ def test_fs_base(self):

@also_with_noderawfs
@is_slow_test
@require_node
@requires_node
def test_fs_nodefs_rw(self):
# TODO(sbc): This test exposes in issue in the way we run closure compiler and
# causes it to generate non-ES5 output.
Expand All @@ -5803,31 +5803,31 @@ def test_fs_nodefs_rw(self):
self.do_runf(test_file('fs/test_nodefs_rw.c'), 'success')

@also_with_noderawfs
@require_node
@requires_node
def test_fs_nodefs_cloexec(self):
self.emcc_args += ['-lnodefs.js']
self.do_runf(test_file('fs/test_nodefs_cloexec.c'), 'success')

@require_node
@requires_node
def test_fs_nodefs_home(self):
self.set_setting('FORCE_FILESYSTEM')
self.emcc_args += ['-lnodefs.js']
self.do_runf(test_file('fs/test_nodefs_home.c'), 'success')

@require_node
@requires_node
def test_fs_nodefs_nofollow(self):
self.emcc_args += ['-lnodefs.js']
self.do_runf(test_file('fs/test_nodefs_nofollow.c'), 'success')

@require_node
@requires_node
def test_fs_nodefs_readdir(self):
# externally setup an existing folder structure: existing/a
os.makedirs(os.path.join(self.working_dir, 'existing', 'a'))
self.emcc_args += ['-lnodefs.js']
self.do_runf(test_file('fs/test_nodefs_readdir.c'), 'success')

@no_windows('no symlink support on windows')
@require_node
@requires_node
def test_fs_noderawfs_nofollow(self):
self.set_setting('NODERAWFS')
create_file('filename', 'foo')
Expand Down Expand Up @@ -5929,7 +5929,7 @@ def test_signals(self):
self.do_core_test(test_file('test_signals.c'))

@no_windows('https://github.com/emscripten-core/emscripten/issues/8882')
@require_node
@requires_node
def test_unistd_access(self):
self.uses_es6 = True
orig_compiler_opts = self.emcc_args.copy()
Expand Down Expand Up @@ -5985,7 +5985,7 @@ def test_unistd_truncate(self, fs):

@no_windows("Windows throws EPERM rather than EACCES or EINVAL")
@unittest.skipIf(WINDOWS or os.geteuid() == 0, "Root access invalidates this test by being able to write on readonly files")
@require_node
@requires_node
def test_unistd_truncate_noderawfs(self):
self.uses_es6 = True
self.set_setting('NODERAWFS')
Expand Down Expand Up @@ -6064,7 +6064,7 @@ def test_unistd_links(self, args, nodefs):
self.do_run_in_out_file_test('unistd/links.c')

@no_windows('Skipping NODEFS test, since it would require administrative privileges.')
@require_node
@requires_node
def test_unistd_symlink_on_nodefs(self):
# Also, other detected discrepancies if you do end up running this test on NODEFS:
# test expects /, but Windows gives \ as path slashes.
Expand Down Expand Up @@ -6351,7 +6351,7 @@ def test_whets(self):
self.do_runf(test_file('whets.cpp'), 'Single Precision C Whetstone Benchmark')

# node is slower, and fail on 64-bit
@require_v8
@requires_v8
@no_asan('depends on the specifics of memory size, which for asan we are forced to increase')
@no_lsan('depends on the specifics of memory size, which for lsan we are forced to increase')
def test_dlmalloc_inline(self):
Expand All @@ -6363,7 +6363,7 @@ def test_dlmalloc_inline(self):
self.do_run('src.js', '*400,0*', args=['400', '400'], force_c=True, no_build=True)

# node is slower, and fail on 64-bit
@require_v8
@requires_v8
@no_asan('depends on the specifics of memory size, which for asan we are forced to increase')
@no_lsan('depends on the specifics of memory size, which for lsan we are forced to increase')
@no_wasmfs('wasmfs does some malloc/free during startup, fragmenting the heap, leading to differences later')
Expand Down Expand Up @@ -7984,7 +7984,7 @@ def test_async_hello(self):

self.do_runf('main.c', 'HelloWorld!99')

@require_v8
@requires_v8
@no_memory64('TODO: asyncify for wasm64')
def test_async_hello_v8(self):
self.test_async_hello()
Expand Down Expand Up @@ -9382,7 +9382,7 @@ def test_em_async_js(self):
self.maybe_closure()
self.do_core_test('test_em_async_js.c')

@require_v8
@requires_v8
@no_wasm2js('wasm2js does not support reference types')
def test_externref(self):
self.run_process([EMCC, '-c', test_file('core/test_externref.s'), '-o', 'asm.o'] + self.get_emcc_args(ldflags=False))
Expand Down
Loading

0 comments on commit 5312576

Please sign in to comment.