From 2e19a3e4e1efa30d2f54c3dc2727baf222f5ddd2 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Wed, 23 Nov 2022 12:01:22 +0100 Subject: [PATCH 1/8] patrol_cli: bump version to 0.7.10 (#631) --- packages/patrol_cli/CHANGELOG.md | 5 +++++ packages/patrol_cli/lib/src/common/constants.dart | 2 +- packages/patrol_cli/pubspec.yaml | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/patrol_cli/CHANGELOG.md b/packages/patrol_cli/CHANGELOG.md index e579052fed..3452b31b48 100644 --- a/packages/patrol_cli/CHANGELOG.md +++ b/packages/patrol_cli/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.7.10 + +- Print error message when screenshot fails on host side (#625) +- Perform internal refactoring to make testing the CLI easier (#626) + ## 0.7.9 - Fix running tests that failed to build (#615) diff --git a/packages/patrol_cli/lib/src/common/constants.dart b/packages/patrol_cli/lib/src/common/constants.dart index b7ffec371f..1561308a1c 100644 --- a/packages/patrol_cli/lib/src/common/constants.dart +++ b/packages/patrol_cli/lib/src/common/constants.dart @@ -1,7 +1,7 @@ import 'package:path/path.dart' as path; /// Version of Patrol CLI. Must be kept in sync with pubspec.yaml. -const globalVersion = '0.7.9'; +const globalVersion = '0.7.10'; const patrolPackage = 'patrol'; const patrolCliPackage = 'patrol_cli'; diff --git a/packages/patrol_cli/pubspec.yaml b/packages/patrol_cli/pubspec.yaml index 789b8848cc..08242d36c1 100644 --- a/packages/patrol_cli/pubspec.yaml +++ b/packages/patrol_cli/pubspec.yaml @@ -1,7 +1,7 @@ name: patrol_cli description: > Command-line tool for Patrol, a powerful Flutter-native UI testing framework. -version: 0.7.9 +version: 0.7.10 homepage: https://patrol.leancode.co repository: https://github.com/leancodepl/patrol issue_tracker: https://github.com/leancodepl/patrol/issues From 0795873290b69947519a516b28f5a6b6f54d6f39 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Wed, 23 Nov 2022 12:55:22 +0100 Subject: [PATCH 2/8] revert version bump (#632) * completely remove logging.dart * Revert "patrol_cli: bump version to 0.7.10 (#631)" This reverts commit 2e19a3e4e1efa30d2f54c3dc2727baf222f5ddd2. --- packages/patrol_cli/CHANGELOG.md | 5 - .../patrol_cli/lib/src/command_runner.dart | 1 - .../patrol_cli/lib/src/common/common.dart | 1 - .../patrol_cli/lib/src/common/constants.dart | 2 +- .../patrol_cli/lib/src/common/logging.dart | 95 ------------------- packages/patrol_cli/pubspec.yaml | 2 +- 6 files changed, 2 insertions(+), 104 deletions(-) delete mode 100644 packages/patrol_cli/lib/src/common/logging.dart diff --git a/packages/patrol_cli/CHANGELOG.md b/packages/patrol_cli/CHANGELOG.md index 3452b31b48..e579052fed 100644 --- a/packages/patrol_cli/CHANGELOG.md +++ b/packages/patrol_cli/CHANGELOG.md @@ -1,8 +1,3 @@ -## 0.7.10 - -- Print error message when screenshot fails on host side (#625) -- Perform internal refactoring to make testing the CLI easier (#626) - ## 0.7.9 - Fix running tests that failed to build (#615) diff --git a/packages/patrol_cli/lib/src/command_runner.dart b/packages/patrol_cli/lib/src/command_runner.dart index ec10adccf9..fa7e9470df 100644 --- a/packages/patrol_cli/lib/src/command_runner.dart +++ b/packages/patrol_cli/lib/src/command_runner.dart @@ -28,7 +28,6 @@ import 'package:pub_updater/pub_updater.dart'; Future patrolCommandRunner(List args) async { final logger = Logger(); - await setUpLogger(); final runner = PatrolCommandRunner(logger: logger); int exitCode; diff --git a/packages/patrol_cli/lib/src/common/common.dart b/packages/patrol_cli/lib/src/common/common.dart index 0736ad16aa..842b2922c7 100644 --- a/packages/patrol_cli/lib/src/common/common.dart +++ b/packages/patrol_cli/lib/src/common/common.dart @@ -1,3 +1,2 @@ export 'constants.dart'; export 'extensions/process.dart'; -export 'logging.dart'; diff --git a/packages/patrol_cli/lib/src/common/constants.dart b/packages/patrol_cli/lib/src/common/constants.dart index 1561308a1c..b7ffec371f 100644 --- a/packages/patrol_cli/lib/src/common/constants.dart +++ b/packages/patrol_cli/lib/src/common/constants.dart @@ -1,7 +1,7 @@ import 'package:path/path.dart' as path; /// Version of Patrol CLI. Must be kept in sync with pubspec.yaml. -const globalVersion = '0.7.10'; +const globalVersion = '0.7.9'; const patrolPackage = 'patrol'; const patrolCliPackage = 'patrol_cli'; diff --git a/packages/patrol_cli/lib/src/common/logging.dart b/packages/patrol_cli/lib/src/common/logging.dart deleted file mode 100644 index 694c5dc77e..0000000000 --- a/packages/patrol_cli/lib/src/common/logging.dart +++ /dev/null @@ -1,95 +0,0 @@ -// ignore_for_file: avoid_print - -import 'dart:async'; - -import 'package:ansi_styles/ansi_styles.dart'; -import 'package:logging/logging.dart'; -import 'package:mason_logger/mason_logger.dart' as mason_logger; - -extension LoggerX on Logger { - static final _logger = mason_logger.Logger(); - - /// Writes progress message to stdout. - mason_logger.Progress progress(String message) { - return _logger.progress(message); - } - - set verbose(bool newValue) => _verbose = newValue; - - void ok(String msg) { - info('${mason_logger.green.wrap("✓")} $msg'); - } - - void err(String msg) { - info('${mason_logger.red.wrap("✗")} $msg'); - } -} - -bool _verbose = false; -StreamSubscription? _sub; - -/// Sets up the global logger. -/// -/// We use 4 log levels: -/// - [Level.SEVERE], printed in red -/// - [Level.WARNING], printed in yellow -/// - [Level.INFO], printed in white -/// - [Level.FINE], printed in grey and only when [_verbose] is true -Future setUpLogger() async { - Logger.root.level = Level.ALL; - - await _sub?.cancel(); - _sub = Logger.root.onRecord.listen((log) { - final fmtLog = _formatLog(log); - - if (log.level >= Level.SEVERE) { - print(AnsiStyles.red(fmtLog)); - } else if (log.level >= Level.WARNING) { - print(AnsiStyles.yellow(fmtLog)); - } else if (log.level >= Level.INFO) { - print(fmtLog); - } else if (log.level >= Level.FINE && _verbose) { - print(AnsiStyles.grey(fmtLog)); - } - }); -} - -/// Copied from -/// https://github.com/leancodepl/logging_bugfender/blob/master/lib/src/print_strategy.dart. -String _formatLog(LogRecord record) { - final hasName = record.loggerName.isNotEmpty; - final hasMessage = record.message != 'null' && record.message.isNotEmpty; - - final hasTopLine = hasName || hasMessage; - final hasError = record.error != null; - final hasStackTrace = record.stackTrace != null; - - final log = StringBuffer(); - - if (hasTopLine) { - log.writeAll( - [ - if (hasName) '${record.loggerName}: ', - if (hasMessage) record.message, - ], - ); - } - - if (hasTopLine && hasError) { - log.write('\n'); - } - - if (hasError) { - log.write(record.error); - } - - if (hasError && hasStackTrace) { - log.write('\n'); - } - - if (hasStackTrace) { - log.write(record.stackTrace); - } - - return log.toString(); -} diff --git a/packages/patrol_cli/pubspec.yaml b/packages/patrol_cli/pubspec.yaml index 08242d36c1..789b8848cc 100644 --- a/packages/patrol_cli/pubspec.yaml +++ b/packages/patrol_cli/pubspec.yaml @@ -1,7 +1,7 @@ name: patrol_cli description: > Command-line tool for Patrol, a powerful Flutter-native UI testing framework. -version: 0.7.10 +version: 0.7.9 homepage: https://patrol.leancode.co repository: https://github.com/leancodepl/patrol issue_tracker: https://github.com/leancodepl/patrol/issues From f8787b372ec4885d20baa8dac0d4ea7464cd3445 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Wed, 23 Nov 2022 12:56:49 +0100 Subject: [PATCH 3/8] patrol_cli: bump version to 0.7.10 (#633) --- packages/patrol_cli/CHANGELOG.md | 5 +++++ packages/patrol_cli/lib/src/common/constants.dart | 2 +- packages/patrol_cli/pubspec.yaml | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/patrol_cli/CHANGELOG.md b/packages/patrol_cli/CHANGELOG.md index e579052fed..3452b31b48 100644 --- a/packages/patrol_cli/CHANGELOG.md +++ b/packages/patrol_cli/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.7.10 + +- Print error message when screenshot fails on host side (#625) +- Perform internal refactoring to make testing the CLI easier (#626) + ## 0.7.9 - Fix running tests that failed to build (#615) diff --git a/packages/patrol_cli/lib/src/common/constants.dart b/packages/patrol_cli/lib/src/common/constants.dart index b7ffec371f..1561308a1c 100644 --- a/packages/patrol_cli/lib/src/common/constants.dart +++ b/packages/patrol_cli/lib/src/common/constants.dart @@ -1,7 +1,7 @@ import 'package:path/path.dart' as path; /// Version of Patrol CLI. Must be kept in sync with pubspec.yaml. -const globalVersion = '0.7.9'; +const globalVersion = '0.7.10'; const patrolPackage = 'patrol'; const patrolCliPackage = 'patrol_cli'; diff --git a/packages/patrol_cli/pubspec.yaml b/packages/patrol_cli/pubspec.yaml index 789b8848cc..08242d36c1 100644 --- a/packages/patrol_cli/pubspec.yaml +++ b/packages/patrol_cli/pubspec.yaml @@ -1,7 +1,7 @@ name: patrol_cli description: > Command-line tool for Patrol, a powerful Flutter-native UI testing framework. -version: 0.7.9 +version: 0.7.10 homepage: https://patrol.leancode.co repository: https://github.com/leancodepl/patrol issue_tracker: https://github.com/leancodepl/patrol/issues From a4799221086cf6def3ef0502752ba0f66a6b4757 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Wed, 23 Nov 2022 15:27:07 +0100 Subject: [PATCH 4/8] Add basic reporting to the test runner (#624) * add basic reporting to `TestRunner` * fix tests * print reports * report canceled tests * replace `int repeats` with `final int repeats` * try to use `expectLater()`, doesnt work * Revert "try to use `expectLater()`, doesnt work" This reverts commit da13e3850279741b908d2e30634f337cd2944141. * use `allRunsPassed` for `allSuccessful` --- .../lib/src/features/drive/drive_command.dart | 38 +++++-- .../lib/src/features/drive/test_runner.dart | 75 ++++++++++++- packages/patrol_cli/pubspec.lock | 7 ++ packages/patrol_cli/pubspec.yaml | 1 + .../test/features/drive/test_runner_test.dart | 101 ++++++++++++++++-- 5 files changed, 205 insertions(+), 17 deletions(-) diff --git a/packages/patrol_cli/lib/src/features/drive/drive_command.dart b/packages/patrol_cli/lib/src/features/drive/drive_command.dart index 99de91cb73..2a901a8d42 100644 --- a/packages/patrol_cli/lib/src/features/drive/drive_command.dart +++ b/packages/patrol_cli/lib/src/features/drive/drive_command.dart @@ -1,3 +1,4 @@ +import 'package:ansi_styles/extension.dart'; import 'package:dispose_scope/dispose_scope.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:mason_logger/mason_logger.dart'; @@ -32,6 +33,8 @@ class DriveCommandConfig with _$DriveCommandConfig { }) = _DriveCommandConfig; } +const _defaultRepeats = 1; + class DriveCommand extends StagedCommand { DriveCommand({ required DeviceFinder deviceFinder, @@ -114,7 +117,7 @@ class DriveCommand extends StagedCommand { 'repeat', abbr: 'n', help: 'Repeat the test n times.', - defaultsTo: '1', + defaultsTo: '$_defaultRepeats', ); } @@ -175,9 +178,9 @@ class DriveCommand extends StagedCommand { throw const FormatException('`wait` argument is not an int'); } - var repeat = 1; + final int repeat; try { - final repeatStr = argResults?['repeat'] as String? ?? '1'; + final repeatStr = argResults?['repeat'] as String? ?? '$_defaultRepeats'; repeat = int.parse(repeatStr); } on FormatException { throw const FormatException('`repeat` argument is not an int'); @@ -222,15 +225,12 @@ class DriveCommand extends StagedCommand { dartDefines: config.dartDefines, ); - var exitCode = 0; - _testRunner ..repeats = config.repeat ..builder = (target, device) async { try { await _flutterTool.build(target, device); } catch (err) { - exitCode = 1; _logger ..err('$err') ..err( @@ -242,8 +242,7 @@ class DriveCommand extends StagedCommand { ..executor = (target, device) async { try { await _flutterTool.drive(target, device); - } on FlutterDriverFailedException catch (err) { - exitCode = 1; + } catch (err) { _logger ..err('$err') ..err( @@ -276,8 +275,29 @@ class DriveCommand extends StagedCommand { } } - await _testRunner.run(); + final results = await _testRunner.run(); + + for (final res in results.targetRunResults) { + if (res.allRunsPassed) { + _logger.write( + '${' PASS '.bgGreen.black.bold} ${res.targetName} on ${res.device.id}\n', + ); + } else if (res.allRunsFailed) { + _logger.write( + '${' FAIL '.bgRed.white.bold} ${res.targetName} on ${res.device.id}\n', + ); + } else if (res.canceled) { + _logger.write( + '${' CANC '.bgGray.white.bold} ${res.targetName} on ${res.device.id}\n', + ); + } else { + _logger.write( + '${' FLAK '.bgYellow.black.bold} ${res.targetName} on ${res.device.id}\n', + ); + } + } + final exitCode = results.allSuccessful ? 0 : 1; return exitCode; } } diff --git a/packages/patrol_cli/lib/src/features/drive/test_runner.dart b/packages/patrol_cli/lib/src/features/drive/test_runner.dart index d131dd5b4e..69c455ce69 100644 --- a/packages/patrol_cli/lib/src/features/drive/test_runner.dart +++ b/packages/patrol_cli/lib/src/features/drive/test_runner.dart @@ -1,8 +1,64 @@ import 'package:dispose_scope/dispose_scope.dart'; +import 'package:equatable/equatable.dart'; +import 'package:path/path.dart' show basename; import 'package:patrol_cli/src/features/drive/device.dart'; typedef _Callback = Future Function(String target, Device device); +class TestRunnerResult with EquatableMixin { + const TestRunnerResult({required this.targetRunResults}); + + final List targetRunResults; + + bool get allSuccessful => targetRunResults.every((e) => e.allRunsPassed); + + @override + List get props => [targetRunResults]; +} + +class TargetRunResult with EquatableMixin { + TargetRunResult({ + required this.target, + required this.device, + required this.runs, + }); + + final String target; + final Device device; + + final List runs; + + String get targetName => basename(target); + + bool get allRunsPassed => runs.every((run) => run == TargetRunStatus.passed); + + bool get allRunsFailed => runs.every( + (run) => + run == TargetRunStatus.failedToBuild || + run == TargetRunStatus.failedToExecute, + ); + + /// True if at least 1 test run was canceled. + bool get canceled => runs.any((run) => run == TargetRunStatus.canceled); + + int get passedRuns { + return runs.where((run) => run == TargetRunStatus.passed).length; + } + + int get runsFailedToBuild { + return runs.where((run) => run == TargetRunStatus.failedToBuild).length; + } + + int get runsFailedToExecute { + return runs.where((run) => run == TargetRunStatus.failedToExecute).length; + } + + @override + List get props => [target, device, runs]; +} + +enum TargetRunStatus { failedToBuild, failedToExecute, passed, canceled } + /// Orchestrates running tests on devices. /// /// It maps running T test targets on D devices, resulting in T * D test runs. @@ -78,7 +134,7 @@ class TestRunner extends Disposable { /// Tests are run sequentially on a single device, but many devices can be /// attached at the same time, and thus many tests can be running at the same /// time. - Future run() async { + Future run() async { if (_running) { throw StateError('tests are already running'); } @@ -101,30 +157,45 @@ class TestRunner extends Disposable { _running = true; + final targetRunResults = []; + final testRunsOnAllDevices = >[]; for (final device in _devices.values) { Future runTestsOnDevice() async { for (final target in _targets) { + final targetRuns = []; + targetRunResults.add( + TargetRunResult(target: target, device: device, runs: targetRuns), + ); + if (_disposed) { + for (var i = 0; i < _repeats; i++) { + targetRuns.add(TargetRunStatus.canceled); + } continue; } try { await builder(target, device); } catch (_) { + targetRuns.add(TargetRunStatus.failedToBuild); continue; } for (var i = 0; i < _repeats; i++) { if (_disposed) { + targetRuns.add(TargetRunStatus.canceled); continue; } try { await executor(target, device); } catch (_) { + targetRuns.add(TargetRunStatus.failedToExecute); continue; } + + targetRuns.add(TargetRunStatus.passed); } } } @@ -135,6 +206,8 @@ class TestRunner extends Disposable { await Future.wait(testRunsOnAllDevices); _running = false; + + return TestRunnerResult(targetRunResults: targetRunResults); } @override diff --git a/packages/patrol_cli/pubspec.lock b/packages/patrol_cli/pubspec.lock index 2aaca1c710..88efd1fc61 100644 --- a/packages/patrol_cli/pubspec.lock +++ b/packages/patrol_cli/pubspec.lock @@ -176,6 +176,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.1" + equatable: + dependency: "direct main" + description: + name: equatable + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" fake_async: dependency: "direct dev" description: diff --git a/packages/patrol_cli/pubspec.yaml b/packages/patrol_cli/pubspec.yaml index 08242d36c1..d34121cb93 100644 --- a/packages/patrol_cli/pubspec.yaml +++ b/packages/patrol_cli/pubspec.yaml @@ -16,6 +16,7 @@ dependencies: args: ^2.3.1 collection: ^1.16.0 dispose_scope: ^2.0.1 + equatable: ^2.0.5 file: ^6.1.4 freezed_annotation: ^2.1.0 http: ^0.13.5 diff --git a/packages/patrol_cli/test/features/drive/test_runner_test.dart b/packages/patrol_cli/test/features/drive/test_runner_test.dart index 32ccd4fd06..3085aa056e 100644 --- a/packages/patrol_cli/test/features/drive/test_runner_test.dart +++ b/packages/patrol_cli/test/features/drive/test_runner_test.dart @@ -117,7 +117,7 @@ void main() { test( 'builds and executes test targets sequentially on single device', - () async { + () { fakeAsync((fakeAsync) { testRunner ..addDevice(androidDevice) @@ -230,7 +230,10 @@ void main() { final expectedLog = []; expect(actualLog, equals([])); - unawaited(testRunner.run()); + late TestRunnerResult result; + unawaited(() async { + result = await testRunner.run(); + }()); fakeAsync.elapse(Duration(seconds: 1)); expectedLog.addAll( @@ -267,10 +270,48 @@ void main() { ['execute C ${androidDevice.id}', 'execute C ${iosDevice.id}'], ); expect(actualLog, expectedLog); + + expect( + result, + TestRunnerResult( + targetRunResults: [ + TargetRunResult( + target: 'A', + device: androidDevice, + runs: [TargetRunStatus.passed], + ), + TargetRunResult( + target: 'A', + device: iosDevice, + runs: [TargetRunStatus.passed], + ), + TargetRunResult( + target: 'B', + device: androidDevice, + runs: [TargetRunStatus.passed], + ), + TargetRunResult( + target: 'B', + device: iosDevice, + runs: [TargetRunStatus.passed], + ), + TargetRunResult( + target: 'C', + device: androidDevice, + runs: [TargetRunStatus.passed], + ), + TargetRunResult( + target: 'C', + device: iosDevice, + runs: [TargetRunStatus.passed], + ), + ], + ), + ); }); }); - test('handles disposal correctly', () async { + test('handles disposal correctly', () { fakeAsync((fakeAsync) { testRunner ..addDevice(androidDevice) @@ -308,7 +349,7 @@ void main() { testRunner.builder = (target, device) async { actualLog.add('start build $target ${device.id}'); if (target == 'B') { - throw Exception('build failed'); + throw Exception('failed to build'); } actualLog.add('end build $target ${device.id}'); }; @@ -317,7 +358,7 @@ void main() { actualLog.add('end execute $target ${device.id}'); }; - await testRunner.run(); + final result = await testRunner.run(); expect(actualLog, [ 'start build A ${androidDevice.id}', 'end build A ${androidDevice.id}', @@ -329,6 +370,29 @@ void main() { 'start execute C ${androidDevice.id}', 'end execute C ${androidDevice.id}', ]); + + expect( + result, + TestRunnerResult( + targetRunResults: [ + TargetRunResult( + target: 'A', + device: androidDevice, + runs: [TargetRunStatus.passed], + ), + TargetRunResult( + target: 'B', + device: androidDevice, + runs: [TargetRunStatus.failedToBuild], + ), + TargetRunResult( + target: 'C', + device: androidDevice, + runs: [TargetRunStatus.passed], + ), + ], + ), + ); }); test( @@ -350,12 +414,12 @@ void main() { testRunner.executor = (target, device) async { actualLog.add('start execute $target ${device.id}'); if (target == 'B') { - throw Exception('build failed'); + throw Exception('failed to execute'); } actualLog.add('end execute $target ${device.id}'); }; - await testRunner.run(); + final result = await testRunner.run(); expect(actualLog, [ 'start build A ${androidDevice.id}', 'end build A ${androidDevice.id}', @@ -369,6 +433,29 @@ void main() { 'start execute C ${androidDevice.id}', 'end execute C ${androidDevice.id}', ]); + + expect( + result, + TestRunnerResult( + targetRunResults: [ + TargetRunResult( + target: 'A', + device: androidDevice, + runs: [TargetRunStatus.passed], + ), + TargetRunResult( + target: 'B', + device: androidDevice, + runs: [TargetRunStatus.failedToExecute], + ), + TargetRunResult( + target: 'C', + device: androidDevice, + runs: [TargetRunStatus.passed], + ), + ], + ), + ); }, ); }); From 5befed68ea6aeb7c96f032be284f9970b9b21ccb Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Wed, 23 Nov 2022 15:28:44 +0100 Subject: [PATCH 5/8] patrol_cli: bump version to 0.7.11 (#634) --- packages/patrol_cli/CHANGELOG.md | 4 ++++ packages/patrol_cli/lib/src/common/constants.dart | 2 +- packages/patrol_cli/pubspec.yaml | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/patrol_cli/CHANGELOG.md b/packages/patrol_cli/CHANGELOG.md index 3452b31b48..ec6490ee2e 100644 --- a/packages/patrol_cli/CHANGELOG.md +++ b/packages/patrol_cli/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.7.11 + +- Print status of test runs after `patrol drive` finishes (#624) + ## 0.7.10 - Print error message when screenshot fails on host side (#625) diff --git a/packages/patrol_cli/lib/src/common/constants.dart b/packages/patrol_cli/lib/src/common/constants.dart index 1561308a1c..3a7b34c0e6 100644 --- a/packages/patrol_cli/lib/src/common/constants.dart +++ b/packages/patrol_cli/lib/src/common/constants.dart @@ -1,7 +1,7 @@ import 'package:path/path.dart' as path; /// Version of Patrol CLI. Must be kept in sync with pubspec.yaml. -const globalVersion = '0.7.10'; +const globalVersion = '0.7.11'; const patrolPackage = 'patrol'; const patrolCliPackage = 'patrol_cli'; diff --git a/packages/patrol_cli/pubspec.yaml b/packages/patrol_cli/pubspec.yaml index d34121cb93..82712e53a8 100644 --- a/packages/patrol_cli/pubspec.yaml +++ b/packages/patrol_cli/pubspec.yaml @@ -1,7 +1,7 @@ name: patrol_cli description: > Command-line tool for Patrol, a powerful Flutter-native UI testing framework. -version: 0.7.10 +version: 0.7.11 homepage: https://patrol.leancode.co repository: https://github.com/leancodepl/patrol issue_tracker: https://github.com/leancodepl/patrol/issues From 15ab2d401f482bf21dc7c9da9dac9d7c511da8ff Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Thu, 24 Nov 2022 16:14:54 +0100 Subject: [PATCH 6/8] only initialize NativeAutomator when `nativeAutomation` is true (#636) --- packages/patrol/lib/src/custom_finders/common.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/patrol/lib/src/custom_finders/common.dart b/packages/patrol/lib/src/custom_finders/common.dart index f4233f6f42..af2511085b 100644 --- a/packages/patrol/lib/src/custom_finders/common.dart +++ b/packages/patrol/lib/src/custom_finders/common.dart @@ -61,12 +61,12 @@ void patrolTest( if (nativeAutomation) { if (binding is PatrolBinding) { hostAutomator = HostAutomator(binding: binding); - } - nativeAutomator = NativeAutomator( - packageName: config.packageName, - bundleId: config.bundleId, - ); + nativeAutomator = NativeAutomator( + packageName: config.packageName, + bundleId: config.bundleId, + ); + } } testWidgets( From 0bb3d699ec80f6580293f516c5a6bc2363a1aac4 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Thu, 24 Nov 2022 16:15:57 +0100 Subject: [PATCH 7/8] patrol: bump version to 0.7.4 (#637) --- packages/patrol/CHANGELOG.md | 4 ++++ packages/patrol/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/patrol/CHANGELOG.md b/packages/patrol/CHANGELOG.md index d70ccf9a7a..7b379d00a8 100644 --- a/packages/patrol/CHANGELOG.md +++ b/packages/patrol/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.7.4 + +- Fix minor bug with custom binding initialization (#636) + ## 0.7.3 - Add `patrolIntegrationDriver`, which extends the default `integrationDriver` diff --git a/packages/patrol/pubspec.yaml b/packages/patrol/pubspec.yaml index a6ba586c55..44a9b8fa86 100644 --- a/packages/patrol/pubspec.yaml +++ b/packages/patrol/pubspec.yaml @@ -2,7 +2,7 @@ name: patrol description: > Simple yet powerful Flutter-native UI testing framework eliminating limitations of flutter_test, integration_test, and flutter_driver. -version: 0.7.3 +version: 0.7.4 homepage: https://patrol.leancode.co repository: https://github.com/leancodepl/patrol issue_tracker: https://github.com/leancodepl/patrol/issues From 31b7b7f4d426e3f2e27ded535e18143e3d3abe5d Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Fri, 25 Nov 2022 12:00:02 +0100 Subject: [PATCH 8/8] Add code coverage (#638) * add coverage directory to .gitignore * setup codecov * patrol: temporarily disable CI for Flutter 3.0.0 and Flutter beta * update codecov.yaml * play with codecov.yaml --- .github/workflows/patrol-prepare.yaml | 11 ++++++--- .github/workflows/patrol_cli-prepare.yaml | 18 +++++++-------- codecov.yaml | 28 +++++++++++++++++++++++ packages/patrol/.gitignore | 2 +- packages/patrol_cli/.gitignore | 1 + 5 files changed, 46 insertions(+), 14 deletions(-) create mode 100644 codecov.yaml diff --git a/.github/workflows/patrol-prepare.yaml b/.github/workflows/patrol-prepare.yaml index 0c9bbc8b41..5d3be42c93 100644 --- a/.github/workflows/patrol-prepare.yaml +++ b/.github/workflows/patrol-prepare.yaml @@ -20,9 +20,9 @@ jobs: fail-fast: false matrix: include: - - version: 3.0.0 - channel: stable - - channel: beta + #- version: 3.0.0 + #- channel: beta defaults: run: @@ -42,7 +42,7 @@ jobs: run: flutter pub get - name: flutter test - run: flutter test + run: flutter test --coverage - name: flutter analyze run: flutter analyze @@ -65,3 +65,8 @@ jobs: - name: flutter test (example app) working-directory: ./packages/patrol/example run: flutter test + + - name: Upload code coverage + uses: codecov/codecov-action@v3 + with: + flags: patrol diff --git a/.github/workflows/patrol_cli-prepare.yaml b/.github/workflows/patrol_cli-prepare.yaml index 72e49ef654..5e9a517b27 100644 --- a/.github/workflows/patrol_cli-prepare.yaml +++ b/.github/workflows/patrol_cli-prepare.yaml @@ -38,20 +38,13 @@ jobs: channel: ${{ matrix.channel }} flutter-version: ${{ matrix.version }} - # - name: Install Java - # uses: actions/setup-java@v3 - # with: - # distribution: "temurin" - # java-version: "11" - - # - name: Setup Android SDK - # uses: android-actions/setup-android@v2 - - name: dart pub get run: dart pub get - name: dart test - run: dart test + run: | + dart test --coverage coverage + dart run coverage:format_coverage --lcov --in coverage --out coverage/lcov.info --report-on lib - name: dart analyze run: dart analyze @@ -77,3 +70,8 @@ jobs: cd example patrol bootstrap --template counter flutter analyze + + - name: Upload code coverage + uses: codecov/codecov-action@v3 + with: + flags: patrol_cli diff --git a/codecov.yaml b/codecov.yaml new file mode 100644 index 0000000000..77f7d040e5 --- /dev/null +++ b/codecov.yaml @@ -0,0 +1,28 @@ +coverage: + status: + project: + default: + target: auto + patrol: + target: auto + flags: + - patrol + patrol_cli: + target: auto + flags: + - patrol_cli + +comment: + layout: "header, flags, files, footer" + behavior: default + require_changes: false + require_base: no + require_head: yes + +flags: + patrol: + paths: ["packages/patrol"] + carryforward: true + patrol_cli: + paths: ["packages/patrol_cli"] + carryforward: true diff --git a/packages/patrol/.gitignore b/packages/patrol/.gitignore index c6d9b08d09..5010eee06a 100644 --- a/packages/patrol/.gitignore +++ b/packages/patrol/.gitignore @@ -10,4 +10,4 @@ build/ pubspec.lock .vscode -coverage +/coverage diff --git a/packages/patrol_cli/.gitignore b/packages/patrol_cli/.gitignore index 06b4e6cf37..c61c006b11 100644 --- a/packages/patrol_cli/.gitignore +++ b/packages/patrol_cli/.gitignore @@ -6,3 +6,4 @@ build/ *.exe +/coverage