blob: 918af995618041ec3685ac2d06cc46fb423fa390 [file] [log] [blame]
// 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.
// @dart = 2.9
/// @assertion void add(List<int> data)
/// void addError(error, [StackTrace stackTrace])
/// Passes the [error] to the target consumer as an error event.
/// @description Checks that error message and stack trace appears in [stderr] as
/// a result of the [addError] method call.
/// @author iarkh@unipro.ru
import "../../../Utils/expect.dart";
import "dart:io";
run_process(IOSink sink) {
sink.addError("my test error",
new StackTrace.fromString("my test stack trace"));
}
run_main(String mode) async {
String executable = Platform.resolvedExecutable;
String eScript = Platform.script.toString();
int called = 0;
await Process.run(executable, [eScript, mode]).then((ProcessResult results) {
Expect.isTrue(results.stderr.contains("my test error"));
Expect.isTrue(results.stderr.contains("my test stack trace"));
Expect.equals(0, results.stdout.length);
called++;
});
Expect.equals(1, called);
}
main(List<String> args) {
if(args.length > 0)
run_process(args[0] == "err" ? stderr : stdout);
else {
run_main("out");
run_main("err");
}
}