5
5
import yaml
6
6
import os
7
7
import sys
8
- from pathlib import Path
9
8
import copy
9
+ import traceback
10
+ from pathlib import Path
10
11
11
- # Resolve repository root from this script location: .gitlab/scripts -> esp32 root
12
+ # Resolve repository root from this script location
12
13
SCRIPT_DIR = Path (__file__ ).resolve ().parent
13
14
REPO_ROOT = SCRIPT_DIR .parent .parent
15
+ TESTS_ROOT = REPO_ROOT / "tests"
14
16
15
17
# Ensure we run from repo root so relative paths work consistently
16
18
try :
17
19
os .chdir (REPO_ROOT )
18
- except Exception :
19
- pass
20
-
21
- TESTS_ROOT = REPO_ROOT / "tests"
20
+ except Exception as e :
21
+ sys .stderr .write (f"[WARN] Failed to chdir to repo root '{ REPO_ROOT } ': { e } \n " )
22
+ sys .stderr .write (traceback .format_exc () + "\n " )
22
23
23
24
24
25
class PrettyDumper (yaml .SafeDumper ):
@@ -35,7 +36,9 @@ def read_json(p: Path):
35
36
try :
36
37
with p .open ("r" , encoding = "utf-8" ) as f :
37
38
return json .load (f )
38
- except Exception :
39
+ except Exception as e :
40
+ sys .stderr .write (f"[WARN] Failed to parse JSON file '{ p } ': { e } \n " )
41
+ sys .stderr .write (traceback .format_exc () + "\n " )
39
42
return {}
40
43
41
44
@@ -155,7 +158,9 @@ def sdk_meets_requirements(sdkconfig: Path, ci_json: dict) -> bool:
155
158
if not ok :
156
159
return False
157
160
return True
158
- except Exception :
161
+ except Exception as e :
162
+ sys .stderr .write (f"[WARN] Failed to evaluate requirements against '{ sdkconfig } ': { e } \n " )
163
+ sys .stderr .write (traceback .format_exc () + "\n " )
159
164
return False
160
165
161
166
@@ -166,13 +171,13 @@ def parse_list_arg(s: str) -> list[str]:
166
171
if txt .startswith ("[" ) and txt .endswith ("]" ):
167
172
try :
168
173
return [str (x ).strip () for x in json .loads (txt )]
169
- except Exception :
170
- # Attempt single-quote JSON -> replace with double quotes
174
+ except Exception as e :
175
+ sys . stderr . write ( f"[WARN] Failed to parse JSON list ' { txt } ': { e } . Retrying with quote normalization. \n " )
171
176
try :
172
177
fixed = txt .replace ("'" , '"' )
173
178
return [str (x ).strip () for x in json .loads (fixed )]
174
- except Exception :
175
- pass
179
+ except Exception as e2 :
180
+ sys . stderr . write ( f"[WARN] Failed to parse JSON list after normalization: { e2 } . Falling back to CSV parsing. \n " )
176
181
# Fallback: comma-separated
177
182
return [part .strip () for part in txt .split ("," ) if part .strip ()]
178
183
0 commit comments