From 9b86c9d8c4effbad645bf9f55b901725ba88fee5 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Wed, 18 May 2022 21:17:27 -0700 Subject: [PATCH 1/2] prep to publish 0.2.1 --- .status | 4 ---- CHANGELOG.md | 2 +- README.md | 3 +-- analysis_options.yaml | 6 ++++- lib/test_reflective_loader.dart | 32 ++++++++++++++------------- pubspec.yaml | 4 ++-- test/test_reflective_loader_test.dart | 2 +- 7 files changed, 27 insertions(+), 26 deletions(-) delete mode 100644 .status diff --git a/.status b/.status deleted file mode 100644 index 364ca4b..0000000 --- a/.status +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright (c) 2015, 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. - diff --git a/CHANGELOG.md b/CHANGELOG.md index 0395858..05195a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.2.1-dev +## 0.2.1 - Use package:lints for analysis. - Populate the pubspec `repository` field. diff --git a/README.md b/README.md index b7f5e19..f7d07db 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ -# test_reflective_loader - [![Build Status](https://github.com/dart-lang/test_reflective_loader/workflows/Dart/badge.svg)](https://github.com/dart-lang/test_reflective_loader/actions) +[![pub package](https://img.shields.io/pub/v/test_reflective_loader.svg)](https://pub.dev/packages/test_reflective_loader) Support for discovering tests and test suites using reflection. diff --git a/analysis_options.yaml b/analysis_options.yaml index 31466c3..fc2a9d3 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,4 +1,8 @@ -include: package:lints/core.yaml +include: package:lints/recommended.yaml + +analyzer: + errors: + slash_for_doc_comments: ignore linter: rules: diff --git a/lib/test_reflective_loader.dart b/lib/test_reflective_loader.dart index e03eb7a..77a2447 100644 --- a/lib/test_reflective_loader.dart +++ b/lib/test_reflective_loader.dart @@ -13,28 +13,28 @@ import 'package:test/test.dart' as test_package; * A marker annotation used to annotate test methods which are expected to fail * when asserts are enabled. */ -const _AssertFailingTest assertFailingTest = const _AssertFailingTest(); +const _AssertFailingTest assertFailingTest = _AssertFailingTest(); /** * A marker annotation used to annotate test methods which are expected to fail. */ -const FailingTest failingTest = const FailingTest(); +const FailingTest failingTest = FailingTest(); /** * A marker annotation used to instruct dart2js to keep reflection information * for the annotated classes. */ -const _ReflectiveTest reflectiveTest = const _ReflectiveTest(); +const _ReflectiveTest reflectiveTest = _ReflectiveTest(); /** * A marker annotation used to annotate test methods that should be skipped. */ -const SkippedTest skippedTest = const SkippedTest(); +const SkippedTest skippedTest = SkippedTest(); /** * A marker annotation used to annotate "solo" groups and tests. */ -const _SoloTest soloTest = const _SoloTest(); +const _SoloTest soloTest = _SoloTest(); final List<_Group> _currentGroups = <_Group>[]; int _currentSuiteLevel = 0; @@ -58,7 +58,7 @@ final bool _isCheckedMode = () { * create embedded suites. If the current suite is the top-level one, perform * check for "solo" groups and tests, and run all or only "solo" items. */ -void defineReflectiveSuite(void define(), {String name = ''}) { +void defineReflectiveSuite(void Function() define, {String name = ''}) { String groupName = _currentSuiteName; _currentSuiteLevel++; try { @@ -96,7 +96,7 @@ void defineReflectiveTests(Type type) { if (!classMirror.metadata.any((InstanceMirror annotation) => annotation.type.reflectedType == _ReflectiveTest)) { String name = MirrorSystem.getName(classMirror.qualifiedName); - throw new Exception('Class $name must have annotation "@reflectiveTest" ' + throw Exception('Class $name must have annotation "@reflectiveTest" ' 'in order to be run by runReflectiveTests.'); } @@ -104,7 +104,7 @@ void defineReflectiveTests(Type type) { { bool isSolo = _hasAnnotationInstance(classMirror, soloTest); String className = MirrorSystem.getName(classMirror.simpleName); - group = new _Group(isSolo, _combineNames(_currentSuiteName, className)); + group = _Group(isSolo, _combineNames(_currentSuiteName, className)); _currentGroups.add(group); } @@ -229,16 +229,18 @@ bool _hasSkippedTestAnnotation(MethodMirror method) => Future _invokeSymbolIfExists( InstanceMirror instanceMirror, Symbol symbol) { - Object? invocationResult = null; + Object? invocationResult; InstanceMirror? closure; try { closure = instanceMirror.getField(symbol); - } on NoSuchMethodError {} + } on NoSuchMethodError { + // ignore + } if (closure is ClosureMirror) { invocationResult = closure.apply([]).reflectee; } - return new Future.value(invocationResult); + return Future.value(invocationResult); } /** @@ -252,7 +254,7 @@ Future _invokeSymbolIfExists( Future? _runFailingTest(ClassMirror classMirror, Symbol symbol) { bool passed = false; return runZonedGuarded(() { - return new Future.sync(() => _runTest(classMirror, symbol)).then((_) { + return Future.sync(() => _runTest(classMirror, symbol)).then((_) { passed = true; test_package.fail('Test passed - expected to fail.'); }).catchError((e) { @@ -272,7 +274,7 @@ Future? _runFailingTest(ClassMirror classMirror, Symbol symbol) { } Future _runTest(ClassMirror classMirror, Symbol symbol) { - InstanceMirror instanceMirror = classMirror.newInstance(new Symbol(''), []); + InstanceMirror instanceMirror = classMirror.newInstance(Symbol(''), []); return _invokeSymbolIfExists(instanceMirror, #setUp) .then((_) => instanceMirror.invoke(symbol, []).reflectee) .whenComplete(() => _invokeSymbolIfExists(instanceMirror, #tearDown)); @@ -341,7 +343,7 @@ class _Group { void addSkippedTest(String name) { var fullName = _combineNames(this.name, name); - tests.add(new _Test.skipped(isSolo, fullName)); + tests.add(_Test.skipped(isSolo, fullName)); } void addTest(bool isSolo, String name, MethodMirror memberMirror, @@ -349,7 +351,7 @@ class _Group { var fullName = _combineNames(this.name, name); var timeout = _getAnnotationInstance(memberMirror, TestTimeout) as TestTimeout?; - tests.add(new _Test(isSolo, fullName, function, timeout?._timeout)); + tests.add(_Test(isSolo, fullName, function, timeout?._timeout)); } } diff --git a/pubspec.yaml b/pubspec.yaml index 51cb753..57cf02b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: test_reflective_loader -version: 0.2.1-dev +version: 0.2.1 description: Support for discovering tests and test suites using reflection. repository: https://github.com/dart-lang/test_reflective_loader @@ -8,4 +8,4 @@ environment: dependencies: lints: ^1.0.0 - test: '>=1.16.0 <2.0.0' + test: ^1.16.0 diff --git a/test/test_reflective_loader_test.dart b/test/test_reflective_loader_test.dart index d303a75..ea7911f 100644 --- a/test/test_reflective_loader_test.dart +++ b/test/test_reflective_loader_test.dart @@ -33,7 +33,7 @@ class TestReflectiveLoaderTest { @failingTest Future test_fails_throws_async() { - return new Future.error('foo'); + return Future.error('foo'); } @skippedTest From 7b494000e7d4370e2f64ea78cb7295319ec88f14 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Wed, 18 May 2022 22:28:34 -0700 Subject: [PATCH 2/2] revert a type change --- lib/test_reflective_loader.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/test_reflective_loader.dart b/lib/test_reflective_loader.dart index 77a2447..6237f67 100644 --- a/lib/test_reflective_loader.dart +++ b/lib/test_reflective_loader.dart @@ -254,7 +254,8 @@ Future _invokeSymbolIfExists( Future? _runFailingTest(ClassMirror classMirror, Symbol symbol) { bool passed = false; return runZonedGuarded(() { - return Future.sync(() => _runTest(classMirror, symbol)).then((_) { + // ignore: void_checks + return Future.sync(() => _runTest(classMirror, symbol)).then((_) { passed = true; test_package.fail('Test passed - expected to fail.'); }).catchError((e) {