Added a new --lint option to the pio project config command // Resolve #4644

This commit is contained in:
Ivan Kravets committed 2023-06-20 14:25:30 +03:00
1 parent 5ffa42a5a2
commit e9cf551101
4 files changed
+117 -4

No files matched your search

+31
View File
@@ -684,3 +684,34 @@ def test_invalid_env_names(tmp_path: Path):
config = ProjectConfig(str(project_conf))
with pytest.raises(InvalidEnvNameError, match=r".*Invalid environment name 'app:1"):
config.validate()
def test_linting_errors(tmp_path: Path):
project_conf = tmp_path / "platformio.ini"
project_conf.write_text(
"""
[env:app1]
lib_use = 1
broken_line
"""
)
result = ProjectConfig.lint(str(project_conf))
assert not result["warnings"]
assert result["errors"] and len(result["errors"]) == 1
error = result["errors"][0]
assert error["type"] == "ParsingError"
assert error["lineno"] == 4
def test_linting_warnings(tmp_path: Path):
project_conf = tmp_path / "platformio.ini"
project_conf.write_text(
"""
[env:app1]
lib_use = 1
"""
)
result = ProjectConfig.lint(str(project_conf))
assert not result["errors"]
assert result["warnings"] and len(result["warnings"]) == 1
assert "deprecated" in result["warnings"][0]