add tests, travis support, some lints
diff --git a/pkgs/test_reflective_loader/.travis.yml b/pkgs/test_reflective_loader/.travis.yml new file mode 100644 index 0000000..9c3a39f --- /dev/null +++ b/pkgs/test_reflective_loader/.travis.yml
@@ -0,0 +1,2 @@ +language: dart +script: ./tool/travis.sh
diff --git a/pkgs/test_reflective_loader/analysis_options.yaml b/pkgs/test_reflective_loader/analysis_options.yaml index cee7122..5f425e0 100644 --- a/pkgs/test_reflective_loader/analysis_options.yaml +++ b/pkgs/test_reflective_loader/analysis_options.yaml
@@ -2,4 +2,6 @@ strong-mode: true linter: rules: + - always_declare_return_types - directives_ordering + - public_member_api_docs
diff --git a/pkgs/test_reflective_loader/lib/test_reflective_loader.dart b/pkgs/test_reflective_loader/lib/test_reflective_loader.dart index 9ebaf84..fa0d91d 100644 --- a/pkgs/test_reflective_loader/lib/test_reflective_loader.dart +++ b/pkgs/test_reflective_loader/lib/test_reflective_loader.dart
@@ -27,7 +27,7 @@ * A marker annotation used to instruct dart2js to keep reflection information * for the annotated classes. */ -const ReflectiveTest reflectiveTest = const ReflectiveTest(); +const _ReflectiveTest reflectiveTest = const _ReflectiveTest(); /** * A marker annotation used to annotate "solo" groups and tests. @@ -92,7 +92,7 @@ void defineReflectiveTests(Type type) { ClassMirror classMirror = reflectClass(type); if (!classMirror.metadata.any((InstanceMirror annotation) => - annotation.type.reflectedType == ReflectiveTest)) { + annotation.type.reflectedType == _ReflectiveTest)) { String name = MirrorSystem.getName(classMirror.qualifiedName); throw new Exception('Class $name must have annotation "@reflectiveTest" ' 'in order to be run by runReflectiveTests.'); @@ -247,21 +247,21 @@ }); } -_runTest(ClassMirror classMirror, Symbol symbol) { +Future _runTest(ClassMirror classMirror, Symbol symbol) { InstanceMirror instanceMirror = classMirror.newInstance(new Symbol(''), []); return _invokeSymbolIfExists(instanceMirror, #setUp) .then((_) => instanceMirror.invoke(symbol, []).reflectee) .whenComplete(() => _invokeSymbolIfExists(instanceMirror, #tearDown)); } -typedef _TestFunction(); +typedef dynamic _TestFunction(); /** * A marker annotation used to instruct dart2js to keep reflection information * for the annotated classes. */ -class ReflectiveTest { - const ReflectiveTest(); +class _ReflectiveTest { + const _ReflectiveTest(); } /**
diff --git a/pkgs/test_reflective_loader/test/test_reflective_loader_test.dart b/pkgs/test_reflective_loader/test/test_reflective_loader_test.dart new file mode 100644 index 0000000..be070a0 --- /dev/null +++ b/pkgs/test_reflective_loader/test/test_reflective_loader_test.dart
@@ -0,0 +1,40 @@ +// 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. + +import 'dart:async'; + +import 'package:test/test.dart'; +import 'package:test_reflective_loader/test_reflective_loader.dart'; + +// ignore_for_file: always_declare_return_types + +void main() { + defineReflectiveSuite(() { + defineReflectiveTests(TestReflectiveLoaderTest); + }); +} + +@reflectiveTest +class TestReflectiveLoaderTest { + String pathname; + + test_passes() { + expect(true, true); + } + + @failingTest + test_fails() { + expect(false, true); + } + + @failingTest + test_fails_throws_sync() { + throw 'foo'; + } + + @failingTest + test_fails_throws_async() { + return new Future.error('foo'); + } +}
diff --git a/pkgs/test_reflective_loader/tool/travis.sh b/pkgs/test_reflective_loader/tool/travis.sh new file mode 100755 index 0000000..ea0f1c4 --- /dev/null +++ b/pkgs/test_reflective_loader/tool/travis.sh
@@ -0,0 +1,16 @@ +#!/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