From b3f9ba061ab7c89aa639646d640bb6dd7310262b Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Mon, 9 Aug 2021 16:17:15 -0700 Subject: [PATCH] Use runtime checks for arguments, out directory Since verify_exported.dart is not run with assertions enabled, replace the assertions with runtime checks and appropriate error messages: * Adds a check for valid arguments and emits usage otherwise * Adds a check for the presence of the out/ directory and exits with error if it does not exist. --- testing/symbols/verify_exported.dart | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/testing/symbols/verify_exported.dart b/testing/symbols/verify_exported.dart index 5aa4fae214618..a8376475e2703 100644 --- a/testing/symbols/verify_exported.dart +++ b/testing/symbols/verify_exported.dart @@ -21,10 +21,14 @@ import 'package:path/path.dart' as p; /// Takes the path to the out directory as the first argument, and the path to /// the buildtools directory as the second argument. /// -/// If the second argument is not specified, it is assumed that it is the parent -/// of the out directory (for backwards compatibility). +/// If the second argument is not specified, for backwards compatibility, it is +/// assumed that it is ../buildtools relative to the first parameter (the out +/// directory). void main(List arguments) { - assert(arguments.length == 2 || arguments.length == 1); + if (arguments.isEmpty || arguments.length > 2) { + print('usage: dart verify_exported.dart OUT_DIR [BUILDTOOLS]'); + exit(1); + } final String outPath = arguments.first; final String buildToolsPath = arguments.length == 1 ? p.join(p.dirname(outPath), 'buildtools') @@ -39,7 +43,10 @@ void main(List arguments) { throw UnimplementedError('Script only support running on Linux or MacOS.'); } final String nmPath = p.join(buildToolsPath, platform, 'clang', 'bin', 'llvm-nm'); - assert(Directory(outPath).existsSync()); + if (!Directory(outPath).existsSync()) { + print('error: build out directory not found: $outPath'); + exit(1); + } final Iterable releaseBuilds = Directory(outPath).listSync() .whereType()