From 90b603037355df21a465fce9338b650cd61df52e Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 4 Jan 2023 10:23:04 -0800 Subject: [PATCH] Update MINIMUM_NODE_VERSION to 10.19.0 and add testing (#18465) --- .circleci/config.yml | 43 ++++++++++++++++++++++++++++++------------- src/parseTools.js | 2 +- test/common.py | 25 ++++++++++++++++--------- test/test_sanity.py | 5 +++-- tools/shared.py | 6 +++++- 5 files changed, 55 insertions(+), 26 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index daa313b931829..2344851271038 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -69,20 +69,30 @@ commands: - run: name: pip install command: << parameters.python >> -m pip install -r requirements-dev.txt - setup-latest-node: - description: "setup latest node" + install-node-version: + description: "install a specific version of node" + parameters: + node_version: + description: "version of node to install" + type: string steps: - run: - name: setup latest node + name: setup node v<< parameters.node_version >> command: | cd $HOME - wget https://nodejs.org/dist/v19.0.0/node-v19.0.0-linux-x64.tar.xz - tar xf node-v19.0.0-linux-x64.tar.xz - echo "NODE_JS = [os.path.expanduser('~/node-v19.0.0-linux-x64/bin/node')]" >> ~/emsdk/.emscripten + version=<< parameters.node_version >> + wget https://nodejs.org/dist/v${version}/node-v${version}-linux-x64.tar.xz + tar xf node-v${version}-linux-x64.tar.xz + echo "NODE_JS = [os.path.expanduser('~/node-v${version}-linux-x64/bin/node')]" >> ~/emsdk/.emscripten echo "JS_ENGINES = [NODE_JS]" >> ~/emsdk/.emscripten echo "if os.path.exists(V8_ENGINE[0]): JS_ENGINES.append(V8_ENGINE)" >> ~/emsdk/.emscripten cat ~/emsdk/.emscripten - echo "export PATH=\"$HOME/node-v19.0.0-linux-x64/bin:\$PATH\"" >> $BASH_ENV + echo "export PATH=\"$HOME/node-v${version}-linux-x64/bin:\$PATH\"" >> $BASH_ENV + install-latest-node: + description: "install latest version of node" + steps: + - install-node-version: + node_version: "19.0.0" install-v8: description: "install v8 using jsvu" steps: @@ -508,11 +518,11 @@ jobs: test_targets: "wasm64_v8" - run-tests: test_targets: "wasm64l" - - setup-latest-node + - install-latest-node - run-tests: test_targets: "wasm64" - upload-test-results - test-latest-node: + test-node-compat: # We don't use `bionic` here since its tool old to run recent node versions: # `/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found` executor: linux-python @@ -523,10 +533,17 @@ jobs: command: git submodule update --init - pip-install - build - - setup-latest-node + # Run some basic tests with the minimum version of node that we currently + # support. + - install-node-version: + node_version: "10.19.0" + - run-tests: + test_targets: "core2.test_hello_world" + # Run a few test with the most recent version of node + # In particular we have some tests that require node flags on older + # versions of node but not with the most recent version. + - install-latest-node - run-tests: - # Run tests that on older versions of node would require flags, but - # those flags should not be injected on newer versions. test_targets: "-v core2.test_pthread_create core2.test_i64_invoke_bigint core2.test_source_map" - upload-test-results test-other: @@ -703,7 +720,7 @@ workflows: - test-sockets-chrome: requires: - build-linux - - test-latest-node + - test-node-compat - test-windows - test-mac: # The mac tester also uses the libraries built on the linux builder to diff --git a/src/parseTools.js b/src/parseTools.js index 94dc5b74adb17..2259a8c3f97f4 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -8,7 +8,7 @@ * Tests live in test/other/test_parseTools.js. */ -globalThis.FOUR_GB = 4 * 1024 * 1024 * 1024; +global.FOUR_GB = 4 * 1024 * 1024 * 1024; const FLOAT_TYPES = new Set(['float', 'double']); let currentlyParsedFilename = ''; diff --git a/test/common.py b/test/common.py index 80ff91677803b..ca3ba1a26349b 100644 --- a/test/common.py +++ b/test/common.py @@ -519,15 +519,22 @@ def setUp(self): self.settings_mods = {} self.emcc_args = ['-Wclosure', '-Werror', '-Wno-limited-postlink-optimizations'] self.ldflags = [] - self.node_args = [ - # Increate stack trace limit to maximise usefulness of test failure reports - '--stack-trace-limit=50', - # Opt in to node v15 default behaviour: - # https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode - '--unhandled-rejections=throw', - # Include backtrace for all uncuaght exceptions (not just Error). - '--trace-uncaught', - ] + # Increate stack trace limit to maximise usefulness of test failure reports + self.node_args = ['--stack-trace-limit=50'] + + node_version = shared.check_node_version() + if node_version: + if node_version < (11, 0, 0): + self.node_args.append('--unhandled-rejections=strict') + self.node_args.append('--experimental-wasm-se') + else: + # Include backtrace for all uncuaght exceptions (not just Error). + self.node_args.append('--trace-uncaught') + if node_version < (15, 0, 0): + # Opt in to node v15 default behaviour: + # https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode + self.node_args.append('--unhandled-rejections=throw') + self.v8_args = ['--wasm-staging'] self.env = {} self.temp_files_before_run = [] diff --git a/test/test_sanity.py b/test/test_sanity.py index 3107a614621e7..bfb9bb723f7ab 100644 --- a/test/test_sanity.py +++ b/test/test_sanity.py @@ -280,8 +280,9 @@ def test_node(self): for version, succeed in [('v0.8.0', False), ('v4.1.0', False), - ('v4.1.1', True), - ('v4.2.3-pre', True), + ('v10.18.0', False), + ('v10.19.0', True), + ('v10.19.1-pre', True), ('cheez', False)]: print(version, succeed) delete_file(SANITY_FILE) diff --git a/tools/shared.py b/tools/shared.py index 3de68585cb6df..0810b8357c7be 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -45,7 +45,11 @@ DEBUG_SAVE = DEBUG or int(os.environ.get('EMCC_DEBUG_SAVE', '0')) -MINIMUM_NODE_VERSION = (4, 1, 1) +# Minimum node version required to run the emscripten compiler. This is distinct +# from the minimum version required to execute the generated code. This is not an +# exact requirement, but is the oldest version of node that we do any testing with. +# This version aligns with the current Ubuuntu TLS 20.04 (Focal). +MINIMUM_NODE_VERSION = (10, 19, 0) EXPECTED_LLVM_VERSION = "16.0" # Used only when EM_PYTHON_MULTIPROCESSING=1 env. var is set.