mirror of
https://github.com/dart-lang/sdk
synced 2024-07-20 05:57:16 +00:00
Run dartfmt on remaining unformated pkg packages
BUG= R=efortuna@google.com Review-Url: https://codereview.chromium.org/2743423009 .
This commit is contained in:
parent
4b0afdf5cb
commit
de54e18369
|
@ -41,7 +41,7 @@ Exception _buildException(String msg) {
|
|||
void asyncStart() {
|
||||
if (_initialized && _asyncLevel == 0) {
|
||||
throw _buildException('asyncStart() was called even though we are done '
|
||||
'with testing.');
|
||||
'with testing.');
|
||||
}
|
||||
if (!_initialized) {
|
||||
print('unittest-suite-wait-for-done');
|
||||
|
@ -58,7 +58,7 @@ void asyncEnd() {
|
|||
throw _buildException('asyncEnd() was called before asyncStart().');
|
||||
} else {
|
||||
throw _buildException('asyncEnd() was called more often than '
|
||||
'asyncStart().');
|
||||
'asyncStart().');
|
||||
}
|
||||
}
|
||||
_asyncLevel--;
|
||||
|
|
|
@ -60,14 +60,20 @@ class LookupMap<K, V> {
|
|||
/// instead of a list of key-value pairs.
|
||||
// TODO(sigmund): make entries a map once we fix TypeImpl.== (issue #17207).
|
||||
const LookupMap(List entries, [List<LookupMap<K, V>> nestedMaps = const []])
|
||||
: _key = null, _value = null, _entries = entries, _nestedMaps = nestedMaps;
|
||||
: _key = null,
|
||||
_value = null,
|
||||
_entries = entries,
|
||||
_nestedMaps = nestedMaps;
|
||||
|
||||
/// Creates a lookup map with a single key-value pair.
|
||||
const LookupMap.pair(K key, V value)
|
||||
: _key = key, _value = value, _entries = const [], _nestedMaps = const [];
|
||||
: _key = key,
|
||||
_value = value,
|
||||
_entries = const [],
|
||||
_nestedMaps = const [];
|
||||
|
||||
/// Return the data corresponding to [key].
|
||||
V operator[](K key) {
|
||||
V operator [](K key) {
|
||||
var map = _flatMap[this];
|
||||
if (map == null) {
|
||||
map = {};
|
||||
|
|
|
@ -11,16 +11,22 @@ class Key {
|
|||
const Key(this.id);
|
||||
}
|
||||
|
||||
class A{}
|
||||
class A {}
|
||||
|
||||
const B = const Key(1);
|
||||
class C{}
|
||||
|
||||
class C {}
|
||||
|
||||
main() {
|
||||
test('entries constructor', () {
|
||||
var m = const LookupMap(const [
|
||||
A, "the-text-for-A",
|
||||
B, "the-text-for-B",
|
||||
1.2, "the-text-for-1.2"]);
|
||||
A,
|
||||
"the-text-for-A",
|
||||
B,
|
||||
"the-text-for-B",
|
||||
1.2,
|
||||
"the-text-for-1.2"
|
||||
]);
|
||||
expect(m[A], 'the-text-for-A');
|
||||
expect(m[B], 'the-text-for-B');
|
||||
expect(m[1.2], 'the-text-for-1.2');
|
||||
|
@ -43,7 +49,8 @@ main() {
|
|||
|
||||
test('entry shadows nested maps', () {
|
||||
var m = const LookupMap(const [
|
||||
A, "the-text-for-A2",
|
||||
A,
|
||||
"the-text-for-A2",
|
||||
], const [
|
||||
const LookupMap.pair(A, "the-text-for-A1"),
|
||||
]);
|
||||
|
@ -51,7 +58,7 @@ main() {
|
|||
});
|
||||
|
||||
test('nested maps shadow in order', () {
|
||||
var m = const LookupMap(const [ ], const [
|
||||
var m = const LookupMap(const [], const [
|
||||
const LookupMap.pair(A, "the-text-for-A1"),
|
||||
const LookupMap.pair(B, "the-text-for-B2"),
|
||||
const LookupMap.pair(A, "the-text-for-A2"),
|
||||
|
@ -65,9 +72,12 @@ main() {
|
|||
// sanity.
|
||||
test('reachable lookups are not tree-shaken', () {
|
||||
var m = const LookupMap(const [
|
||||
A, B,
|
||||
B, C,
|
||||
C, 3.4,
|
||||
A,
|
||||
B,
|
||||
B,
|
||||
C,
|
||||
C,
|
||||
3.4,
|
||||
]);
|
||||
expect(m[m[m[A]]], 3.4);
|
||||
});
|
||||
|
|
|
@ -4,26 +4,17 @@
|
|||
|
||||
library testing.analyze;
|
||||
|
||||
import 'dart:async' show
|
||||
Stream,
|
||||
Future;
|
||||
import 'dart:async' show Stream, Future;
|
||||
|
||||
import 'dart:convert' show
|
||||
LineSplitter,
|
||||
UTF8;
|
||||
import 'dart:convert' show LineSplitter, UTF8;
|
||||
|
||||
import 'dart:io' show
|
||||
File,
|
||||
Process;
|
||||
import 'dart:io' show File, Process;
|
||||
|
||||
import '../testing.dart' show
|
||||
dartSdk;
|
||||
import '../testing.dart' show dartSdk;
|
||||
|
||||
import 'log.dart' show
|
||||
isVerbose;
|
||||
import 'log.dart' show isVerbose;
|
||||
|
||||
import 'suite.dart' show
|
||||
Suite;
|
||||
import 'suite.dart' show Suite;
|
||||
|
||||
class Analyze extends Suite {
|
||||
final Uri analysisOptions;
|
||||
|
@ -85,9 +76,14 @@ class AnalyzerDiagnostic {
|
|||
if (parts.length != 8) {
|
||||
throw "Malformed output: $line";
|
||||
}
|
||||
return new AnalyzerDiagnostic(parts[0], parts[1], parts[2],
|
||||
return new AnalyzerDiagnostic(
|
||||
parts[0],
|
||||
parts[1],
|
||||
parts[2],
|
||||
Uri.base.resolve(parts[3]),
|
||||
int.parse(parts[4]), int.parse(parts[5]), int.parse(parts[6]),
|
||||
int.parse(parts[4]),
|
||||
int.parse(parts[5]),
|
||||
int.parse(parts[6]),
|
||||
parts[7]);
|
||||
}
|
||||
|
||||
|
@ -108,8 +104,7 @@ Stream<AnalyzerDiagnostic> parseAnalyzerOutput(
|
|||
}
|
||||
|
||||
/// Run dartanalyzer on all tests in [uris].
|
||||
Future<Null> analyzeUris(
|
||||
Uri analysisOptions, Uri packages, List<Uri> uris,
|
||||
Future<Null> analyzeUris(Uri analysisOptions, Uri packages, List<Uri> uris,
|
||||
List<RegExp> exclude) async {
|
||||
if (uris.isEmpty) return;
|
||||
const String analyzerPath = "bin/dartanalyzer";
|
||||
|
@ -118,9 +113,9 @@ Future<Null> analyzeUris(
|
|||
throw "Couldn't find '$analyzerPath' in '${dartSdk.toFilePath()}'";
|
||||
}
|
||||
List<String> arguments = <String>[
|
||||
"--packages=${packages.toFilePath()}",
|
||||
"--package-warnings",
|
||||
"--format=machine",
|
||||
"--packages=${packages.toFilePath()}",
|
||||
"--package-warnings",
|
||||
"--format=machine",
|
||||
];
|
||||
if (analysisOptions != null) {
|
||||
arguments.add("--options=${analysisOptions.toFilePath()}");
|
||||
|
@ -157,4 +152,3 @@ Future<Null> analyzeUris(
|
|||
sw.stop();
|
||||
print("Running analyzer took: ${sw.elapsed}.");
|
||||
}
|
||||
|
||||
|
|
|
@ -4,52 +4,36 @@
|
|||
|
||||
library testing.chain;
|
||||
|
||||
import 'dart:async' show
|
||||
Future,
|
||||
Stream;
|
||||
import 'dart:async' show Future, Stream;
|
||||
|
||||
import 'dart:convert' show
|
||||
JSON,
|
||||
JsonEncoder;
|
||||
import 'dart:convert' show JSON, JsonEncoder;
|
||||
|
||||
import 'dart:io' show
|
||||
Directory,
|
||||
File,
|
||||
FileSystemEntity,
|
||||
exitCode;
|
||||
import 'dart:io' show Directory, File, FileSystemEntity, exitCode;
|
||||
|
||||
import 'suite.dart' show
|
||||
Suite;
|
||||
import 'suite.dart' show Suite;
|
||||
|
||||
import '../testing.dart' show
|
||||
TestDescription;
|
||||
import '../testing.dart' show TestDescription;
|
||||
|
||||
import 'test_dart/status_file_parser.dart' show
|
||||
ReadTestExpectations,
|
||||
TestExpectations;
|
||||
import 'test_dart/status_file_parser.dart'
|
||||
show ReadTestExpectations, TestExpectations;
|
||||
|
||||
import 'zone_helper.dart' show
|
||||
runGuarded;
|
||||
import 'zone_helper.dart' show runGuarded;
|
||||
|
||||
import 'error_handling.dart' show
|
||||
withErrorHandling;
|
||||
import 'error_handling.dart' show withErrorHandling;
|
||||
|
||||
import 'log.dart' show
|
||||
logMessage,
|
||||
logStepComplete,
|
||||
logStepStart,
|
||||
logSuiteComplete,
|
||||
logTestComplete,
|
||||
logUnexpectedResult,
|
||||
splitLines;
|
||||
import 'log.dart'
|
||||
show
|
||||
logMessage,
|
||||
logStepComplete,
|
||||
logStepStart,
|
||||
logSuiteComplete,
|
||||
logTestComplete,
|
||||
logUnexpectedResult,
|
||||
splitLines;
|
||||
|
||||
import 'multitest.dart' show
|
||||
MultitestTransformer,
|
||||
isError;
|
||||
import 'multitest.dart' show MultitestTransformer, isError;
|
||||
|
||||
import 'expectation.dart' show
|
||||
Expectation,
|
||||
ExpectationSet;
|
||||
import 'expectation.dart' show Expectation, ExpectationSet;
|
||||
|
||||
typedef Future<ChainContext> CreateContext(
|
||||
Chain suite, Map<String, String> environment);
|
||||
|
@ -74,10 +58,10 @@ class Chain extends Suite {
|
|||
Uri source = base.resolve(json["source"]);
|
||||
Uri uri = base.resolve(json["path"]);
|
||||
Uri statusFile = base.resolve(json["status"]);
|
||||
List<RegExp> pattern = new List<RegExp>.from(
|
||||
json["pattern"].map((String p) => new RegExp(p)));
|
||||
List<RegExp> exclude = new List<RegExp>.from(
|
||||
json["exclude"].map((String p) => new RegExp(p)));
|
||||
List<RegExp> pattern =
|
||||
new List<RegExp>.from(json["pattern"].map((String p) => new RegExp(p)));
|
||||
List<RegExp> exclude =
|
||||
new List<RegExp>.from(json["exclude"].map((String p) => new RegExp(p)));
|
||||
bool processMultitests = json["process-multitests"] ?? false;
|
||||
return new Chain(name, kind, source, uri, statusFile, pattern, exclude,
|
||||
processMultitests);
|
||||
|
@ -235,6 +219,7 @@ abstract class ChainContext {
|
|||
return future;
|
||||
}
|
||||
}
|
||||
|
||||
// The input of the first step is [description].
|
||||
await doStep(description);
|
||||
}
|
||||
|
@ -242,8 +227,8 @@ abstract class ChainContext {
|
|||
logSuiteComplete();
|
||||
if (unexpectedResults.isNotEmpty) {
|
||||
unexpectedResults.forEach((TestDescription description, Result result) {
|
||||
logUnexpectedResult(suite, description, result,
|
||||
unexpectedOutcomes[description]);
|
||||
logUnexpectedResult(
|
||||
suite, description, result, unexpectedOutcomes[description]);
|
||||
});
|
||||
print("${unexpectedResults.length} failed:");
|
||||
unexpectedResults.forEach((TestDescription description, Result result) {
|
||||
|
@ -329,8 +314,7 @@ class Result<O> {
|
|||
|
||||
Result(this.output, this.outcome, this.error, this.trace);
|
||||
|
||||
Result.pass(O output)
|
||||
: this(output, Expectation.Pass, null, null);
|
||||
Result.pass(O output) : this(output, Expectation.Pass, null, null);
|
||||
|
||||
Result.crash(error, StackTrace trace)
|
||||
: this(null, Expectation.Crash, error, trace);
|
||||
|
@ -345,15 +329,13 @@ class Result<O> {
|
|||
}
|
||||
|
||||
Result<O> copyWithOutcome(Expectation outcome) {
|
||||
return new Result<O>(output, outcome, error, trace)
|
||||
..logs.addAll(logs);
|
||||
return new Result<O>(output, outcome, error, trace)..logs.addAll(logs);
|
||||
}
|
||||
}
|
||||
|
||||
/// This is called from generated code.
|
||||
Future<Null> runChain(
|
||||
CreateContext f, Map<String, String> environment, Set<String> selectors,
|
||||
String json) {
|
||||
Future<Null> runChain(CreateContext f, Map<String, String> environment,
|
||||
Set<String> selectors, String json) {
|
||||
return withErrorHandling(() async {
|
||||
Chain suite = new Suite.fromJsonMap(Uri.base, JSON.decode(json));
|
||||
print("Running ${suite.name}");
|
||||
|
|
|
@ -4,20 +4,11 @@
|
|||
|
||||
library testing.discover;
|
||||
|
||||
import 'dart:io' show
|
||||
Directory,
|
||||
FileSystemEntity,
|
||||
Platform,
|
||||
Process;
|
||||
import 'dart:io' show Directory, FileSystemEntity, Platform, Process;
|
||||
|
||||
import 'dart:async' show
|
||||
Future,
|
||||
Stream,
|
||||
StreamController,
|
||||
StreamSubscription;
|
||||
import 'dart:async' show Future, Stream, StreamController, StreamSubscription;
|
||||
|
||||
import '../testing.dart' show
|
||||
TestDescription;
|
||||
import '../testing.dart' show TestDescription;
|
||||
|
||||
final Uri packageConfig = computePackageConfig();
|
||||
|
||||
|
@ -72,8 +63,8 @@ Uri computePackageConfig() {
|
|||
}
|
||||
|
||||
Uri computeDartSdk() {
|
||||
String dartSdkPath = Platform.environment["DART_SDK"]
|
||||
?? const String.fromEnvironment("DART_SDK");
|
||||
String dartSdkPath = Platform.environment["DART_SDK"] ??
|
||||
const String.fromEnvironment("DART_SDK");
|
||||
if (dartSdkPath != null) {
|
||||
return Uri.base.resolveUri(new Uri.file(dartSdkPath));
|
||||
} else {
|
||||
|
@ -81,10 +72,8 @@ Uri computeDartSdk() {
|
|||
}
|
||||
}
|
||||
|
||||
Future<Process> startDart(
|
||||
Uri program,
|
||||
[List<String> arguments,
|
||||
List<String> vmArguments]) {
|
||||
Future<Process> startDart(Uri program,
|
||||
[List<String> arguments, List<String> vmArguments]) {
|
||||
List<String> allArguments = <String>[];
|
||||
allArguments.addAll(vmArguments ?? dartArguments);
|
||||
allArguments.add(program.toFilePath());
|
||||
|
|
|
@ -4,15 +4,11 @@
|
|||
|
||||
library testing.error_handling;
|
||||
|
||||
import 'dart:async' show
|
||||
Future;
|
||||
import 'dart:async' show Future;
|
||||
|
||||
import 'dart:io' show
|
||||
exitCode,
|
||||
stderr;
|
||||
import 'dart:io' show exitCode, stderr;
|
||||
|
||||
import 'dart:isolate' show
|
||||
ReceivePort;
|
||||
import 'dart:isolate' show ReceivePort;
|
||||
|
||||
Future withErrorHandling(Future f()) async {
|
||||
final ReceivePort port = new ReceivePort();
|
||||
|
|
|
@ -38,26 +38,26 @@ class Expectation {
|
|||
}
|
||||
|
||||
class ExpectationSet {
|
||||
static const ExpectationSet Default = const ExpectationSet(
|
||||
const <String, Expectation>{
|
||||
"pass": Expectation.Pass,
|
||||
"crash": Expectation.Crash,
|
||||
"timeout": Expectation.Timeout,
|
||||
"fail": Expectation.Fail,
|
||||
"skip": Expectation.Skip,
|
||||
"missingcompiletimeerror":
|
||||
const Expectation("MissingCompileTimeError", ExpectationGroup.Fail),
|
||||
"missingruntimeerror":
|
||||
const Expectation("MissingRuntimeError", ExpectationGroup.Fail),
|
||||
});
|
||||
static const ExpectationSet Default =
|
||||
const ExpectationSet(const <String, Expectation>{
|
||||
"pass": Expectation.Pass,
|
||||
"crash": Expectation.Crash,
|
||||
"timeout": Expectation.Timeout,
|
||||
"fail": Expectation.Fail,
|
||||
"skip": Expectation.Skip,
|
||||
"missingcompiletimeerror":
|
||||
const Expectation("MissingCompileTimeError", ExpectationGroup.Fail),
|
||||
"missingruntimeerror":
|
||||
const Expectation("MissingRuntimeError", ExpectationGroup.Fail),
|
||||
});
|
||||
|
||||
final Map<String, Expectation> internalMap;
|
||||
|
||||
const ExpectationSet(this.internalMap);
|
||||
|
||||
operator[] (String name) {
|
||||
return internalMap[name.toLowerCase()]
|
||||
?? (throw "No expectation named: '$name'.");
|
||||
operator [](String name) {
|
||||
return internalMap[name.toLowerCase()] ??
|
||||
(throw "No expectation named: '$name'.");
|
||||
}
|
||||
|
||||
factory ExpectationSet.fromJsonList(List data) {
|
||||
|
@ -108,12 +108,18 @@ enum ExpectationGroup {
|
|||
|
||||
ExpectationGroup groupFromString(String name) {
|
||||
switch (name) {
|
||||
case "Crash": return ExpectationGroup.Crash;
|
||||
case "Fail": return ExpectationGroup.Fail;
|
||||
case "Meta": return ExpectationGroup.Meta;
|
||||
case "Pass": return ExpectationGroup.Pass;
|
||||
case "Skip": return ExpectationGroup.Skip;
|
||||
case "Timeout": return ExpectationGroup.Timeout;
|
||||
case "Crash":
|
||||
return ExpectationGroup.Crash;
|
||||
case "Fail":
|
||||
return ExpectationGroup.Fail;
|
||||
case "Meta":
|
||||
return ExpectationGroup.Meta;
|
||||
case "Pass":
|
||||
return ExpectationGroup.Pass;
|
||||
case "Skip":
|
||||
return ExpectationGroup.Skip;
|
||||
case "Timeout":
|
||||
return ExpectationGroup.Timeout;
|
||||
default:
|
||||
throw "Unrecognized group: '$name'.";
|
||||
}
|
||||
|
|
|
@ -4,18 +4,13 @@
|
|||
|
||||
library testing.log;
|
||||
|
||||
import 'chain.dart' show
|
||||
Result,
|
||||
Step;
|
||||
import 'chain.dart' show Result, Step;
|
||||
|
||||
import 'suite.dart' show
|
||||
Suite;
|
||||
import 'suite.dart' show Suite;
|
||||
|
||||
import 'test_description.dart' show
|
||||
TestDescription;
|
||||
import 'test_description.dart' show TestDescription;
|
||||
|
||||
import 'expectation.dart' show
|
||||
Expectation;
|
||||
import 'expectation.dart' show Expectation;
|
||||
|
||||
/// ANSI escape code for moving cursor one line up.
|
||||
/// See [CSI codes](https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_codes).
|
||||
|
@ -35,8 +30,8 @@ void enableVerboseOutput() {
|
|||
_isVerbose = true;
|
||||
}
|
||||
|
||||
void logTestComplete(int completed, int failed, int total,
|
||||
Suite suite, TestDescription description) {
|
||||
void logTestComplete(int completed, int failed, int total, Suite suite,
|
||||
TestDescription description) {
|
||||
String message = formatProgress(completed, failed, total);
|
||||
if (suite != null) {
|
||||
message += ": ${formatTestDescription(suite, description)}";
|
||||
|
@ -44,8 +39,8 @@ void logTestComplete(int completed, int failed, int total,
|
|||
logProgress(message);
|
||||
}
|
||||
|
||||
void logStepStart(int completed, int failed, int total,
|
||||
Suite suite, TestDescription description, Step step) {
|
||||
void logStepStart(int completed, int failed, int total, Suite suite,
|
||||
TestDescription description, Step step) {
|
||||
String message = formatProgress(completed, failed, total);
|
||||
if (suite != null) {
|
||||
message += ": ${formatTestDescription(suite, description)} ${step.name}";
|
||||
|
@ -56,8 +51,8 @@ void logStepStart(int completed, int failed, int total,
|
|||
logProgress(message);
|
||||
}
|
||||
|
||||
void logStepComplete(int completed, int failed, int total,
|
||||
Suite suite, TestDescription description, Step step) {
|
||||
void logStepComplete(int completed, int failed, int total, Suite suite,
|
||||
TestDescription description, Step step) {
|
||||
if (!step.isAsync) return;
|
||||
String message = formatProgress(completed, failed, total);
|
||||
if (suite != null) {
|
||||
|
|
|
@ -4,56 +4,33 @@
|
|||
|
||||
library testing.run;
|
||||
|
||||
import 'dart:async' show
|
||||
Future,
|
||||
Stream;
|
||||
import 'dart:async' show Future, Stream;
|
||||
|
||||
import 'dart:convert' show
|
||||
JSON;
|
||||
import 'dart:convert' show JSON;
|
||||
|
||||
import 'dart:io' show
|
||||
Platform;
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
import 'dart:isolate' show
|
||||
Isolate,
|
||||
ReceivePort;
|
||||
import 'dart:isolate' show Isolate, ReceivePort;
|
||||
|
||||
import 'test_root.dart' show
|
||||
TestRoot;
|
||||
import 'test_root.dart' show TestRoot;
|
||||
|
||||
import 'test_description.dart' show
|
||||
TestDescription;
|
||||
import 'test_description.dart' show TestDescription;
|
||||
|
||||
import 'error_handling.dart' show
|
||||
withErrorHandling;
|
||||
import 'error_handling.dart' show withErrorHandling;
|
||||
|
||||
import 'chain.dart' show
|
||||
CreateContext;
|
||||
import 'chain.dart' show CreateContext;
|
||||
|
||||
import '../testing.dart' show
|
||||
Chain,
|
||||
ChainContext,
|
||||
TestDescription,
|
||||
listTests;
|
||||
import '../testing.dart' show Chain, ChainContext, TestDescription, listTests;
|
||||
|
||||
import 'analyze.dart' show
|
||||
Analyze;
|
||||
import 'analyze.dart' show Analyze;
|
||||
|
||||
import 'log.dart' show
|
||||
isVerbose,
|
||||
logMessage,
|
||||
logNumberedLines,
|
||||
splitLines;
|
||||
import 'log.dart' show isVerbose, logMessage, logNumberedLines, splitLines;
|
||||
|
||||
import 'suite.dart' show
|
||||
Dart,
|
||||
Suite;
|
||||
import 'suite.dart' show Dart, Suite;
|
||||
|
||||
import 'test_dart.dart' show
|
||||
TestDart;
|
||||
import 'test_dart.dart' show TestDart;
|
||||
|
||||
import 'zone_helper.dart' show
|
||||
acknowledgeControlMessages;
|
||||
import 'zone_helper.dart' show acknowledgeControlMessages;
|
||||
|
||||
Future<TestRoot> computeTestRoot(String configurationPath, Uri base) {
|
||||
Uri configuration = configurationPath == null
|
||||
|
@ -70,8 +47,8 @@ Future<TestRoot> computeTestRoot(String configurationPath, Uri base) {
|
|||
/// The optional argument [configurationPath] should be used when
|
||||
/// `testing.json` isn't located in the current working directory and is a path
|
||||
/// relative to `Platform.script`.
|
||||
Future<Null> runMe(
|
||||
List<String> arguments, CreateContext f, [String configurationPath]) {
|
||||
Future<Null> runMe(List<String> arguments, CreateContext f,
|
||||
[String configurationPath]) {
|
||||
return withErrorHandling(() async {
|
||||
TestRoot testRoot =
|
||||
await computeTestRoot(configurationPath, Platform.script);
|
||||
|
@ -112,15 +89,15 @@ Future<Null> runMe(
|
|||
/// The optional argument [configurationPath] should be used when
|
||||
/// `testing.json` isn't located in the current working directory and is a path
|
||||
/// relative to `Uri.base`.
|
||||
Future<Null> run(
|
||||
List<String> arguments, List<String> suiteNames,
|
||||
Future<Null> run(List<String> arguments, List<String> suiteNames,
|
||||
[String configurationPath]) {
|
||||
return withErrorHandling(() async {
|
||||
TestRoot root = await computeTestRoot(configurationPath, Uri.base);
|
||||
List<Suite> suites = root.suites.where(
|
||||
(Suite suite) => suiteNames.contains(suite.name)).toList();
|
||||
SuiteRunner runner = new SuiteRunner(suites, <String, String>{}, null,
|
||||
new Set<String>(), new Set<String>());
|
||||
List<Suite> suites = root.suites
|
||||
.where((Suite suite) => suiteNames.contains(suite.name))
|
||||
.toList();
|
||||
SuiteRunner runner = new SuiteRunner(
|
||||
suites, <String, String>{}, null, new Set<String>(), new Set<String>());
|
||||
String program = await runner.generateDartProgram();
|
||||
await runner.analyze(root.packages);
|
||||
if (program != null) {
|
||||
|
@ -135,8 +112,11 @@ Future<Null> runProgram(String program, Uri packages) async {
|
|||
Uri dataUri = new Uri.dataFromString(program);
|
||||
ReceivePort exitPort = new ReceivePort();
|
||||
Isolate isolate = await Isolate.spawnUri(dataUri, <String>[], null,
|
||||
paused: true, onExit: exitPort.sendPort, errorsAreFatal: false,
|
||||
checked: true, packageConfig: packages);
|
||||
paused: true,
|
||||
onExit: exitPort.sendPort,
|
||||
errorsAreFatal: false,
|
||||
checked: true,
|
||||
packageConfig: packages);
|
||||
List error;
|
||||
var subscription = isolate.errors.listen((data) {
|
||||
error = data;
|
||||
|
@ -247,8 +227,8 @@ Future<Null> main() async {
|
|||
|
||||
Stream<TestDescription> listDescriptions() async* {
|
||||
for (Dart suite in suites.where((Suite suite) => suite is Dart)) {
|
||||
await for (TestDescription description in
|
||||
listTests(<Uri>[suite.uri], pattern: "")) {
|
||||
await for (TestDescription description
|
||||
in listTests(<Uri>[suite.uri], pattern: "")) {
|
||||
testUris.add(await Isolate.resolvePackageUri(description.uri));
|
||||
if (shouldRunSuite(suite)) {
|
||||
String path = description.file.uri.path;
|
||||
|
|
|
@ -4,39 +4,29 @@
|
|||
|
||||
library testing.run_tests;
|
||||
|
||||
import 'dart:async' show
|
||||
Future;
|
||||
import 'dart:async' show Future;
|
||||
|
||||
import 'dart:io' show
|
||||
Directory,
|
||||
File,
|
||||
FileSystemEntity;
|
||||
import 'dart:io' show Directory, File, FileSystemEntity;
|
||||
|
||||
import 'dart:io' as io show
|
||||
exitCode;
|
||||
import 'dart:io' as io show exitCode;
|
||||
|
||||
import 'dart:isolate' show
|
||||
Isolate;
|
||||
import 'dart:isolate' show Isolate;
|
||||
|
||||
import 'error_handling.dart' show
|
||||
withErrorHandling;
|
||||
import 'error_handling.dart' show withErrorHandling;
|
||||
|
||||
import 'test_root.dart' show
|
||||
TestRoot;
|
||||
import 'test_root.dart' show TestRoot;
|
||||
|
||||
import 'zone_helper.dart' show
|
||||
runGuarded;
|
||||
import 'zone_helper.dart' show runGuarded;
|
||||
|
||||
import 'log.dart' show
|
||||
enableVerboseOutput,
|
||||
isVerbose,
|
||||
logMessage,
|
||||
logSuiteComplete,
|
||||
logTestComplete;
|
||||
import 'log.dart'
|
||||
show
|
||||
enableVerboseOutput,
|
||||
isVerbose,
|
||||
logMessage,
|
||||
logSuiteComplete,
|
||||
logTestComplete;
|
||||
|
||||
import 'run.dart' show
|
||||
SuiteRunner,
|
||||
runProgram;
|
||||
import 'run.dart' show SuiteRunner, runProgram;
|
||||
|
||||
class CommandLine {
|
||||
final Set<String> options;
|
||||
|
@ -97,12 +87,11 @@ class CommandLine {
|
|||
if (!await new File(configurationPath).exists()) {
|
||||
Directory test = new Directory("test");
|
||||
if (await test.exists()) {
|
||||
List<FileSystemEntity> candiates =
|
||||
await test.list(recursive: true, followLinks: false)
|
||||
List<FileSystemEntity> candiates = await test
|
||||
.list(recursive: true, followLinks: false)
|
||||
.where((FileSystemEntity entity) {
|
||||
return entity is File &&
|
||||
entity.uri.path.endsWith("/testing.json");
|
||||
}).toList();
|
||||
return entity is File && entity.uri.path.endsWith("/testing.json");
|
||||
}).toList();
|
||||
switch (candiates.length) {
|
||||
case 0:
|
||||
return fail("Couldn't locate: '$configurationPath'.");
|
||||
|
@ -137,8 +126,7 @@ class CommandLine {
|
|||
options = new Set<String>.from(arguments.getRange(0, index - 1));
|
||||
arguments = arguments.sublist(index + 1);
|
||||
} else {
|
||||
options =
|
||||
arguments.where((argument) => argument.startsWith("-")).toSet();
|
||||
options = arguments.where((argument) => argument.startsWith("-")).toSet();
|
||||
arguments =
|
||||
arguments.where((argument) => !argument.startsWith("-")).toList();
|
||||
}
|
||||
|
@ -153,48 +141,48 @@ fail(String message) {
|
|||
}
|
||||
|
||||
main(List<String> arguments) => withErrorHandling(() async {
|
||||
CommandLine cl = CommandLine.parse(arguments);
|
||||
if (cl.verbose) {
|
||||
enableVerboseOutput();
|
||||
}
|
||||
Map<String, String> environment = cl.environment;
|
||||
Uri configuration = await cl.configuration;
|
||||
if (configuration == null) return;
|
||||
if (!isVerbose) {
|
||||
print("Use --verbose to display more details.");
|
||||
}
|
||||
TestRoot root = await TestRoot.fromUri(configuration);
|
||||
SuiteRunner runner = new SuiteRunner(root.suites, environment, cl.selectors,
|
||||
cl.selectedSuites, cl.skip);
|
||||
String program = await runner.generateDartProgram();
|
||||
bool hasAnalyzerSuites = await runner.analyze(root.packages);
|
||||
Stopwatch sw = new Stopwatch()..start();
|
||||
if (program == null) {
|
||||
if (!hasAnalyzerSuites) {
|
||||
fail("No tests configured.");
|
||||
}
|
||||
} else {
|
||||
await runProgram(program, root.packages);
|
||||
}
|
||||
print("Running tests took: ${sw.elapsed}.");
|
||||
});
|
||||
CommandLine cl = CommandLine.parse(arguments);
|
||||
if (cl.verbose) {
|
||||
enableVerboseOutput();
|
||||
}
|
||||
Map<String, String> environment = cl.environment;
|
||||
Uri configuration = await cl.configuration;
|
||||
if (configuration == null) return;
|
||||
if (!isVerbose) {
|
||||
print("Use --verbose to display more details.");
|
||||
}
|
||||
TestRoot root = await TestRoot.fromUri(configuration);
|
||||
SuiteRunner runner = new SuiteRunner(
|
||||
root.suites, environment, cl.selectors, cl.selectedSuites, cl.skip);
|
||||
String program = await runner.generateDartProgram();
|
||||
bool hasAnalyzerSuites = await runner.analyze(root.packages);
|
||||
Stopwatch sw = new Stopwatch()..start();
|
||||
if (program == null) {
|
||||
if (!hasAnalyzerSuites) {
|
||||
fail("No tests configured.");
|
||||
}
|
||||
} else {
|
||||
await runProgram(program, root.packages);
|
||||
}
|
||||
print("Running tests took: ${sw.elapsed}.");
|
||||
});
|
||||
|
||||
Future<Null> runTests(Map<String, Function> tests) =>
|
||||
withErrorHandling(() async {
|
||||
int completed = 0;
|
||||
for (String name in tests.keys) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
try {
|
||||
await runGuarded(() {
|
||||
print("Running test $name");
|
||||
return tests[name]();
|
||||
}, printLineOnStdout: sb.writeln);
|
||||
logMessage(sb);
|
||||
} catch (e) {
|
||||
print(sb);
|
||||
rethrow;
|
||||
}
|
||||
logTestComplete(++completed, 0, tests.length, null, null);
|
||||
}
|
||||
logSuiteComplete();
|
||||
});
|
||||
withErrorHandling(() async {
|
||||
int completed = 0;
|
||||
for (String name in tests.keys) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
try {
|
||||
await runGuarded(() {
|
||||
print("Running test $name");
|
||||
return tests[name]();
|
||||
}, printLineOnStdout: sb.writeln);
|
||||
logMessage(sb);
|
||||
} catch (e) {
|
||||
print(sb);
|
||||
rethrow;
|
||||
}
|
||||
logTestComplete(++completed, 0, tests.length, null, null);
|
||||
}
|
||||
logSuiteComplete();
|
||||
});
|
||||
|
|
|
@ -4,27 +4,15 @@
|
|||
|
||||
library testing.stdio_process;
|
||||
|
||||
import 'dart:async' show
|
||||
EventSink,
|
||||
Future,
|
||||
Stream,
|
||||
StreamTransformer,
|
||||
Timer;
|
||||
import 'dart:async' show EventSink, Future, Stream, StreamTransformer, Timer;
|
||||
|
||||
import 'dart:convert' show
|
||||
UTF8;
|
||||
import 'dart:convert' show UTF8;
|
||||
|
||||
import 'dart:io' show
|
||||
Process,
|
||||
ProcessSignal,
|
||||
Stdout;
|
||||
import 'dart:io' show Process, ProcessSignal, Stdout;
|
||||
|
||||
import 'dart:io' as io show
|
||||
stderr,
|
||||
stdout;
|
||||
import 'dart:io' as io show stderr, stdout;
|
||||
|
||||
import 'chain.dart' show
|
||||
Result;
|
||||
import 'chain.dart' show Result;
|
||||
|
||||
class StdioProcess {
|
||||
final int exitCode;
|
||||
|
@ -44,15 +32,15 @@ class StdioProcess {
|
|||
static StreamTransformer<String, String> transformToStdio(Stdout stdio) {
|
||||
return new StreamTransformer<String, String>.fromHandlers(
|
||||
handleData: (String data, EventSink<String> sink) {
|
||||
sink.add(data);
|
||||
stdio.write(data);
|
||||
});
|
||||
sink.add(data);
|
||||
stdio.write(data);
|
||||
});
|
||||
}
|
||||
|
||||
static Future<StdioProcess> run(
|
||||
String executable, List<String> arguments,
|
||||
{String input, Duration timeout: const Duration(seconds: 60),
|
||||
bool suppressOutput: true}) async {
|
||||
static Future<StdioProcess> run(String executable, List<String> arguments,
|
||||
{String input,
|
||||
Duration timeout: const Duration(seconds: 60),
|
||||
bool suppressOutput: true}) async {
|
||||
Process process = await Process.start(executable, arguments);
|
||||
Timer timer;
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
|
|
@ -4,11 +4,9 @@
|
|||
|
||||
library testing.suite;
|
||||
|
||||
import 'chain.dart' show
|
||||
Chain;
|
||||
import 'chain.dart' show Chain;
|
||||
|
||||
import 'test_dart.dart' show
|
||||
TestDart;
|
||||
import 'test_dart.dart' show TestDart;
|
||||
|
||||
/// Records the properties of a test suite.
|
||||
abstract class Suite {
|
||||
|
@ -79,10 +77,10 @@ class Dart extends Suite {
|
|||
|
||||
factory Dart.fromJsonMap(Uri base, Map json, String name) {
|
||||
Uri uri = base.resolve(json["path"]);
|
||||
List<RegExp> pattern = new List<RegExp>.from(
|
||||
json["pattern"].map((String p) => new RegExp(p)));
|
||||
List<RegExp> exclude = new List<RegExp>.from(
|
||||
json["exclude"].map((String p) => new RegExp(p)));
|
||||
List<RegExp> pattern =
|
||||
new List<RegExp>.from(json["pattern"].map((String p) => new RegExp(p)));
|
||||
List<RegExp> exclude =
|
||||
new List<RegExp>.from(json["exclude"].map((String p) => new RegExp(p)));
|
||||
return new Dart(name, uri, pattern, exclude);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,14 +4,11 @@
|
|||
|
||||
library testing.test_dart;
|
||||
|
||||
import 'dart:convert' show
|
||||
JSON;
|
||||
import 'dart:convert' show JSON;
|
||||
|
||||
import 'dart:io' show
|
||||
Platform;
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
import 'suite.dart' show
|
||||
Suite;
|
||||
import 'suite.dart' show Suite;
|
||||
|
||||
/// A suite that runs test.dart.
|
||||
class TestDart extends Suite {
|
||||
|
@ -22,10 +19,12 @@ class TestDart extends Suite {
|
|||
final List<String> commandLines;
|
||||
|
||||
TestDart(String name, this.common, this.processes, this.commandLines)
|
||||
: super(name, "test_dart",
|
||||
// This suite doesn't know what it's status file is because test.dart
|
||||
// doesn't know.
|
||||
null);
|
||||
: super(
|
||||
name,
|
||||
"test_dart",
|
||||
// This suite doesn't know what it's status file is because
|
||||
// test.dart doesn't know.
|
||||
null);
|
||||
|
||||
factory TestDart.fromJsonMap(Uri base, Map json, String name, String kind) {
|
||||
String common = json["common"] ?? "";
|
||||
|
@ -52,8 +51,9 @@ class TestDart extends Suite {
|
|||
throw "Operating system not supported: ${Platform.operatingSystem}";
|
||||
}
|
||||
List<String> processedArguments = <String>[];
|
||||
processedArguments.add(Uri.base.resolve(
|
||||
"tools/testing/dart/package_testing_support.dart").toFilePath());
|
||||
processedArguments.add(Uri.base
|
||||
.resolve("tools/testing/dart/package_testing_support.dart")
|
||||
.toFilePath());
|
||||
for (String commandLine in commandLines) {
|
||||
String arguments = common;
|
||||
arguments += " $processes";
|
||||
|
|
|
@ -11,9 +11,7 @@ import "dart:io";
|
|||
import "path.dart";
|
||||
import "status_expression.dart";
|
||||
|
||||
import '../expectation.dart' show
|
||||
Expectation,
|
||||
ExpectationSet;
|
||||
import '../expectation.dart' show Expectation, ExpectationSet;
|
||||
|
||||
final RegExp SplitComment = new RegExp("^([^#]*)(#.*)?\$");
|
||||
final RegExp HeaderPattern = new RegExp(r"^\[([^\]]+)\]");
|
||||
|
@ -49,9 +47,8 @@ class Section {
|
|||
}
|
||||
}
|
||||
|
||||
Future<TestExpectations> ReadTestExpectations(
|
||||
List<String> statusFilePaths, Map environment,
|
||||
ExpectationSet expectationSet) {
|
||||
Future<TestExpectations> ReadTestExpectations(List<String> statusFilePaths,
|
||||
Map environment, ExpectationSet expectationSet) {
|
||||
var testExpectations = new TestExpectations(expectationSet);
|
||||
return Future.wait(statusFilePaths.map((String statusFile) {
|
||||
return ReadTestExpectationsInto(testExpectations, statusFile, environment);
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
|
||||
library testing.test_description;
|
||||
|
||||
import 'dart:io' show
|
||||
File,
|
||||
FileSystemEntity;
|
||||
import 'dart:io' show File, FileSystemEntity;
|
||||
|
||||
class TestDescription implements Comparable<TestDescription> {
|
||||
final Uri root;
|
||||
|
@ -44,8 +42,8 @@ class TestDescription implements Comparable<TestDescription> {
|
|||
sink.writeln('.main,');
|
||||
}
|
||||
|
||||
static TestDescription from(
|
||||
Uri root, FileSystemEntity entity, {Pattern pattern}) {
|
||||
static TestDescription from(Uri root, FileSystemEntity entity,
|
||||
{Pattern pattern}) {
|
||||
if (entity is! File) return null;
|
||||
pattern ??= "_test.dart";
|
||||
String path = entity.uri.path;
|
||||
|
|
|
@ -4,24 +4,17 @@
|
|||
|
||||
library testing.test_root;
|
||||
|
||||
import 'dart:async' show
|
||||
Future;
|
||||
import 'dart:async' show Future;
|
||||
|
||||
import 'dart:convert' show
|
||||
JSON;
|
||||
import 'dart:convert' show JSON;
|
||||
|
||||
import 'dart:io' show
|
||||
File;
|
||||
import 'dart:io' show File;
|
||||
|
||||
import '../testing.dart' show
|
||||
Chain;
|
||||
import '../testing.dart' show Chain;
|
||||
|
||||
import 'analyze.dart' show
|
||||
Analyze;
|
||||
import 'analyze.dart' show Analyze;
|
||||
|
||||
import 'suite.dart' show
|
||||
Dart,
|
||||
Suite;
|
||||
import 'suite.dart' show Dart, Suite;
|
||||
|
||||
/// Records properties of a test root. The information is read from a JSON file.
|
||||
///
|
||||
|
@ -63,13 +56,11 @@ class TestRoot {
|
|||
List<RegExp> get excludedFromAnalysis => analyze.exclude;
|
||||
|
||||
Iterable<Dart> get dartSuites {
|
||||
return new List<Dart>.from(
|
||||
suites.where((Suite suite) => suite is Dart));
|
||||
return new List<Dart>.from(suites.where((Suite suite) => suite is Dart));
|
||||
}
|
||||
|
||||
Iterable<Chain> get toolChains {
|
||||
return new List<Chain>.from(
|
||||
suites.where((Suite suite) => suite is Chain));
|
||||
return new List<Chain>.from(suites.where((Suite suite) => suite is Chain));
|
||||
}
|
||||
|
||||
String toString() {
|
||||
|
|
|
@ -5,29 +5,17 @@
|
|||
/// Helper functions for running code in a Zone.
|
||||
library testing.zone_helper;
|
||||
|
||||
import 'dart:async' show
|
||||
Completer,
|
||||
Future,
|
||||
ZoneSpecification,
|
||||
runZoned;
|
||||
import 'dart:async' show Completer, Future, ZoneSpecification, runZoned;
|
||||
|
||||
import 'dart:io' show
|
||||
exit,
|
||||
stderr;
|
||||
import 'dart:io' show exit, stderr;
|
||||
|
||||
import 'dart:isolate' show
|
||||
Capability,
|
||||
Isolate,
|
||||
ReceivePort;
|
||||
import 'dart:isolate' show Capability, Isolate, ReceivePort;
|
||||
|
||||
import 'log.dart' show
|
||||
logUncaughtError;
|
||||
import 'log.dart' show logUncaughtError;
|
||||
|
||||
Future runGuarded(
|
||||
Future f(),
|
||||
Future runGuarded(Future f(),
|
||||
{void printLineOnStdout(line),
|
||||
void handleLateError(error, StackTrace stackTrace)}) {
|
||||
|
||||
void handleLateError(error, StackTrace stackTrace)}) {
|
||||
var printWrapper;
|
||||
if (printLineOnStdout != null) {
|
||||
printWrapper = (_1, _2, _3, String line) {
|
||||
|
@ -50,8 +38,8 @@ Future runGuarded(
|
|||
} catch (_) {
|
||||
// Ignored.
|
||||
}
|
||||
stderr.write("$errorString\n" +
|
||||
(stackTrace == null ? "" : "$stackTrace"));
|
||||
stderr
|
||||
.write("$errorString\n" + (stackTrace == null ? "" : "$stackTrace"));
|
||||
stderr.flush();
|
||||
exit(255);
|
||||
}
|
||||
|
@ -74,10 +62,8 @@ Future runGuarded(
|
|||
Isolate.current.setErrorsFatal(false);
|
||||
Isolate.current.addErrorListener(errorPort.sendPort);
|
||||
return acknowledgeControlMessages(Isolate.current).then((_) {
|
||||
runZoned(
|
||||
() => new Future(f).then(completer.complete),
|
||||
zoneSpecification: specification,
|
||||
onError: handleUncaughtError);
|
||||
runZoned(() => new Future(f).then(completer.complete),
|
||||
zoneSpecification: specification, onError: handleUncaughtError);
|
||||
|
||||
return completer.future.whenComplete(() {
|
||||
errorPort.close();
|
||||
|
|
|
@ -4,26 +4,16 @@
|
|||
|
||||
library testing;
|
||||
|
||||
export 'dart:async' show
|
||||
Future;
|
||||
export 'dart:async' show Future;
|
||||
|
||||
export 'src/discover.dart';
|
||||
|
||||
export 'src/test_description.dart';
|
||||
|
||||
export 'src/chain.dart' show
|
||||
Chain,
|
||||
ChainContext,
|
||||
Result,
|
||||
Step;
|
||||
export 'src/chain.dart' show Chain, ChainContext, Result, Step;
|
||||
|
||||
export 'src/stdio_process.dart' show
|
||||
StdioProcess;
|
||||
export 'src/stdio_process.dart' show StdioProcess;
|
||||
|
||||
export 'src/run.dart' show
|
||||
run,
|
||||
runMe;
|
||||
export 'src/run.dart' show run, runMe;
|
||||
|
||||
export 'src/expectation.dart' show
|
||||
Expectation,
|
||||
ExpectationSet;
|
||||
export 'src/expectation.dart' show Expectation, ExpectationSet;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
library typed_mock;
|
||||
|
||||
|
||||
_InvocationMatcher _lastMatcher;
|
||||
|
||||
/// Enables stubbing methods.
|
||||
|
@ -39,14 +38,12 @@ Behavior when(_ignored) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// Clears all interactions remembered so far.
|
||||
resetInteractions(TypedMock mock) {
|
||||
mock._invocations.clear();
|
||||
mock._verifiedInvocations.clear();
|
||||
}
|
||||
|
||||
|
||||
/// Verifies certain behavior happened a specified number of times.
|
||||
Verifier verify(_ignored) {
|
||||
try {
|
||||
|
@ -60,7 +57,6 @@ Verifier verify(_ignored) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// Verifies that the given mock doesn't have any unverified interaction.
|
||||
void verifyNoMoreInteractions(TypedMock mock) {
|
||||
var notVerified = mock._computeNotVerifiedInvocations();
|
||||
|
@ -73,7 +69,6 @@ void verifyNoMoreInteractions(TypedMock mock) {
|
|||
throw new VerifyError('Unexpected interactions:\n$invocationsString');
|
||||
}
|
||||
|
||||
|
||||
/// Verifies that no interactions happened on the given mock.
|
||||
void verifyZeroInteractions(TypedMock mock) {
|
||||
var invocations = mock._invocations;
|
||||
|
@ -86,7 +81,6 @@ void verifyZeroInteractions(TypedMock mock) {
|
|||
throw new VerifyError('Unexpected interactions:\n$invocationsString');
|
||||
}
|
||||
|
||||
|
||||
/// [VerifyError] is thrown when one of the [verify] checks fails.
|
||||
class VerifyError {
|
||||
final String message;
|
||||
|
@ -94,7 +88,6 @@ class VerifyError {
|
|||
String toString() => 'VerifyError: $message';
|
||||
}
|
||||
|
||||
|
||||
String _getInvocationsString(Iterable<Invocation> invocations) {
|
||||
var buffer = new StringBuffer();
|
||||
invocations.forEach((invocation) {
|
||||
|
@ -109,7 +102,6 @@ String _getInvocationsString(Iterable<Invocation> invocations) {
|
|||
return buffer.toString();
|
||||
}
|
||||
|
||||
|
||||
class _InvocationMatcher {
|
||||
final Symbol _member;
|
||||
final TypedMock _mock;
|
||||
|
@ -145,7 +137,6 @@ class _InvocationMatcher {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class Behavior {
|
||||
final _InvocationMatcher _matcher;
|
||||
|
||||
|
@ -232,7 +223,6 @@ class Behavior {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class Verifier {
|
||||
final TypedMock _mock;
|
||||
final _InvocationMatcher _matcher;
|
||||
|
@ -313,7 +303,6 @@ class Verifier {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// A class to extend mocks from.
|
||||
/// It supports specifying behavior using [when] and validation of interactions
|
||||
/// using [verify].
|
||||
|
@ -368,7 +357,6 @@ class TypedMock {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// [ArgumentMatcher] checks whether the given argument satisfies some
|
||||
/// condition.
|
||||
abstract class ArgumentMatcher {
|
||||
|
@ -378,7 +366,6 @@ abstract class ArgumentMatcher {
|
|||
bool matches(val);
|
||||
}
|
||||
|
||||
|
||||
class _ArgumentMatcher_equals extends ArgumentMatcher {
|
||||
final expected;
|
||||
|
||||
|
@ -390,7 +377,6 @@ class _ArgumentMatcher_equals extends ArgumentMatcher {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class _ArgumentMatcher_anyBool extends ArgumentMatcher {
|
||||
const _ArgumentMatcher_anyBool();
|
||||
|
||||
|
@ -403,7 +389,6 @@ class _ArgumentMatcher_anyBool extends ArgumentMatcher {
|
|||
/// Matches any [bool] value.
|
||||
final anyBool = const _ArgumentMatcher_anyBool() as dynamic;
|
||||
|
||||
|
||||
class _ArgumentMatcher_anyInt extends ArgumentMatcher {
|
||||
const _ArgumentMatcher_anyInt();
|
||||
|
||||
|
@ -416,7 +401,6 @@ class _ArgumentMatcher_anyInt extends ArgumentMatcher {
|
|||
/// Matches any [int] value.
|
||||
final anyInt = const _ArgumentMatcher_anyInt() as dynamic;
|
||||
|
||||
|
||||
class _ArgumentMatcher_anyObject extends ArgumentMatcher {
|
||||
const _ArgumentMatcher_anyObject();
|
||||
|
||||
|
@ -429,7 +413,6 @@ class _ArgumentMatcher_anyObject extends ArgumentMatcher {
|
|||
/// Matches any [Object] (or subclass) value.
|
||||
final anyObject = const _ArgumentMatcher_anyObject() as dynamic;
|
||||
|
||||
|
||||
class _ArgumentMatcher_anyString extends ArgumentMatcher {
|
||||
const _ArgumentMatcher_anyString();
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import 'package:unittest/unittest.dart';
|
|||
|
||||
import 'package:typed_mock/typed_mock.dart';
|
||||
|
||||
|
||||
abstract class TestInterface {
|
||||
int get testProperty;
|
||||
set testProperty(x);
|
||||
|
@ -16,12 +15,10 @@ abstract class TestInterface {
|
|||
int operator [](index);
|
||||
}
|
||||
|
||||
|
||||
class TestInterfaceMock extends TypedMock implements TestInterface {
|
||||
noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
||||
}
|
||||
|
||||
|
||||
main() {
|
||||
// lets make it redable
|
||||
groupSep = ' | ';
|
||||
|
@ -231,11 +228,11 @@ main() {
|
|||
verify(obj.testProperty).times(2);
|
||||
});
|
||||
|
||||
test('OK, void method', () {
|
||||
obj.testMethodVoid(10);
|
||||
obj.testMethodVoid(20);
|
||||
verify(obj.testMethodVoid(anyInt)).times(2);
|
||||
});
|
||||
test('OK, void method', () {
|
||||
obj.testMethodVoid(10);
|
||||
obj.testMethodVoid(20);
|
||||
verify(obj.testMethodVoid(anyInt)).times(2);
|
||||
});
|
||||
|
||||
test('mismatch, getter', () {
|
||||
obj.testProperty;
|
||||
|
|
Loading…
Reference in a new issue