feat(flutter): ensured flutter build warnings are not writted to stderr and cause test run to fail

This commit is contained in:
Jon Samwell 2019-09-22 11:57:38 +10:00
parent cc25319171
commit 6df1a05251
6 changed files with 24 additions and 7 deletions

View File

@ -1,3 +1,7 @@
## [1.1.1] - 20/09/2019
* Updated to latest Gherkin library
* Ensured Gradle build warnings do not output to `stderr` and cause tests runs to fail just because of build warnings
## [1.1.0] - 20/09/2019
* Updated to latest Gherkin lib which implements langauges - features can now be written in different languages / dialects! See https://cucumber.io/docs/gherkin/reference/#overview for supported dialects.
* Ensured the hook to take a screenshot `AttachScreenhotOnFailedStepHook` works for steps that error or timeout as well as fail.

View File

@ -631,11 +631,16 @@ import 'package:gherkin/gherkin.dart';
class GivenIAddTheUsers extends Given1<Table> {
@override
Future<void> executeStep(Table dataTable) async {
// TODO: implement executeStep
for (var row in dataTable.rows) {
// do something with row
row.columns.forEach((columnValue) => print(columnValue));
}
// or get the table as a map (column values keyed by the header)
final columns = dataTable.asMap();
final personOne = columns.elementAt(0);
final personOneName = personOne["Firstname"];
print('Name of first user: `$personOneName`');
}
@override

File diff suppressed because one or more lines are too long

View File

@ -5,6 +5,7 @@ import 'package:gherkin/gherkin.dart';
class FlutterRunProcessHandler extends ProcessHandler {
static const String FAIL_COLOR = "\u001b[33;31m"; // red
static const String WARN_COLOR = "\u001b[33;10m"; // yellow
static const String RESET_COLOR = "\u001b[33;0m";
static RegExp _observatoryDebuggerUriRegex = RegExp(
@ -72,8 +73,15 @@ class FlutterRunProcessHandler extends ProcessHandler {
_runningProcess.stdout.transform(utf8.decoder).asBroadcastStream();
_openSubscriptions.add(_runningProcess.stderr.listen((events) {
stderr.writeln(
"${FAIL_COLOR}Flutter run error: ${String.fromCharCodes(events)}$RESET_COLOR");
final line = String.fromCharCodes(events).trim();
if (line.startsWith('Note:')) {
// This is most likely a depricated api usage warnings (from Gradle) and should not
// cause the test run to fail.
stdout
.writeln("${WARN_COLOR}Flutter build warning: ${line}$RESET_COLOR");
} else {
stderr.writeln("${FAIL_COLOR}Flutter build error: ${line}$RESET_COLOR");
}
}));
}

View File

@ -104,7 +104,7 @@ packages:
name: gherkin
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
glob:
dependency: "direct main"
description:

View File

@ -1,6 +1,6 @@
name: flutter_gherkin
description: A Gherkin / Cucumber parser and test runner for Dart and Flutter
version: 1.1.0
version: 1.1.1
author: Jon Samwell <jonsamwell@gmail.com>
homepage: https://github.com/jonsamwell/flutter_gherkin
@ -16,7 +16,7 @@ dependencies:
sdk: flutter
glob: ^1.1.7
meta: ">=1.1.6 <2.0.0"
gherkin: ^1.1.0
gherkin: ^1.1.1
dev_dependencies:
test: ">=1.6.1 <1.7.0"