summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine du Hamel <duhamelantoine1995@gmail.com>2024-05-23 17:22:40 +0200
committerAntoine du Hamel <duhamelantoine1995@gmail.com>2024-07-08 15:50:50 +0200
commitd0efd899cbdecf7d767ff822bf3f4f2810afd57e (patch)
treed225e5b1bf99387c74f9d992e091149b12c5fbd0
parentMerge staging-next-24.05 into staging-24.05 (diff)
downloadnixpkgs-d0efd899cbdecf7d767ff822bf3f4f2810afd57e.tar.gz
nodejs: run JS test suite as part of the checks
(cherry picked from commit b26563aae2a1fce011ac52e28ff23a460866e82f)
-rw-r--r--pkgs/development/web/nodejs/nodejs.nix10
-rw-r--r--pkgs/development/web/nodejs/use-correct-env-in-tests.patch24
-rw-r--r--pkgs/development/web/nodejs/v18.nix7
-rw-r--r--pkgs/development/web/nodejs/v20.nix7
-rw-r--r--pkgs/development/web/nodejs/v22.nix7
5 files changed, 50 insertions, 5 deletions
diff --git a/pkgs/development/web/nodejs/nodejs.nix b/pkgs/development/web/nodejs/nodejs.nix
index 91038467914d..6f6fb4718c81 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 000000000000..d2fda8d2cead
--- /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 317c6e124a8a..429e50a02bbf 100644
--- a/pkgs/development/web/nodejs/v18.nix
+++ b/pkgs/development/web/nodejs/v18.nix
@@ -1,4 +1,4 @@
-{ callPackage, lib, overrideCC, pkgs, buildPackages, fetchpatch, 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 b716f9bdd1ed..b72018290a07 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 676ef1c7e545..5a2dc68ad16e 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=";
+ })
];
}