diff --git a/tmt/base.py b/tmt/base.py index 859f6bbe4d..ae01d5784e 100644 --- a/tmt/base.py +++ b/tmt/base.py @@ -2130,6 +2130,21 @@ def lint_unknown_keys(self) -> LinterReturn: yield LinterOutcome.PASS, 'correct keys are used' + def lint_empty_env_files(self) -> LinterReturn: + """ P001: env files are not empty """ + + env_files = self.node.get("environment-file") or [] + if env_files: + for env_file in env_files: + env_file = Path(env_file).resolve() + + if not env_file.exists() or not env_file.stat().st_size: + yield LinterOutcome.FAIL, f'the file "{env_file}" does not exists or is empty' + + return + + yield LinterOutcome.PASS, 'no empty environment files found' + def lint_execute_not_defined(self) -> LinterReturn: """ P002: execute step must be defined with "how" """