722e4f2cca
Remove uses of async_minitest and multitests. Removed two files that were checking dynamic behavior that no longer exists (compile-time errors reported at runtime). Rewrote and/or added to enum_const_test.dart and _deferred_in_isoltae_test.dart. Otherwise mainly removing multitest `//# ok:...` comments, or `//# 01: ...error...` that only existed because the test failed in dart2js, along with anything else that tried to special-case dart2js (which no longer supports isolates at all). Some sporadic general clean-up like removing library names. Change-Id: I99b55f05710347343286e86b37ce02f1006868dc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/402700 Reviewed-by: Nate Bosch <nbosch@google.com> Commit-Queue: Lasse Nielsen <lrn@google.com>
74 lines
2.1 KiB
Dart
74 lines
2.1 KiB
Dart
// Copyright (c) 2020, 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:io";
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
void testNoPackages(String filePath, Uri uri, String expected) {
|
|
File mainIsolate = new File(filePath);
|
|
mainIsolate.writeAsStringSync('''
|
|
library spawn_tests;
|
|
|
|
import 'dart:isolate';
|
|
|
|
void main() async {
|
|
const String debugName = 'spawnedIsolate';
|
|
final exitPort = ReceivePort();
|
|
final port = ReceivePort();
|
|
port.listen((msg) {
|
|
print(msg);
|
|
port.close();
|
|
});
|
|
|
|
final isolate = await Isolate.spawnUri(
|
|
Uri.parse('$uri'),
|
|
['$expected'],
|
|
port.sendPort,
|
|
paused: false,
|
|
debugName: debugName,
|
|
onExit: exitPort.sendPort);
|
|
|
|
// Explicitly await spawned isolate exit to enforce main isolate not
|
|
// completing (and the stand-alone runtime exiting) before the spawned
|
|
// isolate is done.
|
|
await exitPort.first;
|
|
}
|
|
''');
|
|
var exec = Platform.resolvedExecutable;
|
|
var args = <String>[];
|
|
args.add(mainIsolate.path);
|
|
var result = Process.runSync(exec, args);
|
|
print('stdout: ${result.stdout}');
|
|
print('stderr: ${result.stderr}');
|
|
Expect.isTrue(result.stdout.contains('$expected'));
|
|
}
|
|
|
|
void main() {
|
|
// Create temporary directory.
|
|
var tmpDir = Directory.systemTemp.createTempSync();
|
|
var tmpDirPath = tmpDir.path;
|
|
|
|
// Generate code for an isolate to run without any package specification.
|
|
File noPackageIsolate = new File("$tmpDirPath/no_package.dart");
|
|
noPackageIsolate.writeAsStringSync('''
|
|
library SpawnUriIsolate;
|
|
main(List<String> args, replyTo) {
|
|
var data = args[0];
|
|
replyTo.send(data);
|
|
}
|
|
''');
|
|
|
|
try {
|
|
// Isolate Spawning another Isolate without any package specification.
|
|
testNoPackages(
|
|
"$tmpDirPath/no_package_isolate.dart",
|
|
Uri.file(noPackageIsolate.path),
|
|
're: no package',
|
|
);
|
|
} finally {
|
|
tmpDir.deleteSync(recursive: true);
|
|
}
|
|
}
|