mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
[pkg/async_helper] use package:lints/recommended.yaml
Also, commit a small tool to pkg/pkg.dart to classify the analysis options settings used by the various pkg/ packages. Change-Id: I34087ed4d033cd2f679c378bcc9270ae65627ae2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282392 Commit-Queue: Devon Carew <devoncarew@google.com> Reviewed-by: Nate Bosch <nbosch@google.com>
This commit is contained in:
parent
bf1b0ee2ba
commit
aa17e57451
|
@ -1 +1 @@
|
|||
include: package:lints/core.yaml
|
||||
include: package:lints/recommended.yaml
|
||||
|
|
|
@ -30,7 +30,7 @@ bool _initialized = false;
|
|||
int _asyncLevel = 0;
|
||||
|
||||
Exception _buildException(String msg) {
|
||||
return new Exception('Fatal: $msg. This is most likely a bug in your test.');
|
||||
return Exception('Fatal: $msg. This is most likely a bug in your test.');
|
||||
}
|
||||
|
||||
/// Call this method before an asynchronous test is created.
|
||||
|
@ -65,26 +65,22 @@ void asyncEnd() {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this after an asynchronous test has ended successfully. This is a helper
|
||||
* for calling [asyncEnd].
|
||||
*
|
||||
* This method intentionally has a signature that matches [:Future.then:] as a
|
||||
* convenience for calling [asyncEnd] when a [:Future:] completes without error,
|
||||
* like this:
|
||||
*
|
||||
* asyncStart();
|
||||
* Future result = test();
|
||||
* result.then(asyncSuccess);
|
||||
*/
|
||||
/// Call this after an asynchronous test has ended successfully. This is a helper
|
||||
/// for calling [asyncEnd].
|
||||
///
|
||||
/// This method intentionally has a signature that matches [:Future.then:] as a
|
||||
/// convenience for calling [asyncEnd] when a [:Future:] completes without error,
|
||||
/// like this:
|
||||
///
|
||||
/// asyncStart();
|
||||
/// Future result = test();
|
||||
/// result.then(asyncSuccess);
|
||||
void asyncSuccess(_) => asyncEnd();
|
||||
|
||||
/**
|
||||
* Helper method for performing asynchronous tests involving [:Future:].
|
||||
*
|
||||
* [f] must return a [:Future:] for the test computation.
|
||||
*/
|
||||
Future<void> asyncTest(f()) {
|
||||
/// Helper method for performing asynchronous tests involving [:Future:].
|
||||
///
|
||||
/// [f] must return a [:Future:] for the test computation.
|
||||
Future<void> asyncTest(Function() f) {
|
||||
asyncStart();
|
||||
return f().then(asyncSuccess);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ import 'dart:async';
|
|||
import 'package:async_helper/async_helper.dart';
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
void group(String name, body()) {
|
||||
void group(String name, Function() body) {
|
||||
var oldName = _pushName(name);
|
||||
try {
|
||||
body();
|
||||
|
@ -41,7 +41,7 @@ void group(String name, body()) {
|
|||
}
|
||||
}
|
||||
|
||||
void test(String name, body()) {
|
||||
void test(String name, Function() body) {
|
||||
var oldName = _pushName(name);
|
||||
|
||||
asyncStart();
|
||||
|
@ -147,7 +147,7 @@ dynamic expectAsync(Function f, {int count = 1}) {
|
|||
return result;
|
||||
};
|
||||
}
|
||||
throw new UnsupportedError(
|
||||
throw UnsupportedError(
|
||||
"expectAsync only accepts up to five argument functions");
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,7 @@ Matcher lessThanOrEqualTo(num n) => (dynamic v) {
|
|||
Expect.fail("$v is not less than $n");
|
||||
};
|
||||
|
||||
Matcher predicate(bool fn(dynamic value), [String description = ""]) =>
|
||||
Matcher predicate(bool Function(dynamic value) fn, [String description = ""]) =>
|
||||
(dynamic v) {
|
||||
Expect.isTrue(fn(v), description);
|
||||
};
|
||||
|
@ -215,7 +215,8 @@ void isNull(dynamic o) {
|
|||
Expect.isNull(o);
|
||||
}
|
||||
|
||||
void _checkThrow<T extends Object>(dynamic v, void onError(error)) {
|
||||
void _checkThrow<T extends Object>(
|
||||
dynamic v, void Function(dynamic error) onError) {
|
||||
if (v is Future) {
|
||||
asyncStart();
|
||||
v.then((_) {
|
||||
|
@ -288,6 +289,7 @@ abstract class _Matcher {
|
|||
|
||||
// ignore: camel_case_types
|
||||
class isInstanceOf<T> implements _Matcher {
|
||||
@override
|
||||
void call(dynamic o) {
|
||||
Expect.type<T>(o);
|
||||
}
|
||||
|
@ -302,7 +304,7 @@ void throwsStateError(dynamic v) {
|
|||
}
|
||||
|
||||
void fail(String message) {
|
||||
Expect.fail("$message");
|
||||
Expect.fail(message);
|
||||
}
|
||||
|
||||
/// Key for zone value holding current test name.
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
include: package:lints/recommended.yaml
|
||||
|
||||
analyzer:
|
||||
errors:
|
||||
import_internal_library: ignore
|
||||
|
|
36
pkg/pkg.dart
Normal file
36
pkg/pkg.dart
Normal file
|
@ -0,0 +1,36 @@
|
|||
// Copyright (c) 2023, 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.
|
||||
|
||||
/// List the packages in pkg/ as well information about their
|
||||
/// analysis_options.yaml configuration.
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
void main(List<String> args) {
|
||||
const indent = 24;
|
||||
|
||||
var dirs = Directory('pkg').listSync().whereType<Directory>().toList();
|
||||
dirs.sort((a, b) => a.path.compareTo(b.path));
|
||||
|
||||
for (var dir in dirs) {
|
||||
var pubspec = File('${dir.path}/pubspec.yaml');
|
||||
if (!pubspec.existsSync()) continue;
|
||||
|
||||
var options = File('${dir.path}/analysis_options.yaml');
|
||||
var name = dir.path.split('/').last;
|
||||
|
||||
if (options.existsSync()) {
|
||||
var type = '** custom **';
|
||||
var optionsContent = options.readAsStringSync();
|
||||
if (optionsContent.contains('package:lints/core.yaml')) {
|
||||
type = 'core';
|
||||
} else if (optionsContent.contains('package:lints/recommended.yaml')) {
|
||||
type = 'recommended';
|
||||
}
|
||||
print('${name.padRight(indent)}: $type');
|
||||
} else {
|
||||
print('${name.padRight(indent)}: default');
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue