From 6ae1d01bcd55a739f3593e28dd8d2bf7dbd8fd69 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Tue, 31 Dec 2024 14:41:39 +0100 Subject: [PATCH] cppcheck: improve and skip failing tests on darwin --- pkgs/by-name/cp/cppcheck/package.nix | 41 ++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/pkgs/by-name/cp/cppcheck/package.nix b/pkgs/by-name/cp/cppcheck/package.nix index 2f355e33d958..7e57a23270e8 100644 --- a/pkgs/by-name/cp/cppcheck/package.nix +++ b/pkgs/by-name/cp/cppcheck/package.nix @@ -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 = ''