From d58e5041de83a3af4ae733837445fb0bc331c60a Mon Sep 17 00:00:00 2001 From: Alex James Date: Sun, 18 May 2025 20:48:10 -0500 Subject: [PATCH] luaPackages.luv: fix `installCheckPhase` on Darwin --- pkgs/development/lua-modules/luv/default.nix | 18 ++++++++++- .../luv/disable-failing-darwin-tests.patch | 19 ++++++++++++ .../luv/disable-failing-tests.patch | 30 +++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/lua-modules/luv/disable-failing-darwin-tests.patch create mode 100644 pkgs/development/lua-modules/luv/disable-failing-tests.patch diff --git a/pkgs/development/lua-modules/luv/default.nix b/pkgs/development/lua-modules/luv/default.nix index 61de3da4c359..e0390b47a788 100644 --- a/pkgs/development/lua-modules/luv/default.nix +++ b/pkgs/development/lua-modules/luv/default.nix @@ -1,4 +1,5 @@ { + stdenv, lib, buildLuarocksPackage, cmake, @@ -28,6 +29,18 @@ buildLuarocksPackage rec { rm -rf deps/lua deps/luajit deps/libuv ''; + patches = + [ + # Fails with "Uncaught Error: ./tests/test-dns.lua:164: assertion failed!" + # and "./tests/test-tty.lua:19: bad argument #1 to 'is_readable' (Expected + # uv_stream userdata)" + ./disable-failing-tests.patch + ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ + # Fails with "Uncaught Error: ./tests/test-udp.lua:261: EHOSTUNREACH" + ./disable-failing-darwin-tests.patch + ]; + buildInputs = [ libuv ]; nativeBuildInputs = [ cmake ]; @@ -56,10 +69,13 @@ buildLuarocksPackage rec { EOF ''; + __darwinAllowLocalNetworking = true; + doInstallCheck = true; installCheckPhase = '' - rm tests/test-{dns,thread,tty}.lua + runHook preInstallCheck luarocks test + runHook postInstallCheck ''; disabled = luaOlder "5.1"; diff --git a/pkgs/development/lua-modules/luv/disable-failing-darwin-tests.patch b/pkgs/development/lua-modules/luv/disable-failing-darwin-tests.patch new file mode 100644 index 000000000000..d87902458b41 --- /dev/null +++ b/pkgs/development/lua-modules/luv/disable-failing-darwin-tests.patch @@ -0,0 +1,19 @@ +diff --git a/tests/test-udp.lua b/tests/test-udp.lua +index bd0f46d..e4542b4 100644 +--- a/tests/test-udp.lua ++++ b/tests/test-udp.lua +@@ -280,14 +280,6 @@ return require('lib/tap')(function (test) + -- same check for skipping the ipv6 test; we just expanded it to + -- the ipv4 test as well. + local function has_external_interface(uv, family) +- local addresses = assert(uv.interface_addresses()) +- for _, vals in pairs(addresses) do +- for _, info in ipairs(vals) do +- if (not family or info.family == family) and not info.internal then +- return true +- end +- end +- end + return false + end + diff --git a/pkgs/development/lua-modules/luv/disable-failing-tests.patch b/pkgs/development/lua-modules/luv/disable-failing-tests.patch new file mode 100644 index 000000000000..14ae9fd94412 --- /dev/null +++ b/pkgs/development/lua-modules/luv/disable-failing-tests.patch @@ -0,0 +1,30 @@ +diff --git a/tests/test-dns.lua b/tests/test-dns.lua +index 894220b..0763b36 100644 +--- a/tests/test-dns.lua ++++ b/tests/test-dns.lua +@@ -161,7 +161,6 @@ return require('lib/tap')(function (test) + p{err=err,hostname=hostname,service=service} + assert(not err, err) + assert(hostname) +- assert(service == "http") + end))) + end) + +diff --git a/tests/test-tty.lua b/tests/test-tty.lua +index 165e58d..11368df 100644 +--- a/tests/test-tty.lua ++++ b/tests/test-tty.lua +@@ -13,13 +13,10 @@ end + return require('lib/tap')(function (test) + + test("tty normal", function (print, p, expect, uv) +- local stdin = uv.new_tty(0, true) + local stdout = uv.new_tty(1, false) + +- assert(uv.is_readable(stdin)) + assert(uv.is_writable(stdout)) + +- uv.close(stdin) + uv.close(stdout) + end) +