Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
language: dart
script: ./tool/travis.sh
2 changes: 2 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ analyzer:
strong-mode: true
linter:
rules:
- always_declare_return_types
- directives_ordering
- public_member_api_docs
12 changes: 6 additions & 6 deletions lib/test_reflective_loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const _FailingTest failingTest = const _FailingTest();
* 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.
Expand Down Expand Up @@ -92,7 +92,7 @@ void defineReflectiveSuite(void define(), {String name}) {
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.');
Expand Down Expand Up @@ -247,21 +247,21 @@ Future _runFailingTest(ClassMirror classMirror, Symbol symbol) {
});
}

_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();
}

/**
Expand Down
38 changes: 38 additions & 0 deletions test/test_reflective_loader_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// 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';

void main() {
defineReflectiveSuite(() {
defineReflectiveTests(TestReflectiveLoaderTest);
});
}

@reflectiveTest
class TestReflectiveLoaderTest {
String pathname;

void test_passes() {
expect(true, true);
}

@failingTest
void test_fails() {
expect(false, true);
}

@failingTest
void test_fails_throws_sync() {
throw 'foo';
}

@failingTest
Future test_fails_throws_async() {
return new Future.error('foo');
}
}
16 changes: 16 additions & 0 deletions tool/travis.sh
Original file line number Diff line number Diff line change
@@ -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