Skip to content

Commit b08d837

Browse files
derekxu16Commit Queue
authored andcommitted
[VM/Service] Move test logic of http_get_isolate_rpc_test from testee to main process
Issue: #60165 Change-Id: Ic393518dd2b85aa0e5385745bf19591f747791c8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/411420 Reviewed-by: Jessy Yameogo <[email protected]> Commit-Queue: Derek Xu <[email protected]>
1 parent 376b934 commit b08d837

File tree

3 files changed

+39
-46
lines changed

3 files changed

+39
-46
lines changed

pkg/vm_service/test/http_invocations/http_auth_get_isolate_rpc_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import 'http_get_isolate_rpc_common.dart';
77

88
void main([args = const <String>[]]) => runIsolateTests(
99
args,
10-
tests,
10+
httpGetIsolateRpcTests,
1111
'http_auth_get_isolate_rpc_test.dart',
12-
testeeBefore: testeeBefore,
1312
);

pkg/vm_service/test/http_invocations/http_get_isolate_rpc_common.dart

Lines changed: 37 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -10,54 +10,49 @@ import '../common/expect.dart';
1010
import '../common/service_test_common.dart';
1111
import 'http_request_helpers.dart';
1212

13-
Future<String> getIsolateId(Uri serverUri) async {
13+
Future<String> _getIsolateId(Uri serverUri) async {
1414
final result = await makeHttpServiceRequest(
1515
serverUri: serverUri,
1616
method: 'getVM',
1717
);
1818
return result['isolates'][0]['id'] as String;
1919
}
2020

21-
Future<void> testeeBefore() async {
22-
final info = await waitForServiceInfo();
23-
final serverUri = info.serverUri!;
24-
25-
try {
26-
// Build the request.
27-
final params = <String, String>{
28-
'isolateId': await getIsolateId(serverUri),
29-
};
30-
31-
final result = createServiceObject(
32-
await makeHttpServiceRequest(
33-
serverUri: serverUri,
34-
method: 'getIsolate',
35-
params: params,
36-
),
37-
['Isolate'],
38-
)! as Isolate;
39-
Expect.isTrue(result.id!.startsWith('isolates/'));
40-
Expect.isNotNull(result.number);
41-
Expect.equals(result.json!['_originNumber'], result.number);
42-
Expect.isTrue(result.startTime! > 0);
43-
Expect.isTrue(result.livePorts! > 0);
44-
Expect.isFalse(result.pauseOnExit);
45-
Expect.isNotNull(result.pauseEvent);
46-
Expect.isNull(result.error);
47-
Expect.isNotNull(result.rootLib);
48-
Expect.isTrue(result.libraries!.isNotEmpty);
49-
Expect.isTrue(result.breakpoints!.isEmpty);
50-
Expect.equals(result.json!['_heaps']['new']['type'], 'HeapSpace');
51-
Expect.equals(result.json!['_heaps']['old']['type'], 'HeapSpace');
52-
Expect.equals(result.json!['isolate_group']['type'], '@IsolateGroup');
53-
} catch (e) {
54-
Expect.fail('invalid request: $e');
55-
}
56-
}
57-
58-
final tests = <IsolateTest>[
21+
final httpGetIsolateRpcTests = <IsolateTest>[
5922
(VmService service, IsolateRef isolateRef) async {
60-
// Just getting here means that the testee enabled the service protocol
61-
// web server.
62-
}
23+
final wsUri = Uri.parse(service.wsUri!);
24+
final serverUri = Uri.parse('http://${wsUri.authority}');
25+
26+
try {
27+
// Build the request.
28+
final params = <String, String>{
29+
'isolateId': await _getIsolateId(serverUri),
30+
};
31+
32+
final result = createServiceObject(
33+
await makeHttpServiceRequest(
34+
serverUri: serverUri,
35+
method: 'getIsolate',
36+
params: params,
37+
),
38+
['Isolate'],
39+
)! as Isolate;
40+
Expect.isTrue(result.id!.startsWith('isolates/'));
41+
Expect.isNotNull(result.number);
42+
Expect.equals(result.json!['_originNumber'], result.number);
43+
Expect.isTrue(result.startTime! > 0);
44+
Expect.isTrue(result.livePorts! > 0);
45+
Expect.isFalse(result.pauseOnExit);
46+
Expect.isNotNull(result.pauseEvent);
47+
Expect.isNull(result.error);
48+
Expect.isNotNull(result.rootLib);
49+
Expect.isTrue(result.libraries!.isNotEmpty);
50+
Expect.isTrue(result.breakpoints!.isEmpty);
51+
Expect.equals(result.json!['_heaps']['new']['type'], 'HeapSpace');
52+
Expect.equals(result.json!['_heaps']['old']['type'], 'HeapSpace');
53+
Expect.equals(result.json!['isolate_group']['type'], '@IsolateGroup');
54+
} catch (e) {
55+
Expect.fail('invalid request: $e');
56+
}
57+
},
6358
];

pkg/vm_service/test/http_invocations/http_get_isolate_rpc_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import 'http_get_isolate_rpc_common.dart';
77

88
void main([args = const <String>[]]) => runIsolateTests(
99
args,
10-
tests,
10+
httpGetIsolateRpcTests,
1111
'http_get_isolate_rpc_test.dart',
12-
testeeBefore: testeeBefore,
1312
useAuthToken: false,
1413
);

0 commit comments

Comments
 (0)