From 2a646487b483a46d9915f808e7430faab61625fc Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Fri, 25 Sep 2020 16:35:41 -0700 Subject: [PATCH 1/3] Added test and fixed bug where running without arguments would crash. --- packages/pigeon/CHANGELOG.md | 4 ++++ packages/pigeon/bin/pigeon.dart | 14 +++++++++----- packages/pigeon/lib/generator_tools.dart | 2 +- packages/pigeon/pubspec.yaml | 2 +- packages/pigeon/run_tests.sh | 5 +++++ 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/packages/pigeon/CHANGELOG.md b/packages/pigeon/CHANGELOG.md index 4d0ef22ebb44..3763675dc3f6 100644 --- a/packages/pigeon/CHANGELOG.md +++ b/packages/pigeon/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.9 + +* Fixed bug where executing pigeon without arguments would crash (introduced in 0.1.8). + ## 0.1.8 * Started spawning pigeon_lib in an isolate instead of a subprocess. The diff --git a/packages/pigeon/bin/pigeon.dart b/packages/pigeon/bin/pigeon.dart index 72497a87cd5e..cbd708a102c4 100644 --- a/packages/pigeon/bin/pigeon.dart +++ b/packages/pigeon/bin/pigeon.dart @@ -11,13 +11,17 @@ import 'package:pigeon/pigeon_lib.dart'; Future main(List args) async { final PigeonOptions opts = Pigeon.parseArgs(args); assert(opts.input != null); - final String rawInputPath = opts.input; final Directory tempDir = Directory.systemTemp.createTempSync(); - final String absInputPath = File(rawInputPath).absolute.path; - final String relInputPath = path.relative(absInputPath, from: tempDir.path); - final String importLine = - (opts.input != null) ? 'import \'$relInputPath\';\n' : ''; + String importLine = ''; + if (opts.input != null) { + final String rawInputPath = opts.input; + final String absInputPath = File(rawInputPath).absolute.path; + final String relInputPath = path.relative(absInputPath, from: tempDir.path); + + importLine = + (opts.input != null) ? 'import \'$relInputPath\';\n' : ''; + } final String code = """$importLine import 'dart:io'; import 'dart:isolate'; diff --git a/packages/pigeon/lib/generator_tools.dart b/packages/pigeon/lib/generator_tools.dart index 940fa19d0060..05a9c6795b7e 100644 --- a/packages/pigeon/lib/generator_tools.dart +++ b/packages/pigeon/lib/generator_tools.dart @@ -8,7 +8,7 @@ import 'dart:mirrors'; import 'ast.dart'; /// The current version of pigeon. -const String pigeonVersion = '0.1.8'; +const String pigeonVersion = '0.1.9'; /// Read all the content from [stdin] to a String. String readStdin() { diff --git a/packages/pigeon/pubspec.yaml b/packages/pigeon/pubspec.yaml index d2ff73ccc37c..c9324df0e472 100644 --- a/packages/pigeon/pubspec.yaml +++ b/packages/pigeon/pubspec.yaml @@ -1,5 +1,5 @@ name: pigeon -version: 0.1.8 +version: 0.1.9 description: Code generator tool to make communication between Flutter and the host platform type-safe and easier. homepage: https://github.com/flutter/packages/tree/master/packages/pigeon dependencies: diff --git a/packages/pigeon/run_tests.sh b/packages/pigeon/run_tests.sh index 9650f6d4d5bf..15e4093151fe 100755 --- a/packages/pigeon/run_tests.sh +++ b/packages/pigeon/run_tests.sh @@ -73,6 +73,11 @@ test_pigeon_android() { pub get pub run test test/ +############################################################################### +# Execute without arguments test +############################################################################### +pub run pigeon + ############################################################################### # Compilation tests (Code is generated and compiled) ############################################################################### From d9f55af19bf07112d71fb04bb8a9eaa499c39deb Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Fri, 25 Sep 2020 16:44:35 -0700 Subject: [PATCH 2/3] removed extra code --- packages/pigeon/bin/pigeon.dart | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/pigeon/bin/pigeon.dart b/packages/pigeon/bin/pigeon.dart index cbd708a102c4..8e12fde65dc9 100644 --- a/packages/pigeon/bin/pigeon.dart +++ b/packages/pigeon/bin/pigeon.dart @@ -18,9 +18,7 @@ Future main(List args) async { final String rawInputPath = opts.input; final String absInputPath = File(rawInputPath).absolute.path; final String relInputPath = path.relative(absInputPath, from: tempDir.path); - - importLine = - (opts.input != null) ? 'import \'$relInputPath\';\n' : ''; + importLine = 'import \'$relInputPath\';\n'; } final String code = """$importLine import 'dart:io'; From b1ae561ab4b3ad643fd8226c4c5c017310aa30db Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Fri, 25 Sep 2020 17:06:51 -0700 Subject: [PATCH 3/3] removed assert --- packages/pigeon/bin/pigeon.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/pigeon/bin/pigeon.dart b/packages/pigeon/bin/pigeon.dart index 8e12fde65dc9..441595617646 100644 --- a/packages/pigeon/bin/pigeon.dart +++ b/packages/pigeon/bin/pigeon.dart @@ -10,7 +10,6 @@ import 'package:pigeon/pigeon_lib.dart'; Future main(List args) async { final PigeonOptions opts = Pigeon.parseArgs(args); - assert(opts.input != null); final Directory tempDir = Directory.systemTemp.createTempSync(); String importLine = '';