cppcheck: improve and skip failing tests on darwin (#369673)

This commit is contained in:
Gaétan Lepage
2024-12-31 15:46:26 +01:00
committed by GitHub
+35 -6
View File
@@ -3,14 +3,20 @@
stdenv,
fetchFromGitHub,
# nativeBuildInputs
docbook_xml_dtd_45,
docbook_xsl,
installShellFiles,
libxslt,
pcre,
pkg-config,
python3,
which,
# buildInputs
pcre,
versionCheckHook,
gitUpdater,
}:
stdenv.mkDerivation (finalAttrs: {
@@ -25,7 +31,7 @@ stdenv.mkDerivation (finalAttrs: {
src = fetchFromGitHub {
owner = "danmar";
repo = "cppcheck";
rev = finalAttrs.version;
tag = finalAttrs.version;
hash = "sha256-awmWfVl7gMLROEkjYdSpbXnFaWQwEX9Ah8B9E0OOFm0=";
};
@@ -58,10 +64,25 @@ stdenv.mkDerivation (finalAttrs: {
doCheck = !(stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64);
doInstallCheck = true;
postPatch = ''
substituteInPlace Makefile \
--replace 'PCRE_CONFIG = $(shell which pcre-config)' 'PCRE_CONFIG = $(PKG_CONFIG) libpcre'
'';
postPatch =
''
substituteInPlace Makefile \
--replace-fail 'PCRE_CONFIG = $(shell which pcre-config)' 'PCRE_CONFIG = $(PKG_CONFIG) libpcre'
''
# Expected:
# Internal Error. MathLib::toDoubleNumber: conversion failed: 1invalid
#
# Actual:
# Internal Error. MathLib::toDoubleNumber: input was not completely consumed: 1invalid
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace test/testmathlib.cpp \
--replace-fail \
'ASSERT_THROW_INTERNAL_EQUALS(MathLib::toDoubleNumber("1invalid"), INTERNAL, "Internal Error. MathLib::toDoubleNumber: conversion failed: 1invalid");' \
"" \
--replace-fail \
'ASSERT_THROW_INTERNAL_EQUALS(MathLib::toDoubleNumber("1.1invalid"), INTERNAL, "Internal Error. MathLib::toDoubleNumber: conversion failed: 1.1invalid");' \
""
'';
postBuild = ''
make DB2MAN=${docbook_xsl}/xml/xsl/docbook/manpages/docbook.xsl man
@@ -71,6 +92,10 @@ stdenv.mkDerivation (finalAttrs: {
installManPage cppcheck.1
'';
nativeInstallCheckInputs = [
versionCheckHook
];
versionCheckProgramArg = [ "--version" ];
installCheckPhase = ''
runHook preInstallCheck
@@ -80,6 +105,10 @@ stdenv.mkDerivation (finalAttrs: {
runHook postInstallCheck
'';
passthru = {
updateScript = gitUpdater { };
};
meta = {
description = "Static analysis tool for C/C++ code";
longDescription = ''