diff --git a/CHANGELOG.md b/CHANGELOG.md index 70f5aa09652..54c23c4f5da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,10 @@ ### Libraries +#### `dart:cli` + +- **Breaking change** [#52121][]: `waitFor` is removed in 3.4. + #### `dart:io` - **Breaking change** [#53863][]: `Stdout` has a new field `lineTerminator`, diff --git a/runtime/bin/BUILD.gn b/runtime/bin/BUILD.gn index ab84362fbde..7755f752478 100644 --- a/runtime/bin/BUILD.gn +++ b/runtime/bin/BUILD.gn @@ -12,7 +12,6 @@ import("../vm/heap/heap_sources.gni") import("../vm/vm_sources.gni") import("builtin_impl_sources.gni") import("builtin_sources.gni") -import("cli_impl_sources.gni") import("cli_sources.gni") import("io_impl_sources.gni") import("io_sources.gni") @@ -357,7 +356,7 @@ template("build_gen_snapshot_dart_io") { defines = [ "DART_IO_SECURE_SOCKET_DISABLED" ] - sources = io_impl_sources + cli_impl_sources + sources = io_impl_sources sources += [ "io_natives.cc", "io_natives.h", @@ -476,7 +475,7 @@ template("dart_io") { } } - sources = io_impl_sources + cli_impl_sources + sources = io_impl_sources sources += [ "builtin_natives.cc", "io_natives.cc", diff --git a/runtime/bin/cli.cc b/runtime/bin/cli.cc deleted file mode 100644 index d56d5229c4b..00000000000 --- a/runtime/bin/cli.cc +++ /dev/null @@ -1,27 +0,0 @@ -// 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. - -#include "bin/builtin.h" -#include "bin/dartutils.h" - -#include "include/dart_api.h" - -namespace dart { -namespace bin { - -void FUNCTION_NAME(CLI_WaitForEvent)(Dart_NativeArguments args) { - int64_t timeout_millis; - Dart_Handle result = Dart_GetNativeIntegerArgument(args, 0, &timeout_millis); - if (Dart_IsError(result)) { - Dart_PropagateError(result); - } - result = Dart_WaitForEvent(timeout_millis); - if (Dart_IsError(result)) { - Dart_PropagateError(result); - } - Dart_SetReturnValue(args, result); -} - -} // namespace bin -} // namespace dart diff --git a/runtime/bin/cli_impl_sources.gni b/runtime/bin/cli_impl_sources.gni deleted file mode 100644 index 86f8fd76978..00000000000 --- a/runtime/bin/cli_impl_sources.gni +++ /dev/null @@ -1,6 +0,0 @@ -# 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. - -# This file contains some C++ sources for the dart:cli library. -cli_impl_sources = [ "cli.cc" ] diff --git a/runtime/bin/dartutils.cc b/runtime/bin/dartutils.cc index 88aeaaca680..4ec82d00e4a 100644 --- a/runtime/bin/dartutils.cc +++ b/runtime/bin/dartutils.cc @@ -553,11 +553,7 @@ Dart_Handle DartUtils::PrepareIsolateLibrary(Dart_Handle isolate_lib) { } Dart_Handle DartUtils::PrepareCLILibrary(Dart_Handle cli_lib) { - Dart_Handle wait_for_event_handle = - Dart_Invoke(cli_lib, NewString("_getWaitForEvent"), 0, nullptr); - RETURN_IF_ERROR(wait_for_event_handle); - return Dart_SetField(cli_lib, NewString("_waitForEventClosure"), - wait_for_event_handle); + return Dart_Null(); } Dart_Handle DartUtils::SetupPackageConfig(const char* packages_config) { diff --git a/runtime/bin/io_natives.cc b/runtime/bin/io_natives.cc index d90a4b4f052..091b61697f6 100644 --- a/runtime/bin/io_natives.cc +++ b/runtime/bin/io_natives.cc @@ -20,7 +20,6 @@ namespace bin { // Some classes, like File and Directory, list their implementations in // builtin_natives.cc instead. #define IO_NATIVE_LIST(V) \ - V(CLI_WaitForEvent, 1) \ V(Crypto_GetRandomBytes, 1) \ V(Directory_Create, 2) \ V(Directory_CreateTemp, 2) \ diff --git a/runtime/include/dart_api.h b/runtime/include/dart_api.h index 8268aafec6b..530139ecc9f 100644 --- a/runtime/include/dart_api.h +++ b/runtime/include/dart_api.h @@ -868,7 +868,7 @@ typedef struct Dart_CodeObserver { * implement registration of kernel blobs for the subsequent Isolate.spawnUri * If no callback is provided, the registration of kernel blobs will throw * an error. - * + * * \param kernel_buffer A buffer which contains a kernel program. Callback * should copy the contents of `kernel_buffer` as * it may be freed immediately after registration. @@ -888,7 +888,7 @@ typedef const char* (*Dart_RegisterKernelBlobCallback)( * unregister kernel blobs. * If no callback is provided, the unregistration of kernel blobs will throw * an error. - * + * * \param kernel_blob_uri URI of the kernel blob to unregister. */ typedef void (*Dart_UnregisterKernelBlobCallback)(const char* kernel_blob_uri); @@ -1679,17 +1679,6 @@ DART_EXPORT Dart_Handle Dart_GetStickyError(void); */ DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_HandleMessage(void); -/** - * Drains the microtask queue, then blocks the calling thread until the current - * isolate receives a message, then handles all messages. - * - * \param timeout_millis When non-zero, the call returns after the indicated - number of milliseconds even if no message was received. - * \return A valid handle if no error occurs, otherwise an error handle. - */ -DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle -Dart_WaitForEvent(int64_t timeout_millis); - /** * Handles any pending messages for the vm service for the current * isolate. diff --git a/runtime/tests/vm/dart/exported_symbols_test.dart b/runtime/tests/vm/dart/exported_symbols_test.dart index fe5a693d5cb..ae227ae263e 100644 --- a/runtime/tests/vm/dart/exported_symbols_test.dart +++ b/runtime/tests/vm/dart/exported_symbols_test.dart @@ -350,7 +350,6 @@ main() { "Dart_TypeToNullableType", "Dart_TypeVoid", "Dart_VersionString", - "Dart_WaitForEvent", "Dart_WriteHeapSnapshot", "Dart_WriteProfileToTimeline", ]; diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc index 3d2e21904b7..771734c17a0 100644 --- a/runtime/vm/dart_api_impl.cc +++ b/runtime/vm/dart_api_impl.cc @@ -2109,68 +2109,6 @@ DART_EXPORT Dart_Handle Dart_HandleMessage() { return Api::Success(); } -DART_EXPORT Dart_Handle Dart_WaitForEvent(int64_t timeout_millis) { - if (!FLAG_enable_deprecated_wait_for) { - return Dart_NewUnhandledExceptionError(Dart_NewStringFromCString( - "Synchronous waiting using dart:cli waitFor " - "and C API Dart_WaitForEvent is deprecated and disabled by default. " - "This feature will be fully removed in Dart 3.4 release. " - "You can currently still enable it by passing " - "--enable_deprecated_wait_for " - "to the Dart VM. " - "See https://dartbug.com/52121.")); - } - - Thread* T = Thread::Current(); - Isolate* I = T->isolate(); - CHECK_API_SCOPE(T); - CHECK_CALLBACK_STATE(T); - API_TIMELINE_BEGIN_END(T); - TransitionNativeToVM transition(T); - if (I->message_notify_callback() != nullptr) { - return Api::NewError("waitForEventSync is not supported by this embedder"); - } - Object& result = - Object::Handle(Z, DartLibraryCalls::EnsureScheduleImmediate()); - if (result.IsError()) { - return Api::NewHandle(T, result.ptr()); - } - - // Drain the microtask queue. Propagate any errors to the entry frame. - result = DartLibraryCalls::DrainMicrotaskQueue(); - if (result.IsError()) { - // Persist the error across unwiding scopes before propagating. - const Error* error; - { - NoSafepointScope no_safepoint; - ErrorPtr raw_error = Error::Cast(result).ptr(); - T->UnwindScopes(T->top_exit_frame_info()); - error = &Error::Handle(T->zone(), raw_error); - } - Exceptions::PropagateToEntry(*error); - UNREACHABLE(); - return Api::NewError("Unreachable"); - } - - // Block to wait for messages and then handle them. Propagate any errors to - // the entry frame. - if (I->message_handler()->PauseAndHandleAllMessages(timeout_millis) != - MessageHandler::kOK) { - // Persist the error across unwiding scopes before propagating. - const Error* error; - { - NoSafepointScope no_safepoint; - ErrorPtr raw_error = T->StealStickyError(); - T->UnwindScopes(T->top_exit_frame_info()); - error = &Error::Handle(T->zone(), raw_error); - } - Exceptions::PropagateToEntry(*error); - UNREACHABLE(); - return Api::NewError("Unreachable"); - } - return Api::Success(); -} - DART_EXPORT bool Dart_HandleServiceMessages() { #if defined(PRODUCT) return true; diff --git a/sdk/lib/_internal/vm/bin/cli_patch.dart b/sdk/lib/_internal/vm/bin/cli_patch.dart deleted file mode 100644 index 40abe7b9c68..00000000000 --- a/sdk/lib/_internal/vm/bin/cli_patch.dart +++ /dev/null @@ -1,9 +0,0 @@ -// 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. - -import "dart:_internal" show patch; - -@patch -@pragma("vm:external-name", "CLI_WaitForEvent") -external void _waitForEvent(int timeoutMillis); diff --git a/sdk/lib/cli/cli.dart b/sdk/lib/cli/cli.dart index f43efeb5951..8c8254f6f9e 100644 --- a/sdk/lib/cli/cli.dart +++ b/sdk/lib/cli/cli.dart @@ -7,7 +7,7 @@ /// ## Deprecation notice /// /// The functionality of this library is incomplete and may be removed in a -/// later version. See [waitFor] for details. +/// later version. /// /// {@category VM} @Deprecated( @@ -16,5 +16,3 @@ library dart.cli; import 'dart:async'; import 'dart:math'; - -part 'wait_for.dart'; diff --git a/sdk/lib/cli/cli_sources.gni b/sdk/lib/cli/cli_sources.gni index e90e1de8d87..6a0844d4a6a 100644 --- a/sdk/lib/cli/cli_sources.gni +++ b/sdk/lib/cli/cli_sources.gni @@ -2,9 +2,4 @@ # 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. -cli_sdk_sources = [ - "cli.dart", - - # The above file needs to be first if additional parts are added to the lib. - "wait_for.dart", -] +cli_sdk_sources = [ "cli.dart" ] diff --git a/sdk/lib/cli/wait_for.dart b/sdk/lib/cli/wait_for.dart deleted file mode 100644 index ab27cd3b22b..00000000000 --- a/sdk/lib/cli/wait_for.dart +++ /dev/null @@ -1,164 +0,0 @@ -// 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. - -part of dart.cli; - -/** - * Synchronously blocks the calling isolate to wait for asynchronous events to - * complete. - * - * If the [timeout] parameter is supplied, [waitForEvent] will return after - * the specified timeout even if no events have occurred. - * - * This call does the following: - * - suspends the current execution stack, - * - runs the microtask queue until it is empty, - * - waits until the message queue is not empty, - * - handles messages on the message queue, plus their associated microtasks, - * until the message queue is empty, - * - resumes the original stack. - * - * This function breaks the usual promise offered by Dart semantics that - * message handlers and microtasks run to completion before the next message - * handler or microtask begins to run. Of particular note is that use of this - * function in a finally block will allow microtasks and message handlers to - * run before all finally blocks for an exception have completed, possibly - * breaking invariants in your program. - * - * This function will synchronously throw the first unhandled exception it - * encounters in running the microtasks and message handlers as though the - * throwing microtask or message handler was the only Dart invocation on the - * stack. That is, unhandled exceptions in a microtask or message handler will - * skip over stacks suspended in a call to [waitForEvent]. - * - * Calls to this function may be nested. Earlier invocations will not - * be able to complete until subsequent ones do. Messages that arrive after - * a subsequent invocation are "consumed" by that invocation, and do not - * unblock an earlier invocation. Please be aware that nesting calls to - * [waitForEvent] can lead to deadlock when subsequent calls block to wait for - * a condition that is only satisfied after an earlier call returns. - * - * Please note that this call is only available in the standalone command-line - * Dart VM. Further, because it suspends the current execution stack until the - * message queue is empty, even when running in the standalone command-line VM - * there exists a risk that the current execution stack will be starved. - */ -external void _waitForEvent(int timeoutMillis); - -@pragma("vm:entry-point") -void Function(int) _getWaitForEvent() => _waitForEvent; - -// This should be set from C++ code by the embedder to wire up waitFor() to the -// native implementation. In the standalone VM this is set to _waitForEvent() -// above. If it is null, calling waitFor() will throw an UnsupportedError. -@pragma("vm:entry-point") -void Function(int)? _waitForEventClosure; - -class _WaitForUtils { - static void waitForEvent({Duration? timeout}) { - final closure = _waitForEventClosure; - if (closure == null) { - throw new UnsupportedError("waitFor is not supported by this embedder"); - } - closure(timeout == null ? 0 : max(1, timeout.inMilliseconds)); - } -} - -/** - * Suspends the stack, runs microtasks, and handles incoming events until - * [future] completes. - * - * ## Deprecation notice - * - * The `waitFor` feature is deprecated, disabled by default and slated for - * removal in Dart 3.4 release. - * - * See https://dartbug.com/52121 - * - * During transitionary period you can still force enable this feature - * by passing --enable-deprecated-wait-for to Dart VM. - * - * ## Call semantics - * - * This call does the following: - * - While [future] is not completed: - * - suspends the current execution stack, - * - runs the microtask queue until it is empty, - * - waits until the message queue is not empty, - * - handles messages on the message queue, plus their associated microtasks, - * until the message queue is empty, - * - resumes the original stack. - * - * This function breaks the usual promise offered by Dart semantics that - * message handlers and microtasks run to completion before the next message - * handler or microtask begins to run. Of particular note is that use of this - * function in a finally block will allow microtasks and message handlers to - * run before all finally blocks for an exception have completed, possibly - * breaking invariants in your program. - * - * Use of this function should be considered a last resort when it is not - * possible to convert a Dart program entirely to an asynchronous style using - * `async` and `await`. - * - * If the [Future] completes normally, its result is returned. If the [Future] - * completes with an error, the error and stack trace are wrapped in an - * [AsyncError] and thrown. If a microtask or message handler run during this - * call results in an unhandled exception, that exception will be propagated - * as though the microtask or message handler was the only Dart invocation on - * the stack. That is, unhandled exceptions in a microtask or message handler - * will skip over stacks suspended in a call to [waitFor]. - * - * If the optional `timeout` parameter is passed, [waitFor] throws a - * [TimeoutException] if the [Future] is not completed within the specified - * period. - * - * Calls to [waitFor] may be nested. Earlier invocations will not complete - * until subsequent ones do, but the completion of a subsequent invocation will - * cause the previous invocation to wake up and check its [Future] for - * completion. - * - * Please be aware that nesting calls to [waitFor] can lead to deadlock if - * subsequent calls block waiting for a condition that is only satisfied when - * an earlier call returns. - */ -@Deprecated("This functionality is deprecated and will be removed in Dart 3.4") -T waitFor(Future future, {Duration? timeout}) { - late T result; - bool futureCompleted = false; - Object? error; - StackTrace? stacktrace; - future.then((T r) { - futureCompleted = true; - result = r; - }, onError: (e, st) { - error = e; - stacktrace = st; - }); - - late Stopwatch s; - if (timeout != null) { - s = new Stopwatch()..start(); - } - Timer.run(() {}); // Ensure there is at least one message. - while (!futureCompleted && (error == null)) { - Duration? remaining; - if (timeout != null) { - if (s.elapsed >= timeout) { - throw new TimeoutException("waitFor() timed out", timeout); - } - remaining = timeout - s.elapsed; - } - _WaitForUtils.waitForEvent(timeout: remaining); - } - if (timeout != null) { - s.stop(); - } - Timer.run(() {}); // Ensure that previous calls to waitFor are woken up. - - if (error != null) { - throw new AsyncError(error!, stacktrace); - } - - return result; -} diff --git a/sdk/lib/libraries.json b/sdk/lib/libraries.json index 6821883d679..1dd3fc33f8c 100644 --- a/sdk/lib/libraries.json +++ b/sdk/lib/libraries.json @@ -124,10 +124,7 @@ ], "libraries": { "cli": { - "uri": "cli/cli.dart", - "patches": [ - "_internal/vm/bin/cli_patch.dart" - ] + "uri": "cli/cli.dart" } } }, diff --git a/sdk/lib/libraries.yaml b/sdk/lib/libraries.yaml index 5e44a20d242..58643bca49b 100644 --- a/sdk/lib/libraries.yaml +++ b/sdk/lib/libraries.yaml @@ -116,8 +116,6 @@ vm: libraries: cli: uri: "cli/cli.dart" - patches: - - "_internal/vm/bin/cli_patch.dart" wasm: include: diff --git a/tests/standalone/io/issue_32052_test.dart b/tests/standalone/io/issue_32052_test.dart deleted file mode 100644 index c9648883e6d..00000000000 --- a/tests/standalone/io/issue_32052_test.dart +++ /dev/null @@ -1,22 +0,0 @@ -// 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. - -// VMOptions=--enable-deprecated-wait-for - -import 'dart:async'; -import 'dart:cli'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -main() { - asyncStart(); - Completer c = new Completer(); - Timer.run(() { - c.complete(null); - asyncEnd(); - }); - Null result = waitFor(c.future); - Expect.isNull(result); -} diff --git a/tests/standalone/io/wait_for_deprecation_test.dart b/tests/standalone/io/wait_for_deprecation_test.dart deleted file mode 100644 index d6511b29944..00000000000 --- a/tests/standalone/io/wait_for_deprecation_test.dart +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2023, 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. - -// This test verifies that attempting to use `waitFor` without enabling it -// causes an exception. - -import 'dart:async'; -import 'dart:cli'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -main() { - asyncStart(); - Expect.throws(() { - waitFor(Future.delayed(Duration(milliseconds: 10)).whenComplete(asyncEnd)); - }, (v) { - return v.contains('deprecated and disabled') && - v.contains('dartbug.com/52121') && - v.contains('enable_deprecated_wait_for'); - }); -} diff --git a/tests/standalone/io/wait_for_error_test.dart b/tests/standalone/io/wait_for_error_test.dart deleted file mode 100644 index 2cd97c4d9af..00000000000 --- a/tests/standalone/io/wait_for_error_test.dart +++ /dev/null @@ -1,21 +0,0 @@ -// 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. - -// VMOptions=--enable-deprecated-wait-for - -import 'dart:async'; -import 'dart:cli'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -main() { - asyncStart(); - Completer c = new Completer(); - Timer.run(() { - c.completeError("Error", StackTrace.current); - asyncEnd(); - }); - Expect.throws(() => waitFor(c.future), (e) => e is AsyncError); -} diff --git a/tests/standalone/io/wait_for_event_helper.dart b/tests/standalone/io/wait_for_event_helper.dart deleted file mode 100644 index b22a1e00db9..00000000000 --- a/tests/standalone/io/wait_for_event_helper.dart +++ /dev/null @@ -1,24 +0,0 @@ -// 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. - -import 'dart:async'; -import 'dart:mirrors'; -import 'dart:cli'; - -late void Function({Duration timeout}) waitForEvent; - -void initWaitForEvent() { - LibraryMirror lib = currentMirrorSystem().findLibrary(#dart.cli); - for (Symbol s in lib.declarations.keys) { - if (s.toString().contains("_WaitForUtils")) { - DeclarationMirror d = lib.declarations[s]!; - ClassMirror utils = (d as ClassMirror); - for (Symbol m in utils.staticMembers.keys) { - if (m.toString().contains("waitForEvent")) { - waitForEvent = utils.getField(m).reflectee; - } - } - } - } -} diff --git a/tests/standalone/io/wait_for_event_isolate_test.dart b/tests/standalone/io/wait_for_event_isolate_test.dart deleted file mode 100644 index 5a147aff8b0..00000000000 --- a/tests/standalone/io/wait_for_event_isolate_test.dart +++ /dev/null @@ -1,45 +0,0 @@ -// 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. - -// VMOptions=--enable-deprecated-wait-for - -import 'dart:async'; -import 'dart:isolate'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -import 'wait_for_event_helper.dart'; - -// Tests that waitForEvent() returns on an Isolate message. - -messageSender(SendPort s) { - new Timer(const Duration(seconds: 1), () { - s.send(true); - }); -} - -main() { - initWaitForEvent(); - asyncStart(); - bool flag1 = false; - bool flag2 = false; - ReceivePort r = new ReceivePort(); - Isolate.spawn(messageSender, r.sendPort).then((Isolate i) { - r.listen((message) { - flag1 = true; - }); - Expect.isFalse(flag1); - waitForEvent(); - Expect.isTrue(flag1); - r.close(); - flag2 = true; - }); - Expect.isFalse(flag1); - Expect.isFalse(flag2); - waitForEvent(); - Expect.isTrue(flag1); - Expect.isTrue(flag2); - asyncEnd(); -} diff --git a/tests/standalone/io/wait_for_event_microtask_test.dart b/tests/standalone/io/wait_for_event_microtask_test.dart deleted file mode 100644 index 96f13dc2b74..00000000000 --- a/tests/standalone/io/wait_for_event_microtask_test.dart +++ /dev/null @@ -1,28 +0,0 @@ -// 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. - -// VMOptions=--enable-deprecated-wait-for - -import 'dart:async'; -import 'dart:cli'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -import 'wait_for_event_helper.dart'; - -// Tests that microtasks are run before waitForEvent() blocks. - -main() { - initWaitForEvent(); - asyncStart(); - bool flag = false; - scheduleMicrotask(() { - flag = true; - asyncEnd(); - }); - Expect.isFalse(flag); - waitForEvent(timeout: const Duration(milliseconds: 10)); - Expect.isTrue(flag); -} diff --git a/tests/standalone/io/wait_for_event_nested_microtask_test.dart b/tests/standalone/io/wait_for_event_nested_microtask_test.dart deleted file mode 100644 index 01a316c072c..00000000000 --- a/tests/standalone/io/wait_for_event_nested_microtask_test.dart +++ /dev/null @@ -1,38 +0,0 @@ -// 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. - -// VMOptions=--enable-deprecated-wait-for - -import 'dart:async'; -import 'dart:cli'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -import 'wait_for_event_helper.dart'; - -// Tests that waitForEvent() drains microtasks before blocking even when -// called from a microtask. - -main() { - initWaitForEvent(); - asyncStart(); - bool flag1 = false; - bool flag2 = false; - scheduleMicrotask(() { - scheduleMicrotask(() { - flag1 = true; - asyncEnd(); - }); - Expect.isFalse(flag1); - waitForEvent(timeout: const Duration(milliseconds: 10)); - Expect.isTrue(flag1); - flag2 = true; - }); - Expect.isFalse(flag1); - Expect.isFalse(flag2); - waitForEvent(timeout: const Duration(milliseconds: 10)); - Expect.isTrue(flag1); - Expect.isTrue(flag2); -} diff --git a/tests/standalone/io/wait_for_event_nested_timer_microtask_test.dart b/tests/standalone/io/wait_for_event_nested_timer_microtask_test.dart deleted file mode 100644 index f91a349e25c..00000000000 --- a/tests/standalone/io/wait_for_event_nested_timer_microtask_test.dart +++ /dev/null @@ -1,31 +0,0 @@ -// 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. - -// VMOptions=--enable-deprecated-wait-for - -import 'dart:async'; -import 'dart:cli'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -import 'wait_for_event_helper.dart'; - -// Tests that the microtasks for a message handler are run before -// waitForEvent() returns. - -main() { - initWaitForEvent(); - asyncStart(); - bool flag = false; - Timer.run(() { - scheduleMicrotask(() { - flag = true; - asyncEnd(); - }); - }); - Expect.isFalse(flag); - waitForEvent(); - Expect.isTrue(flag); -} diff --git a/tests/standalone/io/wait_for_event_nested_timer_test.dart b/tests/standalone/io/wait_for_event_nested_timer_test.dart deleted file mode 100644 index 79d498fb1c1..00000000000 --- a/tests/standalone/io/wait_for_event_nested_timer_test.dart +++ /dev/null @@ -1,34 +0,0 @@ -// 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. - -// VMOptions=--enable-deprecated-wait-for - -import 'dart:async'; -import 'dart:cli'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -import 'wait_for_event_helper.dart'; - -// Tests that all messages are processed before waitForEvent() returns. - -main() { - initWaitForEvent(); - asyncStart(); - bool flag = false; - Timer.run(() { - Timer.run(() { - Timer.run(() { - Timer.run(() { - flag = true; - asyncEnd(); - }); - }); - }); - }); - Expect.isFalse(flag); - waitForEvent(); - Expect.isTrue(flag); -} diff --git a/tests/standalone/io/wait_for_event_nested_waits_test.dart b/tests/standalone/io/wait_for_event_nested_waits_test.dart deleted file mode 100644 index a9dc5afd0c5..00000000000 --- a/tests/standalone/io/wait_for_event_nested_waits_test.dart +++ /dev/null @@ -1,73 +0,0 @@ -// 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. - -// VMOptions=--enable-deprecated-wait-for - -import 'dart:async'; -import 'dart:cli'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -import 'wait_for_event_helper.dart'; - -// Tests that waitForEvent() works when called from a message handler. - -main() { - initWaitForEvent(); - asyncStart(); - bool flag1 = false; - bool flag2 = false; - bool flag3 = false; - bool flag4 = false; - Timer.run(() { - Timer.run(() { - Timer.run(() { - Timer.run(() { - flag1 = true; - asyncEnd(); - }); - Expect.isFalse(flag1); - Expect.isFalse(flag2); - Expect.isFalse(flag3); - Expect.isFalse(flag4); - waitForEvent(); - Expect.isTrue(flag1); - Expect.isFalse(flag2); - Expect.isFalse(flag3); - Expect.isFalse(flag4); - flag2 = true; - }); - Expect.isFalse(flag1); - Expect.isFalse(flag2); - Expect.isFalse(flag3); - Expect.isFalse(flag4); - waitForEvent(); - Expect.isTrue(flag1); - Expect.isTrue(flag2); - Expect.isFalse(flag3); - Expect.isFalse(flag4); - flag3 = true; - }); - Expect.isFalse(flag1); - Expect.isFalse(flag2); - Expect.isFalse(flag3); - Expect.isFalse(flag4); - waitForEvent(); - Expect.isTrue(flag1); - Expect.isTrue(flag2); - Expect.isTrue(flag3); - Expect.isFalse(flag4); - flag4 = true; - }); - Expect.isFalse(flag1); - Expect.isFalse(flag2); - Expect.isFalse(flag3); - Expect.isFalse(flag4); - waitForEvent(); - Expect.isTrue(flag1); - Expect.isTrue(flag2); - Expect.isTrue(flag3); - Expect.isTrue(flag4); -} diff --git a/tests/standalone/io/wait_for_event_timer_test.dart b/tests/standalone/io/wait_for_event_timer_test.dart deleted file mode 100644 index c48928a12d9..00000000000 --- a/tests/standalone/io/wait_for_event_timer_test.dart +++ /dev/null @@ -1,28 +0,0 @@ -// 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. - -// VMOptions=--enable-deprecated-wait-for - -import 'dart:async'; -import 'dart:cli'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -import 'wait_for_event_helper.dart'; - -// Tests that waitForEvent() works in a simple case. - -main() { - initWaitForEvent(); - asyncStart(); - bool flag = false; - Timer.run(() { - flag = true; - asyncEnd(); - }); - Expect.isFalse(flag); - waitForEvent(); - Expect.isTrue(flag); -} diff --git a/tests/standalone/io/wait_for_event_zone_caught_error_test.dart b/tests/standalone/io/wait_for_event_zone_caught_error_test.dart deleted file mode 100644 index a3fb8fbcc9d..00000000000 --- a/tests/standalone/io/wait_for_event_zone_caught_error_test.dart +++ /dev/null @@ -1,33 +0,0 @@ -// 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. - -// VMOptions=--enable-deprecated-wait-for - -import 'dart:async'; -import 'dart:cli'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -import 'wait_for_event_helper.dart'; - -// Tests that waitForEvent() doesn't cause an error to escape a Zone that -// has an error handler. - -main() { - initWaitForEvent(); - asyncStart(); - bool flag = false; - runZonedGuarded(() { - Timer.run(() { - asyncEnd(); - throw "Exception"; - }); - }, (e, s) { - flag = true; - }); - Expect.isFalse(flag); - waitForEvent(); - Expect.isTrue(flag); -} diff --git a/tests/standalone/io/wait_for_event_zone_test.dart b/tests/standalone/io/wait_for_event_zone_test.dart deleted file mode 100644 index 8c13709cdbe..00000000000 --- a/tests/standalone/io/wait_for_event_zone_test.dart +++ /dev/null @@ -1,31 +0,0 @@ -// 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. - -// VMOptions=--enable-deprecated-wait-for - -import 'dart:async'; -import 'dart:cli'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -import 'wait_for_event_helper.dart'; - -// Tests that waitForEvent() works even when the message handler is run in -// a different Zone. - -main() { - initWaitForEvent(); - asyncStart(); - bool flag = false; - runZoned(() { - Timer.run(() { - flag = true; - asyncEnd(); - }); - }); - Expect.isFalse(flag); - waitForEvent(); - Expect.isTrue(flag); -} diff --git a/tests/standalone/io/wait_for_exception_test.dart b/tests/standalone/io/wait_for_exception_test.dart deleted file mode 100644 index 365f7ae069a..00000000000 --- a/tests/standalone/io/wait_for_exception_test.dart +++ /dev/null @@ -1,26 +0,0 @@ -// 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. - -// VMOptions=--enable-deprecated-wait-for - -import 'dart:async'; -import 'dart:cli'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -main() { - asyncStart(); - Completer c = new Completer(); - runZonedGuarded(() { - Timer.run(() { - asyncEnd(); - throw "Error"; - }); - }, (e, s) { - Expect.isTrue(e is String); - c.complete(true); - }); - Expect.isTrue(waitFor(c.future)); -} diff --git a/tests/standalone/io/wait_for_test.dart b/tests/standalone/io/wait_for_test.dart deleted file mode 100644 index 1babf3327a8..00000000000 --- a/tests/standalone/io/wait_for_test.dart +++ /dev/null @@ -1,23 +0,0 @@ -// 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. - -// VMOptions=--enable-deprecated-wait-for - -import 'dart:async'; -import 'dart:mirrors'; -import 'dart:cli'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -main() { - asyncStart(); - Completer c = new Completer(); - Timer.run(() { - c.complete(true); - asyncEnd(); - }); - bool result = waitFor(c.future); - Expect.isTrue(result); -} diff --git a/tests/standalone/io/wait_for_timeout_test.dart b/tests/standalone/io/wait_for_timeout_test.dart deleted file mode 100644 index f343876d4ef..00000000000 --- a/tests/standalone/io/wait_for_timeout_test.dart +++ /dev/null @@ -1,20 +0,0 @@ -// 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. - -// VMOptions=--enable-deprecated-wait-for - -import 'dart:async'; -import 'dart:cli'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -main() { - asyncStart(); - Completer c = new Completer(); - Expect.throws(() { - waitFor(c.future, timeout: const Duration(seconds: 1)); - }, (e) => e is TimeoutException); - asyncEnd(); -}