This commit is contained in:
2025-05-14 22:14:00 +02:00
parent f5198370d3
commit ba64cccc05

View File

@@ -438,55 +438,49 @@ let
# usage: nativeBuildInputs = [ pytestCheckHookWithGdb ];
overlays.withPytestCheckHooks = final: prev: {
pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [
(pythonFinal: pythonPrev: {
pytestCheckHookWithGdb = pythonFinal.pytestCheckHook.override (old: {
makePythonHook =
args:
old.makePythonHook (
args
// {
substitutions =
let
# TODO: export NIX_DEBUG_INFO_DIRS or "set debug-file-directory ${symlinkJoin ...}"
gdb-args =
lib.pipe
[
"set style enabled on"
# "layout asm"
# export NIX_DEBUG_INFO_DIRS=/nix/store/xd69daaly33m7zid6g31glwmml7lk93f-openssl-1.0.2p-debug/lib/debug
# "set debug-file-directory /nix/store/xd69daaly33m7zid6g31glwmml7lk93f-openssl-1.0.2p-debug/lib/debug"
"run"
# "thread apply all backtrace"
# "backtrace"
"backtrace full"
"quit"
]
[
(lib.map (x: "-ex ${lib.escapeShellArg x}"))
(lib.concatStringsSep " ")
];
in
args.substitutions
(
pythonFinal: pythonPrev:
let
# TODO: export NIX_DEBUG_INFO_DIRS or "set debug-file-directory ${symlinkJoin ...}"
gdb-batch = [
"set style enabled on"
# "layout asm"
# export NIX_DEBUG_INFO_DIRS=/nix/store/xd69daaly33m7zid6g31glwmml7lk93f-openssl-1.0.2p-debug/lib/debug
# "set debug-file-directory /nix/store/xd69daaly33m7zid6g31glwmml7lk93f-openssl-1.0.2p-debug/lib/debug"
"run"
# "thread apply all backtrace"
# "backtrace"
"backtrace full"
"quit"
];
gdb-args = lib.pipe gdb-batch [
(lib.map (x: "-ex ${lib.escapeShellArg x}"))
(lib.concatStringsSep " ")
];
mkPytestCheckHook =
prefix:
pythonFinal.pytestCheckHook.override (old: {
makePythonHook =
args:
old.makePythonHook (
args
// {
pythonCheckInterpreter = "${lib.getExe final.gdb} -batch ${gdb-args} --return-child-result --args ${args.substitutions.pythonCheckInterpreter}";
};
}
);
});
pytestCheckHookWithValgrind = pythonFinal.pytestCheckHook.override (old: {
makePythonHook =
args:
old.makePythonHook (
args
// {
substitutions = args.substitutions // {
pythonCheckInterpreter = "${lib.getExe final.valgrind} --leak-check=full --show-leak-kinds=all -- ${args.substitutions.pythonCheckInterpreter}";
# pythonCheckInterpreter = "${lib.getExe final.valgrind} -- ${args.substitutions.pythonCheckInterpreter}";
};
}
);
});
})
substitutions = args.substitutions // {
pythonCheckInterpreter = "${prefix} ${args.substitutions.pythonCheckInterpreter}";
};
}
);
});
in
{
pytestCheckHookWithGdb = mkPytestCheckHook "${lib.getExe final.gdb} -batch ${gdb-args} --return-child-result --args";
pytestCheckHookWithGdbTimeout = mkPytestCheckHook "timeout 300 ${lib.getExe final.gdb} -batch ${gdb-args} --return-child-result --args";
pytestCheckHookWithValgrind = mkPytestCheckHook "${lib.getExe final.valgrind} --leak-check=full --show-leak-kinds=all --";
# = mkPytestCheckHook "${lib.getExe final.valgrind} --";
}
)
];
};