forked from platformio/platformio-core
Refactor PIO Check feature (#3478)
* Add new option --skip-packages for check command Check tools might fail if they're not able to preprocess source files, for example, Cppcheck uses a custom preprocessor that is not able to parse complex preprocessor code in zephyr framework). Instead user can specify this option to skip headers included from packages and only check project sources. * Fix toolchain built-in include paths order C++ and fixed directories should have higher priority * Refactor check feature The main purpose is to prepare a more comprehensive build environment. It's crucial for cppcheck to be able to check complex frameworks like zephyr, esp-idf, etc. Also detect a special case when cppcheck fails to check the entire project (e.g. a syntax error due to custom preprocessor) * Add new test for check feature Tests ststm32 platform all tools and the main frameworks * Update check tools to the latest available versions * Test check tools and Zephyr framework only with Python 3 * Tidy up code * Add history entry
This commit is contained in:
1 parent
62ede23b0e
commit
c03f93521b
13 files changed
+299
-112
No files matched your search
@@ -14,6 +14,7 @@
|
||||
|
||||
import json
|
||||
from os.path import isfile, join
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -383,3 +384,47 @@ check_tool = pvs-studio
|
||||
assert errors != 0
|
||||
assert warnings != 0
|
||||
assert style == 0
|
||||
|
||||
|
||||
def test_check_embedded_platform_all_tools(clirunner, tmpdir):
|
||||
config = """
|
||||
[env:test]
|
||||
platform = ststm32
|
||||
board = nucleo_f401re
|
||||
framework = %s
|
||||
check_tool = %s
|
||||
"""
|
||||
# tmpdir.join("platformio.ini").write(config)
|
||||
tmpdir.mkdir("src").join("main.c").write(
|
||||
"""// This is an open source non-commercial project. Dear PVS-Studio, please check it.
|
||||
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com
|
||||
#include <stdlib.h>
|
||||
|
||||
void unused_function(int val){
|
||||
int unusedVar = 0;
|
||||
int* iP = &unusedVar;
|
||||
*iP++;
|
||||
}
|
||||
|
||||
int main() {
|
||||
}
|
||||
"""
|
||||
)
|
||||
|
||||
frameworks = ["arduino", "mbed", "stm32cube"]
|
||||
if sys.version_info[0] == 3:
|
||||
# Zephyr only supports Python 3
|
||||
frameworks.append("zephyr")
|
||||
|
||||
for framework in frameworks:
|
||||
for tool in ("cppcheck", "clangtidy", "pvs-studio"):
|
||||
tmpdir.join("platformio.ini").write(config % (framework, tool))
|
||||
|
||||
result = clirunner.invoke(cmd_check, ["--project-dir", str(tmpdir)])
|
||||
|
||||
defects = sum(count_defects(result.output))
|
||||
|
||||
assert result.exit_code == 0 and defects > 0, "Failed %s with %s" % (
|
||||
framework,
|
||||
tool,
|
||||
)
|
||||
Reference in new issue
Block a user