Skip to content

Commit

Permalink
dart 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rspilker committed Jul 20, 2018
1 parent e466b00 commit 21bf951
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 34 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
## 0.3.1

* dart 2.0 support

## 0.3.0

* remove dependency on built_collection

## 0.2.0

* Moved part files to src/api and implementation files to src/impl
* moved part files to src/api and implementation files to src/impl

## 0.1.0

Expand Down
21 changes: 21 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false

linter:
rules:
- avoid_empty_else
- avoid_relative_lib_imports
- avoid_return_types_on_setters
- avoid_types_as_parameter_names
- control_flow_in_finally
- no_duplicate_case_values
- prefer_contains
- prefer_equal_for_default_values
- prefer_is_not_empty
- recursive_getters
- throw_in_finally
- unrelated_type_equality_checks
- use_rethrow_when_possible
- valid_regexps
17 changes: 9 additions & 8 deletions lib/src/api/model.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
// Copyright (c) 2016-2017, TOPdesk. Please see the AUTHORS file for details.
// Copyright (c) 2016-2018, TOPdesk. Please see the AUTHORS file for details.
// All rights reserved. Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

//import 'package:built_collection/built_collection.dart';

const int unfinished = -1;

class Report {
final Iterable<Suite> suites;
final DateTime timestamp;

Report(Iterable<Suite> suites, {this.timestamp}) : this.suites = new List.unmodifiable(suites);
Report(Iterable<Suite> suites, {this.timestamp})
: this.suites = new List.unmodifiable(suites);
}

typedef bool _Filter(Test t);

class Suite {
static final _skips = (Test t) => !t.isHidden && t.isSkipped;
static final _problems = (Test t) => !t.isHidden && t.problems.isNotEmpty;
static final _tests = (Test t) => !t.isHidden;
static final _hidden = (Test t) => t.isHidden;
static final _Filter _skips = (t) => !t.isHidden && t.isSkipped;
static final _Filter _problems = (t) => !t.isHidden && t.problems.isNotEmpty;
static final _Filter _tests = (t) => !t.isHidden;
static final _Filter _hidden = (t) => t.isHidden;

final String path;
final String platform;
Expand Down
45 changes: 24 additions & 21 deletions lib/src/impl/processor1.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2016, TOPdesk. Please see the AUTHORS file for details.
// Copyright (c) 2016-2018, TOPdesk. Please see the AUTHORS file for details.
// All rights reserved. Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

Expand All @@ -10,49 +10,51 @@ class Processor1 implements Processor {
static const resultCodes = const ['success', 'failure', 'error'];

Map<int, _Suite> suites = new SplayTreeMap();
Map<int, _Test> tests = {};
Map<int, _Test> tests = <int, _Test>{};
final DateTime timestamp;

Processor1(this.timestamp) {}

@override
void process(Map<String, dynamic> event) {
String type = event['type'];
var type = event['type'] as String;
switch (type) {
case 'testStart':
var test = event['test'];
var test = event['test'] as Map<String, dynamic>;
var testCase = new _Test()
..startTime = event['time']
..name = test['name']
..skipReason = test['metadata']['skipReason'];
..startTime = event['time'] as int
..name = test['name'] as String
..skipReason = test['metadata']['skipReason'] as String;

tests[test['id']] = testCase;
tests[test['id'] as int] = testCase;
suites[test['suiteID']].tests.add(testCase);
break;

case 'testDone':
if (!resultCodes.contains(event['result']))
throw new ArgumentError("Unknown result in '$event'");

tests[event['testID']]
..endTime = event['time']
..hidden = event['hidden'];
tests[event['testID'] as int]
..endTime = event['time'] as int
..hidden = event['hidden'] as bool;
break;

case 'suite':
var suite = event['suite'];
suites[suite['id']] = new _Suite()
..path = suite['path']
..platform = suite['platform'];
var suite = event['suite'] as Map<String, dynamic>;
suites[suite['id'] as int] = new _Suite()
..path = suite['path'] as String
..platform = suite['platform'] as String;
break;

case 'error':
tests[event['testID']].problems.add(new Problem(
event['error'], event['stackTrace'], event['isFailure']));
event['error'] as String,
event['stackTrace'] as String,
event['isFailure'] as bool));
break;

case 'print':
tests[event['testID']].prints.add(event['message']);
tests[event['testID'] as int].prints.add(event['message'] as String);
break;

case 'done':
Expand All @@ -67,7 +69,8 @@ class Processor1 implements Processor {

@override
Report get report {
return new Report(suites.values.map((t) => t.toTestSuite()), timestamp: timestamp);
return new Report(suites.values.map((t) => t.toTestSuite()),
timestamp: timestamp);
}
}

Expand All @@ -76,8 +79,8 @@ class _Test {
int startTime;
int endTime = unfinished;
String skipReason;
List<Problem> problems = [];
List<String> prints = [];
List<Problem> problems = <Problem>[];
List<String> prints = <String>[];
bool hidden;

Test toTestCase() {
Expand All @@ -90,7 +93,7 @@ class _Test {
class _Suite {
String path;
String platform;
List<_Test> tests = [];
List<_Test> tests = <_Test>[];

Suite toTestSuite() {
return new Suite(path, platform, tests.map((t) => t.toTestCase()));
Expand Down
6 changes: 3 additions & 3 deletions lib/src/impl/startprocessor.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2016, TOPdesk. Please see the AUTHORS file for details.
// Copyright (c) 2016-2018, TOPdesk. Please see the AUTHORS file for details.
// All rights reserved. Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

Expand All @@ -14,11 +14,11 @@ class StartProcessor implements Processor {

@override
void process(Map<String, dynamic> event) {
var type = event['type'];
var type = event['type'] as String;
if (type == null) throw new ArgumentError("No type in '$event'");
if (type == 'start') {
if (_delegate == null) {
_delegate = _createDelegate(event['protocolVersion']);
_delegate = _createDelegate(event['protocolVersion'] as String);
return;
}
throw new StateError('already started');
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ dev_dependencies:
test: any

environment:
sdk: '>=1.19.0 <2.0.0'
sdk: '>=1.19.0 <3.0.0'

0 comments on commit 21bf951

Please sign in to comment.