@@ -65,7 +65,6 @@ def annot_to_ty(annot: str) -> type[Any]:
6565 "dict" : dict ,
6666 "str" : str ,
6767 "ByteSize" : int ,
68- "TestData" : TestData ,
6968 "TargetData" : TargetData ,
7069 "Variable" : Variable ,
7170 "Type" : Type ,
@@ -244,6 +243,20 @@ class BlessMetadata:
244243
245244@dataclass (slots = True )
246245class TargetData :
246+ """
247+ Top-level container for all test data.
248+
249+ Due to the differences between PDB and DWARF debug info, we cannot guarantee their output
250+ will be identical. Since LLDB can handle both, we need to conditionally select the correct
251+ test data to use.
252+
253+ Additionally, since there are differences in the internals of some structs based on OS (e.g.
254+ `PathBuf`/`OsString`), we need to be aware of whether we're on Windows or not.
255+
256+ A global var `TARGET` is set to the current variant upon `lldb_batchmode`'s instantiation using
257+ an env var passed from `compiletest` and is not expected to change afterwards.
258+ """
259+
247260 bless_metadata : BlessMetadata = field (default_factory = BlessMetadata )
248261 """Miscellaneous data included to make diagnosing issues easier. This data is not intended to be
249262 tested against."""
@@ -260,30 +273,9 @@ class TargetData:
260273 """Each element corresponds to one stopping point in the test. The element itself is a
261274 dictionary mapping variable names to their respective test data."""
262275
263-
264- @dataclass (slots = True )
265- class TestData :
266- """
267- Top-level container for all test data.
268-
269- Due to the differences between PDB and DWARF debug info, we cannot guarantee their output
270- will be identical. Since LLDB can handle both, we need to conditionally select the correct
271- test data to use.
272-
273- Additionally, since there are differences in the internals of some structs based on OS (e.g.
274- `PathBuf`/`OsString`), we need to be aware of whether we're on Windows or not.
275-
276- A global var `TARGET` is set to the current variant upon `lldb_batchmode`'s instantiation using
277- an env var passed from `compiletest` and is not expected to change afterwards.
278- """
279-
280- non_windows : TargetData = field (default_factory = TargetData )
281- windows_gnu : TargetData = field (default_factory = TargetData )
282- windows_msvc : TargetData = field (default_factory = TargetData )
283-
284276 @staticmethod
285- def initialize () -> "TestData " :
286- result = TestData ()
277+ def initialize () -> "TargetData " :
278+ result = TargetData ()
287279 path = os .environ ["LLDB_BATCHMODE_INPUT_DATA_PATH" ]
288280 if not os .path .isfile (path ):
289281 if BLESS :
@@ -296,47 +288,17 @@ def initialize() -> "TestData":
296288
297289 with open (path , "r" ) as f :
298290 try :
299- data : dict [ str , JsonType ] = json .load (f )
291+ result = from_dict ( TargetData , json .load (f ) )
300292 except json .decoder .JSONDecodeError :
301293 print ("Warning: Malformed input data, reverting to default" )
302- result .non_windows = TargetData ()
303- result .windows_gnu = TargetData ()
304- result .windows_msvc = TargetData ()
305- return result
306-
307- if BLESS and TARGET == Target .WindowsGnu :
308- result .windows_gnu = TargetData ()
309- else :
310- result .windows_gnu = from_dict (TargetData , data ["windows_gnu" ])
311-
312- if BLESS and TARGET == Target .WindowsMsvc :
313- result .windows_msvc = TargetData ()
314- else :
315- result .windows_msvc = from_dict (TargetData , data ["windows_msvc" ])
316-
317- if BLESS and TARGET == Target .NonWindows :
318- result .non_windows = TargetData ()
319- else :
320- result .non_windows = from_dict (TargetData , data ["non_windows" ])
321294
322295 return result
323296
324- def get_target_data (self ) -> TargetData :
325- """Retrieves data from the target specified by `compiletest`"""
326-
327- if TARGET == Target .WindowsGnu :
328- return self .windows_gnu
329-
330- if TARGET == Target .WindowsMsvc :
331- return self .windows_msvc
332-
333- return self .non_windows
334-
335297 def save_blessing (self , metadata : BlessMetadata ):
336298 """Writes the entirety of `self` to the input file. Used to finalize changes made by
337299 one or more `TestData.bless_variable` calls."""
338300
339- self .get_target_data (). bless_metadata = metadata
301+ self .bless_metadata = metadata
340302 path = os .environ ["LLDB_BATCHMODE_INPUT_DATA_PATH" ]
341303 # dumping directly to a file is somewhat unsafe. If the json ends up malformed, we could
342304 # end up overwriting valid test data with a complete mess. Since the in-memory data
0 commit comments