blob: 0c2f42a97ac9c99e7114714b4b9a644b20573349 [file] [log] [blame]
// Copyright (c) 2018, 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.
/// @assertion String readLineSync({
/// Encoding encoding: systemEncoding,
/// bool retainNewlines: false
/// })
/// Synchronously read a line from stdin.
/// @description Checks that line is read from stdin.
/// @author iarkh@unipro.ru
import "../../../Utils/expect.dart";
import "dart:io";
import "stdin_utils.dart";
run_process() {
stdout.write(stdin.readLineSync());
}
run_main() async {
String executable = Platform.resolvedExecutable;
String eScript = Platform.script.toString();
int called = 0;
await Process.start(
executable, [...Platform.executableArguments, eScript, "test"],
runInShell: true)
.then((Process process) async {
process.stdin.writeln("Hello");
await process.stdout.toList().then((out) {
Expect.listEquals([72, 101, 108, 108, 111], flattenList<int>(out));
called++;
});
});
Expect.equals(1, called);
}
main(List<String> args) {
args.length > 0 ? run_process() : run_main();
}