Skip to content

Commit

Permalink
Merge branch 'master' into feature/run_process
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekpacia authored Nov 25, 2022
2 parents cee6922 + 31b7b7f commit 66ea3ee
Show file tree
Hide file tree
Showing 18 changed files with 272 additions and 136 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/patrol-prepare.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
18 changes: 8 additions & 10 deletions .github/workflows/patrol_cli-prepare.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
28 changes: 28 additions & 0 deletions codecov.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion packages/patrol/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ build/
pubspec.lock

.vscode
coverage
/coverage
4 changes: 4 additions & 0 deletions packages/patrol/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
10 changes: 5 additions & 5 deletions packages/patrol/lib/src/custom_finders/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion packages/patrol/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions packages/patrol_cli/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
build/

*.exe
/coverage
9 changes: 9 additions & 0 deletions packages/patrol_cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 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)
- Perform internal refactoring to make testing the CLI easier (#626)

## 0.7.9

- Fix running tests that failed to build (#615)
Expand Down
1 change: 0 additions & 1 deletion packages/patrol_cli/lib/src/command_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import 'package:pub_updater/pub_updater.dart';

Future<int> patrolCommandRunner(List<String> args) async {
final logger = Logger();
await setUpLogger();

final runner = PatrolCommandRunner(logger: logger);
int exitCode;
Expand Down
1 change: 0 additions & 1 deletion packages/patrol_cli/lib/src/common/common.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export 'constants.dart';
export 'extensions/process.dart';
export 'logging.dart';
2 changes: 1 addition & 1 deletion packages/patrol_cli/lib/src/common/constants.dart
Original file line number Diff line number Diff line change
@@ -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.11';

const patrolPackage = 'patrol';
const patrolCliPackage = 'patrol_cli';
Expand Down
95 changes: 0 additions & 95 deletions packages/patrol_cli/lib/src/common/logging.dart

This file was deleted.

38 changes: 29 additions & 9 deletions packages/patrol_cli/lib/src/features/drive/drive_command.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -32,6 +33,8 @@ class DriveCommandConfig with _$DriveCommandConfig {
}) = _DriveCommandConfig;
}

const _defaultRepeats = 1;

class DriveCommand extends StagedCommand<DriveCommandConfig> {
DriveCommand({
required DeviceFinder deviceFinder,
Expand Down Expand Up @@ -114,7 +117,7 @@ class DriveCommand extends StagedCommand<DriveCommandConfig> {
'repeat',
abbr: 'n',
help: 'Repeat the test n times.',
defaultsTo: '1',
defaultsTo: '$_defaultRepeats',
);
}

Expand Down Expand Up @@ -175,9 +178,9 @@ class DriveCommand extends StagedCommand<DriveCommandConfig> {
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');
Expand Down Expand Up @@ -222,15 +225,12 @@ class DriveCommand extends StagedCommand<DriveCommandConfig> {
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(
Expand All @@ -242,8 +242,7 @@ class DriveCommand extends StagedCommand<DriveCommandConfig> {
..executor = (target, device) async {
try {
await _flutterTool.drive(target, device);
} on FlutterDriverFailedException catch (err) {
exitCode = 1;
} catch (err) {
_logger
..err('$err')
..err(
Expand Down Expand Up @@ -276,8 +275,29 @@ class DriveCommand extends StagedCommand<DriveCommandConfig> {
}
}

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;
}
}
Loading

0 comments on commit 66ea3ee

Please sign in to comment.