blob: 5d379fe0aa2a6b6f50c042445ba174a757867845 [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 Future<T> first
* Stops listening to the stream after the first element has been received.
* Internally the method cancels its subscription after the first element. This
* means that single-subscription (non-broadcast) streams are closed and cannot
* be reused after a call to this getter.
* @description Checks that listening to [stdin] is stopped after the [first]
* method call.
* @author iarkh@unipro.ru
*/
import "../../../Utils/expect.dart";
import "dart:io";
run_process() async {
await stdin.first.then((_) async {
try {
stdin.listen((_) {
exit(99);
});
} catch (e) {
exit(0);
}
});
}
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("Testme");
await process.exitCode.then((int code) async {
Expect.equals(0, code);
called++;
});
});
Expect.equals(1, called);
}
main(List<String> args) {
args.length > 0 ? run_process() : run_main();
}