@@ -251,11 +251,15 @@ List<String> nmParameterFor(OS targetOS) => switch (targetOS) {
251
251
OS () => ['-D' ],
252
252
};
253
253
254
- Future <String > readSymbols (CodeAsset asset, OS targetOS) async {
254
+ /// Returns null if the tool to extract the symbols is not available.
255
+ Future <String ?> readSymbols (CodeAsset asset, OS targetOS) async {
255
256
final assetUri = asset.file! ;
256
257
switch (targetOS) {
257
258
case OS .windows:
258
259
final result = await _runDumpbin (['/EXPORTS' ], asset.file! );
260
+ if (result == null ) {
261
+ return null ;
262
+ }
259
263
expect (result.exitCode, 0 );
260
264
return result.stdout;
261
265
case OS ():
@@ -269,12 +273,18 @@ Future<String> readSymbols(CodeAsset asset, OS targetOS) async {
269
273
}
270
274
}
271
275
272
- Future <RunProcessResult > _runDumpbin (List <String > arguments, Uri libUri) async {
273
- final dumpbinUri = (await dumpbin.defaultResolver! .resolve (
274
- logger: logger,
275
- )).first.uri;
276
+ /// Returns null if the dumpbin tool is not available.
277
+ Future <RunProcessResult ?> _runDumpbin (
278
+ List <String > arguments,
279
+ Uri libUri,
280
+ ) async {
281
+ final dumpbinTools = await dumpbin.defaultResolver! .resolve (logger: logger);
282
+ if (dumpbinTools.isEmpty) {
283
+ logger.info ('Unable to locate dumpbin tool. Some expects may be skipped.' );
284
+ return null ;
285
+ }
276
286
return await runProcess (
277
- executable: dumpbinUri ,
287
+ executable: dumpbinTools.first.uri ,
278
288
arguments: [...arguments, libUri.toFilePath ()],
279
289
logger: logger,
280
290
);
@@ -369,7 +379,7 @@ const dumpbinFileFormat = {
369
379
/// executed on the provided [targetArch] architecture.
370
380
///
371
381
/// On Linux, the format of the binary is determined by `readelf` . On MacOS,
372
- /// the `objsdump ` tool is used. On Windows, `dumpbin` is used.
382
+ /// the `objdump ` tool is used. On Windows, `dumpbin` is used.
373
383
Future <void > expectMachineArchitecture (
374
384
Uri libUri,
375
385
Architecture targetArch,
@@ -394,11 +404,14 @@ Future<void> expectMachineArchitecture(
394
404
);
395
405
} else if (Platform .isWindows && targetOS == OS .windows) {
396
406
final result = await _runDumpbin (['/HEADERS' ], libUri);
397
- expect (result.exitCode, 0 );
398
- final machine = result.stdout
407
+ final skipReason = result == null
408
+ ? 'tool to determine binary architecture unavailable'
409
+ : false ;
410
+ expect (result? .exitCode, 0 , skip: skipReason);
411
+ final machine = result? .stdout
399
412
.split ('\n ' )
400
413
.firstWhere ((e) => e.contains ('machine' ));
401
- expect (machine, contains (dumpbinFileFormat[targetArch]));
414
+ expect (machine, contains (dumpbinFileFormat[targetArch]), skip : skipReason );
402
415
}
403
416
}
404
417
0 commit comments