@@ -319,8 +319,7 @@ internal extension swiftscan_diagnostic_severity_t {
319
319
api. swiftscan_string_set_dispose != nil
320
320
}
321
321
322
- @_spi ( Testing) public func queryTargetInfo( invocationCommand: [ String ] )
323
- throws -> FrontendTargetInfo {
322
+ func queryTargetInfo( invocationCommand: [ String ] ) throws -> FrontendTargetInfo {
324
323
// Create and configure the scanner invocation
325
324
let invocation = api. swiftscan_scan_invocation_create ( )
326
325
defer { api. swiftscan_scan_invocation_dispose ( invocation) }
@@ -334,18 +333,35 @@ internal extension swiftscan_diagnostic_severity_t {
334
333
print ( " --> ResultData: \( targetInfoData) " )
335
334
let info = try JSONDecoder ( ) . decode ( FrontendTargetInfo . self, from: targetInfoData)
336
335
print ( " --> Result info: \( info) " )
337
- let verifiedInfo = verifyTargetInfo ( info)
338
- print ( " --> Verified Result info: \( info) " )
339
- return verifiedInfo
336
+ return info
340
337
}
341
338
342
- private func verifyTargetInfo( _ info: FrontendTargetInfo ) -> FrontendTargetInfo {
343
- print ( " <<< Verifying Target Info >>> " )
344
- print ( info. compilerVersion)
345
- print ( info. paths)
346
- print ( info. target)
347
- print ( " <<< --------------------- >>> " )
348
- return info
339
+
340
+ @_spi ( Testing) public func verifyBeingAbleToQueryTargetInfo( invocationCommand: [ String ] ) -> Bool {
341
+ do {
342
+ // Create and configure the scanner invocation
343
+ let invocation = api. swiftscan_scan_invocation_create ( )
344
+ defer { api. swiftscan_scan_invocation_dispose ( invocation) }
345
+ withArrayOfCStrings ( invocationCommand) { invocationStringArray in
346
+ api. swiftscan_scan_invocation_set_argv ( invocation,
347
+ Int32 ( invocationCommand. count) ,
348
+ invocationStringArray)
349
+ }
350
+ let targetInfoString = try toSwiftString ( api. swiftscan_compiler_target_info_query ( invocation) )
351
+ let targetInfoData = Data ( targetInfoString. utf8)
352
+ print ( " --> ResultData: \( targetInfoData) " )
353
+ let info = try JSONDecoder ( ) . decode ( FrontendTargetInfo . self, from: targetInfoData)
354
+ print ( " --> Result info: \( info) " )
355
+ print ( " <<< Verifying Target Info >>> " )
356
+ print ( info. compilerVersion)
357
+ print ( info. paths)
358
+ print ( info. target)
359
+ print ( " <<< --------------------- >>> " )
360
+ } catch {
361
+ print ( error)
362
+ return false
363
+ }
364
+ return true
349
365
}
350
366
}
351
367
0 commit comments