Update lints, require latest Dart SDK, prepare to release v2.0.3 (dart-lang/test_process#34)
Also add an example and fix the format and behavior of examples
in readme.md
diff --git a/pkgs/test_process/.github/dependabot.yml b/pkgs/test_process/.github/dependabot.yml
index 430a85e..d5262be 100644
--- a/pkgs/test_process/.github/dependabot.yml
+++ b/pkgs/test_process/.github/dependabot.yml
@@ -8,4 +8,4 @@
directory: "/"
schedule:
# Check for updates to GitHub Actions every weekday
- interval: "daily"
+ interval: "monthly"
diff --git a/pkgs/test_process/.github/workflows/test-package.yml b/pkgs/test_process/.github/workflows/test-package.yml
index 771cf1a..717fd92 100644
--- a/pkgs/test_process/.github/workflows/test-package.yml
+++ b/pkgs/test_process/.github/workflows/test-package.yml
@@ -22,8 +22,8 @@
matrix:
sdk: [dev]
steps:
- - uses: actions/checkout@v3
- - uses: dart-lang/setup-dart@v1
+ - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
+ - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d
with:
sdk: ${{ matrix.sdk }}
- id: install
@@ -47,10 +47,10 @@
matrix:
# Add macos-latest and/or windows-latest if relevant for this package.
os: [ubuntu-latest]
- sdk: [2.12.0, dev]
+ sdk: [2.17.0, dev]
steps:
- - uses: actions/checkout@v3
- - uses: dart-lang/setup-dart@v1
+ - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
+ - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d
with:
sdk: ${{ matrix.sdk }}
- id: install
diff --git a/pkgs/test_process/CHANGELOG.md b/pkgs/test_process/CHANGELOG.md
index 2ee2a66..68b88b1 100644
--- a/pkgs/test_process/CHANGELOG.md
+++ b/pkgs/test_process/CHANGELOG.md
@@ -1,53 +1,56 @@
-## 2.0.3-dev
+## 2.0.3
-* Populate the pubspec `repository` field.
+- Populate the pubspec `repository` field.
+- Fixed examples in `readme.md`.
+- Added `example/example.dart`
+- Require Dart >=2.17
## 2.0.2
-* Reverted `meta` constraint to `^1.3.0`.
+- Reverted `meta` constraint to `^1.3.0`.
## 2.0.1
-* Update `meta` constraint to `>=1.3.0 <3.0.0`.
+- Update `meta` constraint to `>=1.3.0 <3.0.0`.
## 2.0.0
-* Migrate to null safety.
+- Migrate to null safety.
## 1.0.6
-* Require Dart >=2.1
+- Require Dart >=2.1
## 1.0.5
-* Don't allow the test to time out as long as the process is emitting output.
+- Don't allow the test to time out as long as the process is emitting output.
## 1.0.4
-* Set max SDK version to `<3.0.0`, and adjust other dependencies.
+- Set max SDK version to `<3.0.0`, and adjust other dependencies.
## 1.0.3
-* Support test `1.x.x`.
+- Support test `1.x.x`.
## 1.0.2
-* Update SDK version to 2.0.0-dev.17.0
+- Update SDK version to 2.0.0-dev.17.0
## 1.0.1
-* Declare support for `async` 2.0.0.
+- Declare support for `async` 2.0.0.
## 1.0.0
-* Added `pid` and `exitCode` getters to `TestProcess`.
+- Added `pid` and `exitCode` getters to `TestProcess`.
## 1.0.0-rc.2
-* Subclassed `TestProcess`es now emit log output based on the superclass's
+- Subclassed `TestProcess`es now emit log output based on the superclass's
standard IO streams rather than the subclass's. This matches the documented
behavior.
## 1.0.0-rc.1
-* Initial release candidate.
+- Initial release candidate.
diff --git a/pkgs/test_process/README.md b/pkgs/test_process/README.md
index 4ff6c90..6fa42d2 100644
--- a/pkgs/test_process/README.md
+++ b/pkgs/test_process/README.md
@@ -30,19 +30,19 @@
import 'package:test_process/test_process.dart';
void main() {
- test("pub get gets dependencies", () async {
+ test('pub get gets dependencies', () async {
// TestProcess.start() works just like Process.start() from dart:io.
- var process = await TestProcess.start("pub", ["get"]);
+ var process = await TestProcess.start('dart', ['pub', 'get']);
// StreamQueue.next returns the next line emitted on standard out.
var firstLine = await process.stdout.next;
- expect(firstLine, equals("Resolving dependencies..."));
+ expect(firstLine, equals('Resolving dependencies...'));
// Each call to StreamQueue.next moves one line further.
String next;
do {
next = await process.stdout.next;
- } while (next != "Got dependencies!");
+ } while (next != 'Got dependencies!');
// Assert that the process exits with code 0.
await process.shouldExit(0);
@@ -61,16 +61,16 @@
import 'package:test_process/test_process.dart';
void main() {
- test("pub get gets dependencies", () async {
- var process = await TestProcess.start("pub", ["get"]);
+ test('pub get gets dependencies', () async {
+ var process = await TestProcess.start('dart', ['pub', 'get']);
// Each stream matcher will consume as many lines as it matches from a
// StreamQueue, and no more, so it's safe to use them in sequence.
- await expectLater(process.stdout, emits("Resolving dependencies..."));
+ await expectLater(process.stdout, emits('Resolving dependencies...'));
// The emitsThrough matcher matches and consumes any number of lines, as
// long as they end with one matching the argument.
- await expectLater(process.stdout, emitsThrough("Got dependencies!"));
+ await expectLater(process.stdout, emitsThrough('Got dependencies!'));
await process.shouldExit(0);
});
diff --git a/pkgs/test_process/analysis_options.yaml b/pkgs/test_process/analysis_options.yaml
index 0711aca..8f13782 100644
--- a/pkgs/test_process/analysis_options.yaml
+++ b/pkgs/test_process/analysis_options.yaml
@@ -1,43 +1,30 @@
-include: package:pedantic/analysis_options.yaml
+include: package:lints/recommended.yaml
+
analyzer:
- strong-mode:
- implicit-casts: false
+ language:
+ strict-casts: true
+ strict-inference: true
+ strict-raw-types: true
+
linter:
rules:
- - avoid_empty_else
- - avoid_init_to_null
- - avoid_null_checks_in_equality_operators
+ - always_declare_return_types
- avoid_unused_constructor_parameters
- - await_only_futures
- - camel_case_types
- cancel_subscriptions
- - constant_identifier_names
- - control_flow_in_finally
- directives_ordering
- - empty_catches
- - empty_constructor_bodies
- - empty_statements
- - hash_and_equals
- - implementation_imports
- - iterable_contains_unrelated_type
- - library_names
- - library_prefixes
- - list_remove_unrelated_type
- - non_constant_identifier_names
- - overridden_fields
+ - lines_longer_than_80_chars
+ - literal_only_boolean_expressions
+ - missing_whitespace_between_adjacent_strings
+ - no_adjacent_strings_in_list
+ - no_runtimeType_toString
+ - omit_local_variable_types
- package_api_docs
- - package_names
- - package_prefixed_library_names
- - prefer_equal_for_default_values
- - prefer_final_fields
- - prefer_generic_function_type_aliases
- - prefer_is_not_empty
- - slash_for_doc_comments
+ - prefer_relative_imports
+ - prefer_single_quotes
- test_types_in_equals
- throw_in_finally
- - type_init_formals
- - unnecessary_brace_in_string_interps
- - unnecessary_const
- - unnecessary_new
- - unrelated_type_equality_checks
- - valid_regexps
+ - type_annotate_public_apis
+ - unawaited_futures
+ - unnecessary_await_in_return
+ - unnecessary_lambdas
+ - use_super_parameters
diff --git a/pkgs/test_process/example/example.dart b/pkgs/test_process/example/example.dart
new file mode 100644
index 0000000..22175f4
--- /dev/null
+++ b/pkgs/test_process/example/example.dart
@@ -0,0 +1,26 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:test/test.dart';
+import 'package:test_process/test_process.dart';
+
+void main() {
+ test('pub get gets dependencies', () async {
+ // TestProcess.start() works just like Process.start() from dart:io.
+ var process = await TestProcess.start('dart', ['pub', 'get']);
+
+ // StreamQueue.next returns the next line emitted on standard out.
+ var firstLine = await process.stdout.next;
+ expect(firstLine, equals('Resolving dependencies...'));
+
+ // Each call to StreamQueue.next moves one line further.
+ String next;
+ do {
+ next = await process.stdout.next;
+ } while (next != 'Got dependencies!');
+
+ // Assert that the process exits with code 0.
+ await process.shouldExit(0);
+ });
+}
diff --git a/pkgs/test_process/lib/test_process.dart b/pkgs/test_process/lib/test_process.dart
index be8efc7..0d4e193 100644
--- a/pkgs/test_process/lib/test_process.dart
+++ b/pkgs/test_process/lib/test_process.dart
@@ -60,7 +60,7 @@
/// Completes to [_process]'s exit code if it's exited, otherwise completes to
/// `null` immediately.
- Future<int?> get _exitCodeOrNull async => await exitCode
+ Future<int?> get _exitCodeOrNull => exitCode
.then<int?>((value) => value)
.timeout(Duration.zero, onTimeout: () => null);
@@ -141,7 +141,7 @@
}
/// A callback that's run when the test completes.
- Future _tearDown() async {
+ Future<void> _tearDown() async {
// If the process is already dead, do nothing.
if (await _exitCodeOrNull != null) return;
@@ -153,7 +153,7 @@
}
/// Formats the contents of [_log] and passes them to [printOnFailure].
- Future _logOutput() async {
+ Future<void> _logOutput() async {
if (_loggedOutput) return;
_loggedOutput = true;
@@ -161,7 +161,7 @@
// Wait a timer tick to ensure that all available lines have been flushed to
// [_log].
- await Future.delayed(Duration.zero);
+ await Future<void>.delayed(Duration.zero);
var buffer = StringBuffer();
buffer.write('Process `$description` ');
@@ -212,7 +212,7 @@
/// future that completes once it's dead.
///
/// If this is called after the process is already dead, it does nothing.
- Future kill() async {
+ Future<void> kill() async {
_process.kill(ProcessSignal.sigkill);
await exitCode;
}
@@ -222,7 +222,7 @@
///
/// If this is called after the process is already dead, it verifies its
/// existing exit code.
- Future shouldExit([expectedExitCode]) async {
+ Future<void> shouldExit([Object? expectedExitCode]) async {
var exitCode = await this.exitCode;
if (expectedExitCode == null) return;
expect(exitCode, expectedExitCode,
diff --git a/pkgs/test_process/pubspec.yaml b/pkgs/test_process/pubspec.yaml
index b9519fd..e4ace98 100644
--- a/pkgs/test_process/pubspec.yaml
+++ b/pkgs/test_process/pubspec.yaml
@@ -1,10 +1,11 @@
name: test_process
-version: 2.0.3-dev
-description: A package for testing subprocesses.
+version: 2.0.3
+description:
+ "Test processes: starting; validating stdout and stderr; checking exit code"
repository: https://github.com/dart-lang/test_process
environment:
- sdk: ">=2.12.0-0 <3.0.0"
+ sdk: ">=2.17.0 <3.0.0"
dependencies:
async: ^2.5.0
@@ -13,5 +14,5 @@
test: ^1.16.0
dev_dependencies:
- pedantic: ^1.10.0
+ lints: ^2.0.0
test_descriptor: ^2.0.0