TEST=new tests added

Change-Id: Ic604cc9576f092c1bf96f411ae1abdea6c78c384
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329784
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
This commit is contained in:
asiva 2023-10-11 21:51:02 +00:00 committed by Commit Queue
parent fd798c2cef
commit 8e6a02d899
4 changed files with 68 additions and 2 deletions

View file

@ -374,6 +374,43 @@ void defineCompileTests() {
expect(result.stdout, contains('42'));
}, skip: isRunningOnIA32);
test('Regression test for https://github.com/dart-lang/sdk/issues/45347',
() async {
final p = project(mainSrc: '''
import "dart:developer";
import "dart:isolate";
void main() {
final id = Service.getIsolateId(Isolate.current)?? "NA";
}
''');
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
final outFile = path.canonicalize(path.join(p.dirPath, 'myexe'));
var result = await p.run(
[
'compile',
'exe',
'-v',
'-o',
outFile,
inFile,
],
);
expect(result.stderr, isEmpty);
expect(result.exitCode, 0);
expect(File(outFile).existsSync(), true,
reason: 'File not found: $outFile');
result = Process.runSync(
outFile,
[],
);
expect(result.stderr, isEmpty);
expect(result.exitCode, 0);
}, skip: isRunningOnIA32);
test('Compile executable cannot compile cross-OS', () async {
final p = project(
mainSrc: 'void main() {print(const String.fromEnvironment("cross"));}');

View file

@ -178,7 +178,7 @@ external void _webServerControl(
@patch
@pragma("vm:external-name", "Developer_getIsolateIdFromSendPort")
external String _getIsolateIdFromSendPort(SendPort sendPort);
external String? _getIsolateIdFromSendPort(SendPort sendPort);
@patch
@pragma("vm:external-name", "Developer_getObjectId")

View file

@ -535,7 +535,7 @@ final class Isolate {
external static void _sendOOB(port, msg);
@pragma("vm:external-name", "Isolate_getDebugName")
external static String _getDebugName(SendPort controlPort);
external static String? _getDebugName(SendPort controlPort);
@patch
void _pause(Capability resumeCapability) {

View file

@ -0,0 +1,29 @@
// 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.
// Regression test for https://github.com/dart-lang/sdk/issues/45347
import 'dart:developer';
import 'dart:isolate';
import "package:expect/expect.dart";
void sendSetOfEnums(SendPort port) {
Isolate childIsolate = Isolate.current;
port.send(childIsolate);
}
void main() async {
try {
final id = Service.getIsolateId(Isolate.current) ?? "NA";
print(id);
final port = ReceivePort();
await Isolate.spawn(sendSetOfEnums, port.sendPort);
Isolate childIsolate = await port.first;
final did = childIsolate.debugName ?? "NA";
print(did);
} catch (e, s) {
Expect.isTrue(false);
}
}