From b26563aae2a1fce011ac52e28ff23a460866e82f Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 23 May 2024 17:22:40 +0200 Subject: [PATCH] nodejs: run JS test suite as part of the checks --- pkgs/development/web/nodejs/nodejs.nix | 10 ++++++-- .../web/nodejs/use-correct-env-in-tests.patch | 24 +++++++++++++++++++ pkgs/development/web/nodejs/v18.nix | 7 +++++- pkgs/development/web/nodejs/v20.nix | 7 +++++- pkgs/development/web/nodejs/v22.nix | 7 +++++- 5 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 pkgs/development/web/nodejs/use-correct-env-in-tests.patch diff --git a/pkgs/development/web/nodejs/nodejs.nix b/pkgs/development/web/nodejs/nodejs.nix index 91038467914d9..6f6fb4718c816 100644 --- a/pkgs/development/web/nodejs/nodejs.nix +++ b/pkgs/development/web/nodejs/nodejs.nix @@ -137,10 +137,16 @@ let "build-node-api-tests" "tooltest" "cctest" + "test-ci-js" ]; - # Do not create __pycache__ when running tests. - checkFlags = [ "PYTHONDONTWRITEBYTECODE=1" ]; + checkFlags = [ + # Do not create __pycache__ when running tests. + "PYTHONDONTWRITEBYTECODE=1" + "FLAKY_TESTS=skip" + # Skip some tests that are not passing in this context + "CI_SKIP_TESTS=test-setproctitle,test-tls-cli-max-version-1.3,test-tls-client-auth,test-child-process-exec-env,test-fs-write-stream-eagain,test-tls-sni-option,test-https-foafssl,test-child-process-uid-gid,test-process-euid-egid,test-process-initgroups,test-process-uid-gid,test-process-setgroups" + ]; postInstall = '' HOST_PATH=$out/bin patchShebangs --host $out diff --git a/pkgs/development/web/nodejs/use-correct-env-in-tests.patch b/pkgs/development/web/nodejs/use-correct-env-in-tests.patch new file mode 100644 index 0000000000000..d2fda8d2ceadf --- /dev/null +++ b/pkgs/development/web/nodejs/use-correct-env-in-tests.patch @@ -0,0 +1,24 @@ +`/usr/bin/env` is not available. + +--- old/test/common/assertSnapshot.js ++++ new/test/common/assertSnapshot.js +@@ -81,2 +81,2 @@ async function spawnAndAssert(filename, transform = (x) => x, { tty = false, ... +- const executable = tty ? 'tools/pseudo-tty.py' : process.execPath; +- const args = tty ? [process.execPath, ...flags, filename] : [...flags, filename]; ++ const executable = tty ? 'python3' : process.execPath; ++ const args = tty ? ['tools/pseudo-tty.py', process.execPath, ...flags, filename] : [...flags, filename]; +--- old/test/parallel/test-child-process-default-options.js ++++ new/test/parallel/test-child-process-default-options.js +@@ -35 +35 @@ if (isWindows) { +- child = spawn('/usr/bin/env', [], {}); ++ child = spawn('env', [], {}); +--- old/test/parallel/test-child-process-env.js ++++ new/test/parallel/test-child-process-env.js +@@ -51 +51 @@ if (isWindows) { +- child = spawn('/usr/bin/env', [], { env }); ++ child = spawn('env', [], { env }); +--- old/test/parallel/test-child-process-exec-env.js ++++ new/test/parallel/test-child-process-exec-env.js +@@ -47 +47 @@ if (!isWindows) { +- child = exec('/usr/bin/env', { env: { 'HELLO': 'WORLD' } }, after); ++ child = exec('env', { env: { 'HELLO': 'WORLD' } }, after); diff --git a/pkgs/development/web/nodejs/v18.nix b/pkgs/development/web/nodejs/v18.nix index 6b3ca7635e436..7f80e2070f383 100644 --- a/pkgs/development/web/nodejs/v18.nix +++ b/pkgs/development/web/nodejs/v18.nix @@ -1,4 +1,4 @@ -{ callPackage, lib, overrideCC, pkgs, buildPackages, openssl, python3, enableNpm ? true }: +{ callPackage, lib, overrideCC, pkgs, buildPackages, openssl, python3, fetchpatch2, enableNpm ? true }: let # Clang 16+ cannot build Node v18 due to -Wenum-constexpr-conversion errors. @@ -27,5 +27,10 @@ buildNodejs { ./revert-arm64-pointer-auth.patch ./node-npm-build-npm-package-logic.patch ./trap-handler-backport.patch + ./use-correct-env-in-tests.patch + (fetchpatch2 { + url = "https://github.com/nodejs/node/commit/534c122de166cb6464b489f3e6a9a544ceb1c913.patch"; + hash = "sha256-4q4LFsq4yU1xRwNsM1sJoNVphJCnxaVe2IyL6AeHJ/I="; + }) ]; } diff --git a/pkgs/development/web/nodejs/v20.nix b/pkgs/development/web/nodejs/v20.nix index b716f9bdd1ed5..b72018290a077 100644 --- a/pkgs/development/web/nodejs/v20.nix +++ b/pkgs/development/web/nodejs/v20.nix @@ -1,4 +1,4 @@ -{ callPackage, openssl, python3, enableNpm ? true }: +{ callPackage, fetchpatch2, openssl, python3, enableNpm ? true }: let buildNodejs = callPackage ./nodejs.nix { @@ -15,5 +15,10 @@ buildNodejs { ./disable-darwin-v8-system-instrumentation-node19.patch ./bypass-darwin-xcrun-node16.patch ./node-npm-build-npm-package-logic.patch + ./use-correct-env-in-tests.patch + (fetchpatch2 { + url = "https://github.com/nodejs/node/commit/534c122de166cb6464b489f3e6a9a544ceb1c913.patch"; + hash = "sha256-4q4LFsq4yU1xRwNsM1sJoNVphJCnxaVe2IyL6AeHJ/I="; + }) ]; } diff --git a/pkgs/development/web/nodejs/v22.nix b/pkgs/development/web/nodejs/v22.nix index 676ef1c7e5452..5a2dc68ad16e1 100644 --- a/pkgs/development/web/nodejs/v22.nix +++ b/pkgs/development/web/nodejs/v22.nix @@ -1,4 +1,4 @@ -{ callPackage, openssl, python3, enableNpm ? true }: +{ callPackage, fetchpatch2, openssl, python3, enableNpm ? true }: let buildNodejs = callPackage ./nodejs.nix { @@ -14,5 +14,10 @@ buildNodejs { ./disable-darwin-v8-system-instrumentation-node19.patch ./bypass-darwin-xcrun-node16.patch ./node-npm-build-npm-package-logic.patch + ./use-correct-env-in-tests.patch + (fetchpatch2 { + url = "https://github.com/nodejs/node/commit/534c122de166cb6464b489f3e6a9a544ceb1c913.patch"; + hash = "sha256-4q4LFsq4yU1xRwNsM1sJoNVphJCnxaVe2IyL6AeHJ/I="; + }) ]; }