Skip to content
This repository was archived by the owner on Jan 3, 2025. It is now read-only.

Commit 068f9f8

Browse files
authored
Update lints, require latest Dart SDK, prepare to release v2.0.3 (#34)
Also add an example and fix the format and behavior of examples in readme.md
1 parent 3e695bc commit 068f9f8

File tree

8 files changed

+89
-72
lines changed

8 files changed

+89
-72
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ updates:
88
directory: "/"
99
schedule:
1010
# Check for updates to GitHub Actions every weekday
11-
interval: "daily"
11+
interval: "monthly"

.github/workflows/test-package.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ jobs:
2222
matrix:
2323
sdk: [dev]
2424
steps:
25-
- uses: actions/checkout@v3
26-
- uses: dart-lang/setup-dart@v1
25+
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
26+
- uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d
2727
with:
2828
sdk: ${{ matrix.sdk }}
2929
- id: install
@@ -47,10 +47,10 @@ jobs:
4747
matrix:
4848
# Add macos-latest and/or windows-latest if relevant for this package.
4949
os: [ubuntu-latest]
50-
sdk: [2.12.0, dev]
50+
sdk: [2.17.0, dev]
5151
steps:
52-
- uses: actions/checkout@v3
53-
- uses: dart-lang/setup-dart@v1
52+
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
53+
- uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d
5454
with:
5555
sdk: ${{ matrix.sdk }}
5656
- id: install

CHANGELOG.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,56 @@
1-
## 2.0.3-dev
1+
## 2.0.3
22

3-
* Populate the pubspec `repository` field.
3+
- Populate the pubspec `repository` field.
4+
- Fixed examples in `readme.md`.
5+
- Added `example/example.dart`
6+
- Require Dart >=2.17
47

58
## 2.0.2
69

7-
* Reverted `meta` constraint to `^1.3.0`.
10+
- Reverted `meta` constraint to `^1.3.0`.
811

912
## 2.0.1
1013

11-
* Update `meta` constraint to `>=1.3.0 <3.0.0`.
14+
- Update `meta` constraint to `>=1.3.0 <3.0.0`.
1215

1316
## 2.0.0
1417

15-
* Migrate to null safety.
18+
- Migrate to null safety.
1619

1720
## 1.0.6
1821

19-
* Require Dart >=2.1
22+
- Require Dart >=2.1
2023

2124
## 1.0.5
2225

23-
* Don't allow the test to time out as long as the process is emitting output.
26+
- Don't allow the test to time out as long as the process is emitting output.
2427

2528
## 1.0.4
2629

27-
* Set max SDK version to `<3.0.0`, and adjust other dependencies.
30+
- Set max SDK version to `<3.0.0`, and adjust other dependencies.
2831

2932
## 1.0.3
3033

31-
* Support test `1.x.x`.
34+
- Support test `1.x.x`.
3235

3336
## 1.0.2
3437

35-
* Update SDK version to 2.0.0-dev.17.0
38+
- Update SDK version to 2.0.0-dev.17.0
3639

3740
## 1.0.1
3841

39-
* Declare support for `async` 2.0.0.
42+
- Declare support for `async` 2.0.0.
4043

4144
## 1.0.0
4245

43-
* Added `pid` and `exitCode` getters to `TestProcess`.
46+
- Added `pid` and `exitCode` getters to `TestProcess`.
4447

4548
## 1.0.0-rc.2
4649

47-
* Subclassed `TestProcess`es now emit log output based on the superclass's
50+
- Subclassed `TestProcess`es now emit log output based on the superclass's
4851
standard IO streams rather than the subclass's. This matches the documented
4952
behavior.
5053

5154
## 1.0.0-rc.1
5255

53-
* Initial release candidate.
56+
- Initial release candidate.

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ import 'package:test/test.dart';
3030
import 'package:test_process/test_process.dart';
3131
3232
void main() {
33-
test("pub get gets dependencies", () async {
33+
test('pub get gets dependencies', () async {
3434
// TestProcess.start() works just like Process.start() from dart:io.
35-
var process = await TestProcess.start("pub", ["get"]);
35+
var process = await TestProcess.start('dart', ['pub', 'get']);
3636
3737
// StreamQueue.next returns the next line emitted on standard out.
3838
var firstLine = await process.stdout.next;
39-
expect(firstLine, equals("Resolving dependencies..."));
39+
expect(firstLine, equals('Resolving dependencies...'));
4040
4141
// Each call to StreamQueue.next moves one line further.
4242
String next;
4343
do {
4444
next = await process.stdout.next;
45-
} while (next != "Got dependencies!");
45+
} while (next != 'Got dependencies!');
4646
4747
// Assert that the process exits with code 0.
4848
await process.shouldExit(0);
@@ -61,16 +61,16 @@ import 'package:test/test.dart';
6161
import 'package:test_process/test_process.dart';
6262
6363
void main() {
64-
test("pub get gets dependencies", () async {
65-
var process = await TestProcess.start("pub", ["get"]);
64+
test('pub get gets dependencies', () async {
65+
var process = await TestProcess.start('dart', ['pub', 'get']);
6666
6767
// Each stream matcher will consume as many lines as it matches from a
6868
// StreamQueue, and no more, so it's safe to use them in sequence.
69-
await expectLater(process.stdout, emits("Resolving dependencies..."));
69+
await expectLater(process.stdout, emits('Resolving dependencies...'));
7070
7171
// The emitsThrough matcher matches and consumes any number of lines, as
7272
// long as they end with one matching the argument.
73-
await expectLater(process.stdout, emitsThrough("Got dependencies!"));
73+
await expectLater(process.stdout, emitsThrough('Got dependencies!'));
7474
7575
await process.shouldExit(0);
7676
});

analysis_options.yaml

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,30 @@
1-
include: package:pedantic/analysis_options.yaml
1+
include: package:lints/recommended.yaml
2+
23
analyzer:
3-
strong-mode:
4-
implicit-casts: false
4+
language:
5+
strict-casts: true
6+
strict-inference: true
7+
strict-raw-types: true
8+
59
linter:
610
rules:
7-
- avoid_empty_else
8-
- avoid_init_to_null
9-
- avoid_null_checks_in_equality_operators
11+
- always_declare_return_types
1012
- avoid_unused_constructor_parameters
11-
- await_only_futures
12-
- camel_case_types
1313
- cancel_subscriptions
14-
- constant_identifier_names
15-
- control_flow_in_finally
1614
- directives_ordering
17-
- empty_catches
18-
- empty_constructor_bodies
19-
- empty_statements
20-
- hash_and_equals
21-
- implementation_imports
22-
- iterable_contains_unrelated_type
23-
- library_names
24-
- library_prefixes
25-
- list_remove_unrelated_type
26-
- non_constant_identifier_names
27-
- overridden_fields
15+
- lines_longer_than_80_chars
16+
- literal_only_boolean_expressions
17+
- missing_whitespace_between_adjacent_strings
18+
- no_adjacent_strings_in_list
19+
- no_runtimeType_toString
20+
- omit_local_variable_types
2821
- package_api_docs
29-
- package_names
30-
- package_prefixed_library_names
31-
- prefer_equal_for_default_values
32-
- prefer_final_fields
33-
- prefer_generic_function_type_aliases
34-
- prefer_is_not_empty
35-
- slash_for_doc_comments
22+
- prefer_relative_imports
23+
- prefer_single_quotes
3624
- test_types_in_equals
3725
- throw_in_finally
38-
- type_init_formals
39-
- unnecessary_brace_in_string_interps
40-
- unnecessary_const
41-
- unnecessary_new
42-
- unrelated_type_equality_checks
43-
- valid_regexps
26+
- type_annotate_public_apis
27+
- unawaited_futures
28+
- unnecessary_await_in_return
29+
- unnecessary_lambdas
30+
- use_super_parameters

example/example.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'package:test/test.dart';
6+
import 'package:test_process/test_process.dart';
7+
8+
void main() {
9+
test('pub get gets dependencies', () async {
10+
// TestProcess.start() works just like Process.start() from dart:io.
11+
var process = await TestProcess.start('dart', ['pub', 'get']);
12+
13+
// StreamQueue.next returns the next line emitted on standard out.
14+
var firstLine = await process.stdout.next;
15+
expect(firstLine, equals('Resolving dependencies...'));
16+
17+
// Each call to StreamQueue.next moves one line further.
18+
String next;
19+
do {
20+
next = await process.stdout.next;
21+
} while (next != 'Got dependencies!');
22+
23+
// Assert that the process exits with code 0.
24+
await process.shouldExit(0);
25+
});
26+
}

lib/test_process.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class TestProcess {
6060

6161
/// Completes to [_process]'s exit code if it's exited, otherwise completes to
6262
/// `null` immediately.
63-
Future<int?> get _exitCodeOrNull async => await exitCode
63+
Future<int?> get _exitCodeOrNull => exitCode
6464
.then<int?>((value) => value)
6565
.timeout(Duration.zero, onTimeout: () => null);
6666

@@ -141,7 +141,7 @@ class TestProcess {
141141
}
142142

143143
/// A callback that's run when the test completes.
144-
Future _tearDown() async {
144+
Future<void> _tearDown() async {
145145
// If the process is already dead, do nothing.
146146
if (await _exitCodeOrNull != null) return;
147147

@@ -153,15 +153,15 @@ class TestProcess {
153153
}
154154

155155
/// Formats the contents of [_log] and passes them to [printOnFailure].
156-
Future _logOutput() async {
156+
Future<void> _logOutput() async {
157157
if (_loggedOutput) return;
158158
_loggedOutput = true;
159159

160160
var exitCodeOrNull = await _exitCodeOrNull;
161161

162162
// Wait a timer tick to ensure that all available lines have been flushed to
163163
// [_log].
164-
await Future.delayed(Duration.zero);
164+
await Future<void>.delayed(Duration.zero);
165165

166166
var buffer = StringBuffer();
167167
buffer.write('Process `$description` ');
@@ -212,7 +212,7 @@ class TestProcess {
212212
/// future that completes once it's dead.
213213
///
214214
/// If this is called after the process is already dead, it does nothing.
215-
Future kill() async {
215+
Future<void> kill() async {
216216
_process.kill(ProcessSignal.sigkill);
217217
await exitCode;
218218
}
@@ -222,7 +222,7 @@ class TestProcess {
222222
///
223223
/// If this is called after the process is already dead, it verifies its
224224
/// existing exit code.
225-
Future shouldExit([expectedExitCode]) async {
225+
Future<void> shouldExit([Object? expectedExitCode]) async {
226226
var exitCode = await this.exitCode;
227227
if (expectedExitCode == null) return;
228228
expect(exitCode, expectedExitCode,

pubspec.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
name: test_process
2-
version: 2.0.3-dev
3-
description: A package for testing subprocesses.
2+
version: 2.0.3
3+
description:
4+
"Test processes: starting; validating stdout and stderr; checking exit code"
45
repository: https://github.com/dart-lang/test_process
56

67
environment:
7-
sdk: ">=2.12.0-0 <3.0.0"
8+
sdk: ">=2.17.0 <3.0.0"
89

910
dependencies:
1011
async: ^2.5.0
@@ -13,5 +14,5 @@ dependencies:
1314
test: ^1.16.0
1415

1516
dev_dependencies:
16-
pedantic: ^1.10.0
17+
lints: ^2.0.0
1718
test_descriptor: ^2.0.0

0 commit comments

Comments
 (0)