Properly handle the check_src_filters option per environment

Resolves #4788
This commit is contained in:
valeros
2023-11-17 13:12:40 +02:00
parent e1f34c7ea0
commit 961ab6b35e
3 changed files with 40 additions and 2 deletions

View File

@ -23,6 +23,8 @@ test-driven methodologies, and modern toolchains for unrivaled success.
* Drastically enhanced the speed of project building when operating in verbose mode (`issue #4783 <https://github.com/platformio/platformio-core/issues/4783>`_)
* Resolved an issue where the ``COMPILATIONDB_INCLUDE_TOOLCHAIN`` setting was not correctly applying to private libraries (`issue #4762 <https://github.com/platformio/platformio-core/issues/4762>`_)
* Resolved an issue where ``get_systype()`` inaccurately returned the architecture when executed within a Docker container on a 64-bit kernel with a 32-bit userspace (`issue #4777 <https://github.com/platformio/platformio-core/issues/4777>`_)
* Resolved an issue with incorrect handling of the ``check_src_filters`` option when used in multiple environments (`issue #4788 <https://github.com/platformio/platformio-core/issues/4788>`_)
6.1.11 (2023-08-31)
~~~~~~~~~~~~~~~~~~~

View File

@ -108,7 +108,7 @@ def cli(
"+<%s>" % os.path.basename(config.get("platformio", "include_dir")),
]
src_filters = (
env_src_filters = (
src_filters
or pattern
or env_options.get(
@ -120,7 +120,7 @@ def cli(
tool_options = dict(
verbose=verbose,
silent=silent,
src_filters=src_filters,
src_filters=env_src_filters,
flags=flags or env_options.get("check_flags"),
severity=[DefectItem.SEVERITY_LABELS[DefectItem.SEVERITY_HIGH]]
if silent

View File

@ -767,3 +767,39 @@ check_patterns =
assert errors + warnings + style == EXPECTED_DEFECTS * 2
assert "main.cpp" not in result.output
def test_check_src_filter_multiple_envs(clirunner, validate_cliresult, tmpdir_factory):
tmpdir = tmpdir_factory.mktemp("project")
config = """
[env]
check_tool = cppcheck
check_src_filters =
+<src/*>
[env:check_sources]
platform = native
[env:check_tests]
platform = native
check_src_filters =
+<test/*>
"""
tmpdir.join("platformio.ini").write(config)
src_dir = tmpdir.mkdir("src")
src_dir.join("main.cpp").write(TEST_CODE)
src_dir.mkdir("spi").join("spi.cpp").write(TEST_CODE)
tmpdir.mkdir("test").join("test.cpp").write(TEST_CODE)
result = clirunner.invoke(
cmd_check, ["--project-dir", str(tmpdir), "-e", "check_tests"]
)
validate_cliresult(result)
errors, warnings, style = count_defects(result.output)
assert errors + warnings + style == EXPECTED_DEFECTS
assert "test.cpp" in result.output
assert "main.cpp" not in result.output