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

Commit 8d0de01

Browse files
authored
prep to publish 0.2.1 (#40)
prep to publish 0.2.1
1 parent 8e49095 commit 8d0de01

File tree

7 files changed

+28
-26
lines changed

7 files changed

+28
-26
lines changed

.status

Lines changed: 0 additions & 4 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## 0.2.1-dev
1+
## 0.2.1
22

33
- Use package:lints for analysis.
44
- Populate the pubspec `repository` field.

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
# test_reflective_loader
2-
31
[![Build Status](https://github.com/dart-lang/test_reflective_loader/workflows/Dart/badge.svg)](https://github.com/dart-lang/test_reflective_loader/actions)
2+
[![pub package](https://img.shields.io/pub/v/test_reflective_loader.svg)](https://pub.dev/packages/test_reflective_loader)
43

54
Support for discovering tests and test suites using reflection.
65

analysis_options.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
include: package:lints/core.yaml
1+
include: package:lints/recommended.yaml
2+
3+
analyzer:
4+
errors:
5+
slash_for_doc_comments: ignore
26

37
linter:
48
rules:

lib/test_reflective_loader.dart

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,28 @@ import 'package:test/test.dart' as test_package;
1313
* A marker annotation used to annotate test methods which are expected to fail
1414
* when asserts are enabled.
1515
*/
16-
const _AssertFailingTest assertFailingTest = const _AssertFailingTest();
16+
const _AssertFailingTest assertFailingTest = _AssertFailingTest();
1717

1818
/**
1919
* A marker annotation used to annotate test methods which are expected to fail.
2020
*/
21-
const FailingTest failingTest = const FailingTest();
21+
const FailingTest failingTest = FailingTest();
2222

2323
/**
2424
* A marker annotation used to instruct dart2js to keep reflection information
2525
* for the annotated classes.
2626
*/
27-
const _ReflectiveTest reflectiveTest = const _ReflectiveTest();
27+
const _ReflectiveTest reflectiveTest = _ReflectiveTest();
2828

2929
/**
3030
* A marker annotation used to annotate test methods that should be skipped.
3131
*/
32-
const SkippedTest skippedTest = const SkippedTest();
32+
const SkippedTest skippedTest = SkippedTest();
3333

3434
/**
3535
* A marker annotation used to annotate "solo" groups and tests.
3636
*/
37-
const _SoloTest soloTest = const _SoloTest();
37+
const _SoloTest soloTest = _SoloTest();
3838

3939
final List<_Group> _currentGroups = <_Group>[];
4040
int _currentSuiteLevel = 0;
@@ -58,7 +58,7 @@ final bool _isCheckedMode = () {
5858
* create embedded suites. If the current suite is the top-level one, perform
5959
* check for "solo" groups and tests, and run all or only "solo" items.
6060
*/
61-
void defineReflectiveSuite(void define(), {String name = ''}) {
61+
void defineReflectiveSuite(void Function() define, {String name = ''}) {
6262
String groupName = _currentSuiteName;
6363
_currentSuiteLevel++;
6464
try {
@@ -96,15 +96,15 @@ void defineReflectiveTests(Type type) {
9696
if (!classMirror.metadata.any((InstanceMirror annotation) =>
9797
annotation.type.reflectedType == _ReflectiveTest)) {
9898
String name = MirrorSystem.getName(classMirror.qualifiedName);
99-
throw new Exception('Class $name must have annotation "@reflectiveTest" '
99+
throw Exception('Class $name must have annotation "@reflectiveTest" '
100100
'in order to be run by runReflectiveTests.');
101101
}
102102

103103
_Group group;
104104
{
105105
bool isSolo = _hasAnnotationInstance(classMirror, soloTest);
106106
String className = MirrorSystem.getName(classMirror.simpleName);
107-
group = new _Group(isSolo, _combineNames(_currentSuiteName, className));
107+
group = _Group(isSolo, _combineNames(_currentSuiteName, className));
108108
_currentGroups.add(group);
109109
}
110110

@@ -229,16 +229,18 @@ bool _hasSkippedTestAnnotation(MethodMirror method) =>
229229

230230
Future<Object?> _invokeSymbolIfExists(
231231
InstanceMirror instanceMirror, Symbol symbol) {
232-
Object? invocationResult = null;
232+
Object? invocationResult;
233233
InstanceMirror? closure;
234234
try {
235235
closure = instanceMirror.getField(symbol);
236-
} on NoSuchMethodError {}
236+
} on NoSuchMethodError {
237+
// ignore
238+
}
237239

238240
if (closure is ClosureMirror) {
239241
invocationResult = closure.apply([]).reflectee;
240242
}
241-
return new Future.value(invocationResult);
243+
return Future.value(invocationResult);
242244
}
243245

244246
/**
@@ -252,7 +254,8 @@ Future<Object?> _invokeSymbolIfExists(
252254
Future<Object?>? _runFailingTest(ClassMirror classMirror, Symbol symbol) {
253255
bool passed = false;
254256
return runZonedGuarded(() {
255-
return new Future.sync(() => _runTest(classMirror, symbol)).then<void>((_) {
257+
// ignore: void_checks
258+
return Future.sync(() => _runTest(classMirror, symbol)).then<void>((_) {
256259
passed = true;
257260
test_package.fail('Test passed - expected to fail.');
258261
}).catchError((e) {
@@ -272,7 +275,7 @@ Future<Object?>? _runFailingTest(ClassMirror classMirror, Symbol symbol) {
272275
}
273276

274277
Future<Object?> _runTest(ClassMirror classMirror, Symbol symbol) {
275-
InstanceMirror instanceMirror = classMirror.newInstance(new Symbol(''), []);
278+
InstanceMirror instanceMirror = classMirror.newInstance(Symbol(''), []);
276279
return _invokeSymbolIfExists(instanceMirror, #setUp)
277280
.then((_) => instanceMirror.invoke(symbol, []).reflectee)
278281
.whenComplete(() => _invokeSymbolIfExists(instanceMirror, #tearDown));
@@ -341,15 +344,15 @@ class _Group {
341344

342345
void addSkippedTest(String name) {
343346
var fullName = _combineNames(this.name, name);
344-
tests.add(new _Test.skipped(isSolo, fullName));
347+
tests.add(_Test.skipped(isSolo, fullName));
345348
}
346349

347350
void addTest(bool isSolo, String name, MethodMirror memberMirror,
348351
_TestFunction function) {
349352
var fullName = _combineNames(this.name, name);
350353
var timeout =
351354
_getAnnotationInstance(memberMirror, TestTimeout) as TestTimeout?;
352-
tests.add(new _Test(isSolo, fullName, function, timeout?._timeout));
355+
tests.add(_Test(isSolo, fullName, function, timeout?._timeout));
353356
}
354357
}
355358

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: test_reflective_loader
2-
version: 0.2.1-dev
2+
version: 0.2.1
33
description: Support for discovering tests and test suites using reflection.
44
repository: https://github.com/dart-lang/test_reflective_loader
55

@@ -8,4 +8,4 @@ environment:
88

99
dependencies:
1010
lints: ^1.0.0
11-
test: '>=1.16.0 <2.0.0'
11+
test: ^1.16.0

test/test_reflective_loader_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class TestReflectiveLoaderTest {
3333

3434
@failingTest
3535
Future test_fails_throws_async() {
36-
return new Future.error('foo');
36+
return Future.error('foo');
3737
}
3838

3939
@skippedTest

0 commit comments

Comments
 (0)