]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
test/yaml: Improve YAML parsing error messages
authorJeff Lucovsky <jeff@lucovsky.org>
Tue, 25 Jan 2022 19:14:50 +0000 (14:14 -0500)
committerVictor Julien <victor@inliniac.net>
Thu, 10 Nov 2022 13:03:49 +0000 (15:03 +0200)
Without this commit, a YAML syntactic error is silently ignored. This
patch displays the YAML exception, if any, that occurs while loading the
YAML config file.

run.py

diff --git a/run.py b/run.py
index ce3615f780aa2d89096a273e5aa70b2ab6cec654..523095bc0a71e288ae767070eabfcbee2c67aed1 100755 (executable)
--- a/run.py
+++ b/run.py
@@ -524,8 +524,11 @@ class TestRunner:
 
     def load_config(self):
         if os.path.exists(os.path.join(self.directory, "test.yaml")):
-            self.config = yaml.safe_load(
-                open(os.path.join(self.directory, "test.yaml"), "rb"))
+            try:
+                self.config = yaml.safe_load(
+                    open(os.path.join(self.directory, "test.yaml"), "rb"))
+            except yaml.scanner.ScannerError as e:
+                print(str(e))
         if self.config is None:
             self.config = {}