diff --git a/HISTORY.rst b/HISTORY.rst index 014fc8f3..cfe23a1c 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -21,6 +21,7 @@ PlatformIO Core 6 * Resolved an issue that caused generated projects for `PlatformIO IDE for VSCode `__ to break when the ``-iprefix`` compiler flag was used * Resolved an issue encountered while utilizing the `pio pkg exec `__ command on the Windows platform to execute Python scripts from a package * Implemented a crucial improvement to the `pio run `__ command, guaranteeing that the ``monitor`` target is not executed if any of the preceding targets, such as ``upload``, encounter failures +* `Cppcheck `__ v2.11 with new checks, CLI commands and various analysis improvements 6.1.9 (2023-07-06) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/__init__.py b/platformio/__init__.py index 2cd1ac9d..aa43c2d1 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -46,7 +46,7 @@ __core_packages__ = { "contrib-piohome": "~3.4.2", "contrib-pioremote": "~1.0.0", "tool-scons": "~4.40502.0", - "tool-cppcheck": "~1.270.0", + "tool-cppcheck": "~1.21100.0", "tool-clangtidy": "~1.150005.0", "tool-pvs-studio": "~7.18.0", } diff --git a/tests/commands/test_check.py b/tests/commands/test_check.py index cb6f7777..91679d03 100644 --- a/tests/commands/test_check.py +++ b/tests/commands/test_check.py @@ -69,7 +69,7 @@ PVS_STUDIO_FREE_LICENSE_HEADER = """ EXPECTED_ERRORS = 5 EXPECTED_WARNINGS = 1 -EXPECTED_STYLE = 2 +EXPECTED_STYLE = 4 EXPECTED_DEFECTS = EXPECTED_ERRORS + EXPECTED_WARNINGS + EXPECTED_STYLE @@ -345,7 +345,10 @@ def test_check_individual_flags_passed(clirunner, validate_cliresult, tmpdir): assert pvs_flags_found -def test_check_cppcheck_misra_addon(clirunner, validate_cliresult, check_dir): +def test_check_cppcheck_misra_addon(clirunner, validate_cliresult, tmpdir_factory): + check_dir = tmpdir_factory.mktemp("project") + check_dir.join("platformio.ini").write(DEFAULT_CONFIG) + check_dir.mkdir("src").join("main.c").write(TEST_CODE) check_dir.join("misra.json").write( """ { @@ -508,16 +511,18 @@ TEST-TEST-TEST-TEST assert verbose_result.exit_code != 0 assert "license information is incorrect" in verbose_result.output.lower() - -def test_check_embedded_platform_all_tools(clirunner, validate_cliresult, tmpdir): - config = """ +@pytest.mark.parametrize("framework", ["arduino", "stm32cube", "zephyr"]) +@pytest.mark.parametrize("check_tool", ["cppcheck", "clangtidy", "pvs-studio"]) +def test_check_embedded_platform_all_tools( + clirunner, validate_cliresult, tmpdir, framework, check_tool +): + config = f""" [env:test] platform = ststm32 board = nucleo_f401re -framework = %s -check_tool = %s +framework = {framework} +check_tool = {check_tool} """ - # tmpdir.join("platformio.ini").write(config) tmpdir.mkdir("src").join("main.c").write( PVS_STUDIO_FREE_LICENSE_HEADER + """ @@ -534,20 +539,12 @@ int main() { """ ) - for framework in ( - "arduino", - "stm32cube", - "zephyr", - ): - for tool in ("cppcheck", "clangtidy", "pvs-studio"): - tmpdir.join("platformio.ini").write(config % (framework, tool)) - result = clirunner.invoke(cmd_check, ["--project-dir", str(tmpdir)]) - validate_cliresult(result) - defects = sum(count_defects(result.output)) - assert defects > 0, "Failed %s with %s" % ( - framework, - tool, - ) + + tmpdir.join("platformio.ini").write(config) + result = clirunner.invoke(cmd_check, ["--project-dir", str(tmpdir)]) + validate_cliresult(result) + defects = sum(count_defects(result.output)) + assert defects > 0, "Not defects were found!" def test_check_skip_includes_from_packages(clirunner, validate_cliresult, tmpdir):