-
Notifications
You must be signed in to change notification settings - Fork 87
Migrate a handful of tests to null-safety #1715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,6 @@ | |
// 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. | ||
|
||
// @dart = 2.9 | ||
|
||
@TestOn('vm') | ||
import 'dart:async'; | ||
|
||
|
@@ -53,64 +51,64 @@ void main() { | |
|
||
group('breakpoint', () { | ||
VM vm; | ||
Isolate isolate; | ||
late Isolate isolate; | ||
ScriptList scripts; | ||
ScriptRef mainScript; | ||
Stream<Event> stream; | ||
late ScriptRef mainScript; | ||
late Stream<Event> stream; | ||
|
||
setUp(() async { | ||
setCurrentLogWriter(debug: debug); | ||
vm = await service.getVM(); | ||
isolate = await service.getIsolate(vm.isolates.first.id); | ||
scripts = await service.getScripts(isolate.id); | ||
isolate = await service.getIsolate(vm.isolates!.first.id!); | ||
scripts = await service.getScripts(isolate.id!); | ||
|
||
await service.streamListen('Debug'); | ||
stream = service.onEvent('Debug'); | ||
|
||
mainScript = scripts.scripts | ||
.firstWhere((each) => each.uri.contains('main.dart')); | ||
mainScript = scripts.scripts! | ||
.firstWhere((each) => each.uri!.contains('main.dart')); | ||
}); | ||
|
||
tearDown(() async { | ||
await service.resume(isolate.id); | ||
await service.resume(isolate.id!); | ||
}); | ||
|
||
test('set breakpoint', () async { | ||
final line = await context.findBreakpointLine( | ||
'printLocal', isolate.id, mainScript); | ||
'printLocal', isolate.id!, mainScript); | ||
final bp = await service.addBreakpointWithScriptUri( | ||
isolate.id, mainScript.uri, line); | ||
isolate.id!, mainScript.uri!, line); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe the same for mainScript.uri? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
await stream.firstWhere( | ||
(Event event) => event.kind == EventKind.kPauseBreakpoint); | ||
|
||
expect(bp, isNotNull); | ||
|
||
// Remove breakpoint so it doesn't impact other tests. | ||
await service.removeBreakpoint(isolate.id, bp.id); | ||
await service.removeBreakpoint(isolate.id!, bp.id!); | ||
}); | ||
|
||
test('set breakpoint again', () async { | ||
final line = await context.findBreakpointLine( | ||
'printLocal', isolate.id, mainScript); | ||
'printLocal', isolate.id!, mainScript); | ||
final bp = await service.addBreakpointWithScriptUri( | ||
isolate.id, mainScript.uri, line); | ||
isolate.id!, mainScript.uri!, line); | ||
|
||
await stream.firstWhere( | ||
(Event event) => event.kind == EventKind.kPauseBreakpoint); | ||
|
||
expect(bp, isNotNull); | ||
|
||
// Remove breakpoint so it doesn't impact other tests. | ||
await service.removeBreakpoint(isolate.id, bp.id); | ||
await service.removeBreakpoint(isolate.id!, bp.id!); | ||
}); | ||
|
||
test('set breakpoint inside a JavaScript line succeeds', () async { | ||
final line = await context.findBreakpointLine( | ||
'printNestedObjectMultiLine', isolate.id, mainScript); | ||
'printNestedObjectMultiLine', isolate.id!, mainScript); | ||
final column = 0; | ||
final bp = await service.addBreakpointWithScriptUri( | ||
isolate.id, mainScript.uri, line, | ||
isolate.id!, mainScript.uri!, line, | ||
column: column); | ||
|
||
await stream.firstWhere( | ||
|
@@ -125,7 +123,7 @@ void main() { | |
.having((loc) => loc.column, 'column', greaterThan(column))); | ||
|
||
// Remove breakpoint so it doesn't impact other tests. | ||
await service.removeBreakpoint(isolate.id, bp.id); | ||
await service.removeBreakpoint(isolate.id!, bp.id!); | ||
}); | ||
}); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,6 @@ | |
// 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. | ||
|
||
// @dart = 2.9 | ||
|
||
@TestOn('vm') | ||
import 'dart:async'; | ||
|
||
|
@@ -66,47 +64,47 @@ void main() { | |
}); | ||
|
||
group('callStack |', () { | ||
ChromeProxyService service; | ||
late ChromeProxyService service; | ||
VM vm; | ||
Isolate isolate; | ||
late Isolate isolate; | ||
ScriptList scripts; | ||
ScriptRef mainScript; | ||
ScriptRef testLibraryScript; | ||
Stream<Event> stream; | ||
late ScriptRef mainScript; | ||
late ScriptRef testLibraryScript; | ||
late Stream<Event> stream; | ||
|
||
setUp(() async { | ||
setCurrentLogWriter(debug: debug); | ||
service = setup.service; | ||
vm = await service.getVM(); | ||
isolate = await service.getIsolate(vm.isolates.first.id); | ||
scripts = await service.getScripts(isolate.id); | ||
isolate = await service.getIsolate(vm.isolates!.first.id!); | ||
scripts = await service.getScripts(isolate.id!); | ||
|
||
await service.streamListen('Debug'); | ||
stream = service.onEvent('Debug'); | ||
|
||
final testPackage = | ||
soundNullSafety ? '_test_package_sound' : '_test_package'; | ||
|
||
mainScript = scripts.scripts | ||
.firstWhere((each) => each.uri.contains('main.dart')); | ||
testLibraryScript = scripts.scripts.firstWhere((each) => | ||
each.uri.contains('package:$testPackage/test_library.dart')); | ||
mainScript = scripts.scripts! | ||
.firstWhere((each) => each.uri!.contains('main.dart')); | ||
testLibraryScript = scripts.scripts!.firstWhere((each) => | ||
each.uri!.contains('package:$testPackage/test_library.dart')); | ||
}); | ||
|
||
tearDown(() async { | ||
await service.resume(isolate.id); | ||
await service.resume(isolate.id!); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar for isolate.id here, as it looks like it is used in many places. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
}); | ||
|
||
Future<void> onBreakPoint(BreakpointTestData breakpoint, | ||
Future<void> Function() body) async { | ||
Breakpoint bp; | ||
Breakpoint? bp; | ||
try { | ||
final bpId = breakpoint.bpId; | ||
final script = breakpoint.script; | ||
final line = | ||
await context.findBreakpointLine(bpId, isolate.id, script); | ||
await context.findBreakpointLine(bpId, isolate.id!, script); | ||
bp = await setup.service | ||
.addBreakpointWithScriptUri(isolate.id, script.uri, line); | ||
.addBreakpointWithScriptUri(isolate.id!, script.uri!, line); | ||
|
||
expect(bp, isNotNull); | ||
expect(bp.location, _matchBpLocation(script, line, 0)); | ||
|
@@ -118,7 +116,7 @@ void main() { | |
} finally { | ||
// Remove breakpoint so it doesn't impact other tests or retries. | ||
if (bp != null) { | ||
await setup.service.removeBreakpoint(isolate.id, bp.id); | ||
await setup.service.removeBreakpoint(isolate.id!, bp.id!); | ||
} | ||
} | ||
} | ||
|
@@ -127,13 +125,13 @@ void main() { | |
{int frameIndex = 1}) async { | ||
// Find lines the breakpoints are located on. | ||
final lines = await Future.wait(breakpoints.map((frame) => context | ||
.findBreakpointLine(frame.bpId, isolate.id, frame.script))); | ||
.findBreakpointLine(frame.bpId, isolate.id!, frame.script))); | ||
|
||
// Get current stack. | ||
final stack = await service.getStack(isolate.id); | ||
final stack = await service.getStack(isolate.id!); | ||
|
||
// Verify the stack is correct. | ||
expect(stack.frames.length, greaterThanOrEqualTo(lines.length)); | ||
expect(stack.frames!.length, greaterThanOrEqualTo(lines.length)); | ||
final expected = [ | ||
for (var i = 0; i < lines.length; i++) | ||
_matchFrame( | ||
|
@@ -143,7 +141,7 @@ void main() { | |
|
||
// Verify that expression evaluation is not failing. | ||
final instance = | ||
await service.evaluateInFrame(isolate.id, frameIndex, 'true'); | ||
await service.evaluateInFrame(isolate.id!, frameIndex, 'true'); | ||
expect(instance, isA<InstanceRef>()); | ||
} | ||
|
||
|
@@ -236,7 +234,7 @@ void main() { | |
), | ||
]; | ||
await onBreakPoint(breakpoints[0], () async { | ||
await service.resume(isolate.id, step: 'Out'); | ||
await service.resume(isolate.id!, step: 'Out'); | ||
await stream.firstWhere( | ||
(Event event) => event.kind == EventKind.kPauseInterrupted); | ||
return testCallStack([breakpoints[1], breakpoints[2]]); | ||
|
@@ -263,7 +261,7 @@ void main() { | |
), | ||
]; | ||
await onBreakPoint(breakpoints[1], () async { | ||
await service.resume(isolate.id, step: 'Into'); | ||
await service.resume(isolate.id!, step: 'Into'); | ||
await stream.firstWhere( | ||
(Event event) => event.kind == EventKind.kPauseInterrupted); | ||
return testCallStack(breakpoints); | ||
|
@@ -295,7 +293,7 @@ void main() { | |
final bp = BreakpointTestData( | ||
'printMultiLine', 'printObjectMultiLine', mainScript); | ||
await onBreakPoint(bp, () async { | ||
await service.resume(isolate.id, step: 'Into'); | ||
await service.resume(isolate.id!, step: 'Into'); | ||
await stream.firstWhere( | ||
(Event event) => event.kind == EventKind.kPauseInterrupted); | ||
return testCallStack(breakpoints); | ||
|
@@ -309,7 +307,7 @@ void main() { | |
} | ||
|
||
Matcher _matchFrame(ScriptRef script, String function, int line) => isA<Frame>() | ||
.having((frame) => frame.code.name, 'function', function) | ||
.having((frame) => frame.code!.name, 'function', function) | ||
.having((frame) => frame.location, 'location', | ||
_matchFrameLocation(script, line)); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we declare an
isolateId
variable instead of asserting onisolate.id!
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done