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 bb0f5ab..05195a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md
@@ -1,3 +1,8 @@ +## 0.2.1 + +- Use package:lints for analysis. +- Populate the pubspec `repository` field. + ## 0.2.0 - Stable null safety release.
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 180004e..fc2a9d3 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml
@@ -1,4 +1,8 @@ +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 3528a43..6237f67 100644 --- a/lib/test_reflective_loader.dart +++ b/lib/test_reflective_loader.dart
@@ -13,28 +13,28 @@ * 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 @@ * 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 @@ 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,14 +104,14 @@ { 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); } classMirror.instanceMembers .forEach((Symbol symbol, MethodMirror memberMirror) { // we need only methods - if (memberMirror is! MethodMirror || !memberMirror.isRegularMethod) { + if (!memberMirror.isRegularMethod) { return; } // prepare information about the method @@ -229,16 +229,18 @@ Future<Object?> _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,8 @@ Future<Object?>? _runFailingTest(ClassMirror classMirror, Symbol symbol) { bool passed = false; return runZonedGuarded(() { - return new Future.sync(() => _runTest(classMirror, symbol)).then<void>((_) { + // ignore: void_checks + return Future.sync(() => _runTest(classMirror, symbol)).then<void>((_) { passed = true; test_package.fail('Test passed - expected to fail.'); }).catchError((e) { @@ -272,13 +275,13 @@ } Future<Object?> _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)); } -typedef dynamic _TestFunction(); +typedef _TestFunction = dynamic Function(); /** * A marker annotation used to annotate test methods which are expected to fail. @@ -341,7 +344,7 @@ 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 +352,7 @@ 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 1a72733..57cf02b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml
@@ -1,11 +1,11 @@ name: test_reflective_loader -version: 0.2.0 - +version: 0.2.1 description: Support for discovering tests and test suites using reflection. -homepage: https://github.com/dart-lang/test_reflective_loader +repository: https://github.com/dart-lang/test_reflective_loader environment: - sdk: '>=2.12.0-0 <3.0.0' + sdk: '>=2.12.0 <3.0.0' dependencies: - test: '>=1.16.0 <2.0.0' + lints: ^1.0.0 + test: ^1.16.0
diff --git a/test/test_reflective_loader_test.dart b/test/test_reflective_loader_test.dart index 2c69cce..ea7911f 100644 --- a/test/test_reflective_loader_test.dart +++ b/test/test_reflective_loader_test.dart
@@ -2,6 +2,8 @@ // 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. +// ignore_for_file: non_constant_identifier_names + import 'dart:async'; import 'package:test/test.dart'; @@ -31,7 +33,7 @@ @failingTest Future test_fails_throws_async() { - return new Future.error('foo'); + return Future.error('foo'); } @skippedTest
diff --git a/tool/travis.sh b/tool/travis.sh deleted file mode 100755 index ea0f1c4..0000000 --- a/tool/travis.sh +++ /dev/null
@@ -1,16 +0,0 @@ -#!/bin/bash - -# Copyright (c) 2017, 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. - -# Fast fail the script on failures. -set -e - -# Verify that the libraries are error free. -dartanalyzer --fatal-warnings \ - lib/test_reflective_loader.dart \ - test/test_reflective_loader_test.dart - -# Run the tests. -dart test/test_reflective_loader_test.dart