diff --git a/webdev/test/build/min_sdk_test.dart b/webdev/test/build/min_sdk_test.dart index a890013d2..9a12dbab8 100644 --- a/webdev/test/build/min_sdk_test.dart +++ b/webdev/test/build/min_sdk_test.dart @@ -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') @Skip('Intended to run in analyze stage on stable SDK only, see mono_pkg.yaml') import 'dart:io'; @@ -19,7 +17,7 @@ void main() { sdkVersion = Version(sdkVersion.major, sdkVersion.minor, 0); var sdkConstraint = VersionConstraint.compatibleWith(sdkVersion); - var pubspecSdkConstraint = pubspec.environment['sdk']; + var pubspecSdkConstraint = pubspec.environment!['sdk']!; expect(sdkConstraint.allowsAll(pubspecSdkConstraint), true, reason: 'Min sdk constraint is outdated. Please update SDK constraint in ' diff --git a/webdev/test/chrome_test.dart b/webdev/test/chrome_test.dart index 7acbda24f..116b820f3 100644 --- a/webdev/test/chrome_test.dart +++ b/webdev/test/chrome_test.dart @@ -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 - @Timeout(Duration(seconds: 60)) import 'dart:async'; import 'dart:io'; @@ -15,28 +13,28 @@ import 'package:webdev/src/serve/chrome.dart'; import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'; void main() { - Chrome chrome; + Chrome? chrome; - Future launchChrome({int port, String userDataDir}) async { + Future launchChrome({int? port, String? userDataDir}) async { chrome = await Chrome.start([_googleUrl], port: port ?? 0, userDataDir: userDataDir); } Future openTab(String url) => - chrome.chromeConnection.getUrl(_openTabUrl(url)); + chrome!.chromeConnection.getUrl(_openTabUrl(url)); Future closeTab(ChromeTab tab) => - chrome.chromeConnection.getUrl(_closeTabUrl(tab.id)); + chrome!.chromeConnection.getUrl(_closeTabUrl(tab.id)); Future connectToTab(String url) async { - var tab = await chrome.chromeConnection.getTab((t) => t.url.contains(url)); + var tab = await chrome!.chromeConnection.getTab((t) => t.url.contains(url)); expect(tab, isNotNull); - return tab.connect(); + return tab!.connect(); } group('chrome with temp data dir', () { tearDown(() async { - var tabs = await chrome?.chromeConnection?.getTabs(); + var tabs = await chrome?.chromeConnection.getTabs(); if (tabs != null) { for (var tab in tabs) { await closeTab(tab); @@ -53,7 +51,7 @@ void main() { test('has a working debugger', () async { await launchChrome(); - var tabs = await chrome.chromeConnection.getTabs(); + var tabs = await chrome!.chromeConnection.getTabs(); expect( tabs, contains(const TypeMatcher() @@ -62,7 +60,7 @@ void main() { test('uses open debug port if provided port is 0', () async { await launchChrome(port: 0); - expect(chrome.debugPort, isNot(equals(0))); + expect(chrome!.debugPort, isNot(equals(0))); }); test('has correct profile path', () async { @@ -84,16 +82,16 @@ void main() { }); group('chrome with user data dir', () { - Directory dataDir; - StreamController logController; - Stream logStream; + late Directory dataDir; + late StreamController logController; + late Stream logStream; setUp(() { logController = StreamController(); logStream = logController.stream; void _logWriter(Level level, String message, - {String error, String loggerName, String stackTrace}) { + {String? error, String? loggerName, String? stackTrace}) { if (level >= Level.INFO) { logController.add('[$level] $loggerName: $message'); } @@ -104,7 +102,7 @@ void main() { }); tearDown(() async { - var tabs = await chrome?.chromeConnection?.getTabs(); + var tabs = await chrome?.chromeConnection.getTabs(); if (tabs != null) { for (var tab in tabs) { await closeTab(tab); @@ -121,7 +119,7 @@ void main() { '.*chrome_user_data_copy'))); await logController.close(); } - dataDir?.deleteSync(recursive: true); + dataDir.deleteSync(recursive: true); }); test('works with debug port', () async { @@ -132,7 +130,7 @@ void main() { test('has a working debugger', () async { await launchChrome(userDataDir: dataDir.path); - var tabs = await chrome.chromeConnection.getTabs(); + var tabs = await chrome!.chromeConnection.getTabs(); expect( tabs, contains(const TypeMatcher() @@ -160,7 +158,7 @@ void main() { var userDataDir = autoDetectChromeUserDataDirectory(); expect(userDataDir, isNotNull); - expect(Directory(userDataDir).existsSync(), isTrue); + expect(Directory(userDataDir!).existsSync(), isTrue); await launchChrome(userDataDir: userDataDir); await openTab(_chromeVersionUrl); @@ -188,14 +186,14 @@ String _openTabUrl(String url) => '/json/new?$url'; String _closeTabUrl(String id) => '/json/close/$id'; Future _evaluateExpression(WipPage page, String expression) async { - var result = ''; + String? result = ''; while (result == null || result.isEmpty) { await Future.delayed(const Duration(milliseconds: 100)); var wipResponse = await page.sendCommand( 'Runtime.evaluate', params: {'expression': expression}, ); - result = wipResponse.json['result']['result']['value'] as String; + result = wipResponse.json['result']['result']['value'] as String?; } return result; } diff --git a/webdev/test/configuration_test.dart b/webdev/test/configuration_test.dart index c308d5819..4bfdcb87e 100644 --- a/webdev/test/configuration_test.dart +++ b/webdev/test/configuration_test.dart @@ -2,14 +2,12 @@ // 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 - import 'package:args/args.dart'; import 'package:test/test.dart'; import 'package:webdev/src/command/configuration.dart'; void main() { - ArgParser argParser; + late ArgParser argParser; setUp(() { argParser = ArgParser() ..addFlag('release') diff --git a/webdev/test/daemon/app_domain_test.dart b/webdev/test/daemon/app_domain_test.dart index 638e61ac3..ad6f6735e 100644 --- a/webdev/test/daemon/app_domain_test.dart +++ b/webdev/test/daemon/app_domain_test.dart @@ -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 - @Timeout(Duration(minutes: 2)) import 'dart:convert'; import 'dart:io'; @@ -14,7 +12,7 @@ import '../test_utils.dart'; import 'utils.dart'; void main() { - String exampleDirectory; + late String exampleDirectory; setUpAll(() async { exampleDirectory = await prepareWorkspace(); diff --git a/webdev/test/daemon/daemon_domain_test.dart b/webdev/test/daemon/daemon_domain_test.dart index a8e551d5f..a7102a622 100644 --- a/webdev/test/daemon/daemon_domain_test.dart +++ b/webdev/test/daemon/daemon_domain_test.dart @@ -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 - @Timeout(Duration(minutes: 2)) import 'dart:convert'; @@ -14,7 +12,7 @@ import '../test_utils.dart'; import 'utils.dart'; void main() { - String exampleDirectory; + late String exampleDirectory; setUpAll(() async { exampleDirectory = await prepareWorkspace(); diff --git a/webdev/test/daemon/launch_app_test.dart b/webdev/test/daemon/launch_app_test.dart index 5133b5cba..9818e7ba9 100644 --- a/webdev/test/daemon/launch_app_test.dart +++ b/webdev/test/daemon/launch_app_test.dart @@ -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 - @Timeout(Duration(minutes: 2)) import 'package:test/test.dart'; @@ -11,7 +9,7 @@ import '../test_utils.dart'; import 'utils.dart'; void main() { - String exampleDirectory; + late String exampleDirectory; setUpAll(() async { exampleDirectory = await prepareWorkspace(); diff --git a/webdev/test/daemon/utils.dart b/webdev/test/daemon/utils.dart index 1adb1e723..fcb21d53b 100644 --- a/webdev/test/daemon/utils.dart +++ b/webdev/test/daemon/utils.dart @@ -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 - import 'dart:async'; import 'dart:convert'; @@ -50,7 +48,7 @@ Future prepareWorkspace() async { return exampleDirectory; } -String getDebugServiceUri(String line) { +String? getDebugServiceUri(String line) { var regex = RegExp(r'Debug service listening on (?[^\s^\\]*)'); var match = regex.firstMatch(line); if (match != null) { @@ -62,8 +60,8 @@ String getDebugServiceUri(String line) { Future findBreakpointLine(VmService vmService, String breakpointId, String isolateId, ScriptRef scriptRef) async { - var script = await vmService.getObject(isolateId, scriptRef.id) as Script; - var lines = LineSplitter.split(script.source).toList(); + var script = await vmService.getObject(isolateId, scriptRef.id!) as Script; + var lines = LineSplitter.split(script.source!).toList(); var lineNumber = lines.indexWhere((l) => l.endsWith('// Breakpoint: $breakpointId')); if (lineNumber == -1) { diff --git a/webdev/test/e2e_test.dart b/webdev/test/e2e_test.dart index ecdb3536c..6fdffd55b 100644 --- a/webdev/test/e2e_test.dart +++ b/webdev/test/e2e_test.dart @@ -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 - @Timeout(Duration(minutes: 5)) import 'dart:io'; @@ -29,7 +27,7 @@ import 'test_utils.dart'; /// Value: `null` - exists in both modes /// `true` - DDC only /// `false` - dart2js only -const _testItems = { +const _testItems = { 'main.dart.js': null, 'main.dart.bootstrap.js': true, 'main.unsound.ddc.js': true, @@ -39,8 +37,8 @@ void main() { // Change to true for debugging. final debug = false; - String exampleDirectory; - String soundExampleDirectory; + late String exampleDirectory; + late String soundExampleDirectory; setUpAll(() async { configureLogWriter(debug); exampleDirectory = @@ -309,14 +307,14 @@ void main() { var process = await runWebDev(args, workingDirectory: soundNullSafety ? soundExampleDirectory : exampleDirectory); - VmService vmService; + VmService? vmService; process.stdoutStream().listen(Logger.root.fine); process.stderrStream().listen(Logger.root.warning); try { // Wait for debug service Uri - String wsUri; + String? wsUri; await expectLater(process.stdout, emitsThrough((message) { wsUri = getDebugServiceUri(message as String); return wsUri != null; @@ -324,29 +322,29 @@ void main() { Logger.root.fine('vm service uri: $wsUri'); expect(wsUri, isNotNull); - vmService = await vmServiceConnectUri(wsUri); + vmService = await vmServiceConnectUri(wsUri!); var vm = await vmService.getVM(); - var isolate = vm.isolates.first; - var scripts = await vmService.getScripts(isolate.id); + var isolateId = vm.isolates!.first.id!; + var scripts = await vmService.getScripts(isolateId); await vmService.streamListen('Debug'); var stream = vmService.onEvent('Debug'); - var mainScript = scripts.scripts - .firstWhere((each) => each.uri.contains('main.dart')); + var mainScript = scripts.scripts! + .firstWhere((each) => each.uri!.contains('main.dart')); var bpLine = await findBreakpointLine( - vmService, 'printCounter', isolate.id, mainScript); + vmService, 'printCounter', isolateId, mainScript); var bp = await vmService.addBreakpointWithScriptUri( - isolate.id, mainScript.uri, bpLine); + isolateId, mainScript.uri!, bpLine); expect(bp, isNotNull); await stream.firstWhere( (Event event) => event.kind == EventKind.kPauseBreakpoint); var result = - await vmService.evaluateInFrame(isolate.id, 0, 'true'); + await vmService.evaluateInFrame(isolateId, 0, 'true'); expect( result, const TypeMatcher().having( @@ -372,25 +370,26 @@ void main() { var process = await runWebDev(args, workingDirectory: soundNullSafety ? soundExampleDirectory : exampleDirectory); - VmService vmService; + VmService? vmService; try { // Wait for debug service Uri - String wsUri; + String? wsUri; await expectLater(process.stdout, emitsThrough((message) { wsUri = getDebugServiceUri(message as String); return wsUri != null; })); expect(wsUri, isNotNull); - vmService = await vmServiceConnectUri(wsUri); + vmService = await vmServiceConnectUri(wsUri!); var vm = await vmService.getVM(); - var isolate = await vmService.getIsolate(vm.isolates.first.id); - var library = isolate.rootLib; + var isolateId = vm.isolates!.first.id!; + var isolate = await vmService.getIsolate(isolateId); + var libraryId = isolate.rootLib!.id!; await vmService.streamListen('Debug'); - var result = await vmService.evaluate(isolate.id, library.id, + var result = await vmService.evaluate(isolateId, libraryId, '(document?.body?.children?.first as SpanElement)?.text'); expect( @@ -401,7 +400,7 @@ void main() { 'Hello World!!')); result = await vmService.evaluate( - isolate.id, library.id, 'main.toString()'); + isolateId, libraryId, 'main.toString()'); expect( result, @@ -429,41 +428,41 @@ void main() { var process = await runWebDev(args, workingDirectory: soundNullSafety ? soundExampleDirectory : exampleDirectory); - VmService vmService; + VmService? vmService; try { // Wait for debug service Uri - String wsUri; + String? wsUri; await expectLater(process.stdout, emitsThrough((message) { wsUri = getDebugServiceUri(message as String); return wsUri != null; })); expect(wsUri, isNotNull); - vmService = await vmServiceConnectUri(wsUri); + vmService = await vmServiceConnectUri(wsUri!); var vm = await vmService.getVM(); - var isolate = vm.isolates.first; - var scripts = await vmService.getScripts(isolate.id); + var isolateId = vm.isolates!.first.id!; + var scripts = await vmService.getScripts(isolateId); await vmService.streamListen('Debug'); var stream = vmService.onEvent('Debug'); - var mainScript = scripts.scripts - .firstWhere((each) => each.uri.contains('main.dart')); + var mainScript = scripts.scripts! + .firstWhere((each) => each.uri!.contains('main.dart')); var bpLine = await findBreakpointLine( - vmService, 'printCounter', isolate.id, mainScript); + vmService, 'printCounter', isolateId, mainScript); var bp = await vmService.addBreakpointWithScriptUri( - isolate.id, mainScript.uri, bpLine); + isolateId, mainScript.uri!, bpLine); expect(bp, isNotNull); var event = await stream.firstWhere( (Event event) => event.kind == EventKind.kPauseBreakpoint); expect( - () => vmService.evaluateInFrame( - isolate.id, event.topFrame.index, 'true'), + () => vmService!.evaluateInFrame( + isolateId, event.topFrame!.index!, 'true'), throwsRPCError); } finally { await vmService?.dispose(); @@ -484,27 +483,28 @@ void main() { var process = await runWebDev(args, workingDirectory: soundNullSafety ? soundExampleDirectory : exampleDirectory); - VmService vmService; + VmService? vmService; try { // Wait for debug service Uri - String wsUri; + String? wsUri; await expectLater(process.stdout, emitsThrough((message) { wsUri = getDebugServiceUri(message as String); return wsUri != null; })); expect(wsUri, isNotNull); - vmService = await vmServiceConnectUri(wsUri); + vmService = await vmServiceConnectUri(wsUri!); var vm = await vmService.getVM(); - var isolate = await vmService.getIsolate(vm.isolates.first.id); - var library = isolate.rootLib; + var isolateId = vm.isolates!.first.id!; + var isolate = await vmService.getIsolate(isolateId); + var libraryId = isolate.rootLib!.id!; await vmService.streamListen('Debug'); expect( - () => vmService.evaluate( - isolate.id, library.id, 'main.toString()'), + () => vmService! + .evaluate(isolateId, libraryId, 'main.toString()'), throwsRPCError); } finally { await vmService?.dispose(); diff --git a/webdev/test/integration_test.dart b/webdev/test/integration_test.dart index be766da1b..cfadf8ca9 100644 --- a/webdev/test/integration_test.dart +++ b/webdev/test/integration_test.dart @@ -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 - import 'dart:async'; import 'dart:io'; @@ -156,7 +154,7 @@ name: sample var webCompilersVersion = _supportedWebCompilersVersion; var buildDaemonVersion = _supportedBuildDaemonVersion; - String supportedRange; + late String supportedRange; switch (entry.key) { case 'build_runner': buildRunnerVersion = version; @@ -272,9 +270,9 @@ const _supportedWebCompilersVersion = '2.12.0'; const _supportedBuildDaemonVersion = '2.0.0'; String _pubspecLock( - {String runnerVersion = _supportedBuildRunnerVersion, - String webCompilersVersion = _supportedWebCompilersVersion, - String daemonVersion = _supportedBuildDaemonVersion, + {String? runnerVersion = _supportedBuildRunnerVersion, + String? webCompilersVersion = _supportedWebCompilersVersion, + String? daemonVersion = _supportedBuildDaemonVersion, List extraPkgs = const []}) { var buffer = StringBuffer(''' # Copy-pasted from a valid run diff --git a/webdev/test/readme_test.dart b/webdev/test/readme_test.dart index 359860f57..0f57f0f96 100644 --- a/webdev/test/readme_test.dart +++ b/webdev/test/readme_test.dart @@ -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') @OnPlatform({ 'windows': Skip('https://github.com/dart-lang/webdev/issues/711'), diff --git a/webdev/test/test_utils.dart b/webdev/test/test_utils.dart index bf93bbeca..6ba2efebd 100644 --- a/webdev/test/test_utils.dart +++ b/webdev/test/test_utils.dart @@ -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 - import 'dart:async'; import 'dart:io'; @@ -14,7 +12,7 @@ import 'package:webdev/src/util.dart'; final _webdevBin = p.absolute(p.join('bin', 'webdev.dart')); -Future runWebDev(List args, {String workingDirectory}) { +Future runWebDev(List args, {String? workingDirectory}) { var fullArgs = [_webdevBin, ...args]; return TestProcess.start(dartPath, fullArgs, diff --git a/webdev/test/utils_test.dart b/webdev/test/utils_test.dart index a29748beb..8725483ce 100644 --- a/webdev/test/utils_test.dart +++ b/webdev/test/utils_test.dart @@ -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 - @Retry(0) import 'dart:async'; @@ -14,8 +12,8 @@ import 'package:test/test.dart'; import 'package:webdev/src/serve/utils.dart'; void main() { - Directory from; - Directory to; + late Directory from; + late Directory to; setUp(() { from = Directory.systemTemp.createTempSync('from'); @@ -23,8 +21,8 @@ void main() { }); tearDown(() { - from?.deleteSync(recursive: true); - to?.deleteSync(recursive: true); + from.deleteSync(recursive: true); + to.deleteSync(recursive: true); }); test('updatePath does nothing for non-existing directories', () async {