From 80f0130fc2f3ebedc7faab7ba6e511b382b0e214 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Fri, 9 Dec 2022 09:06:45 -0800 Subject: [PATCH 01/36] Fix first test --- dwds/test/build_daemon_circular_evaluate_test.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dwds/test/build_daemon_circular_evaluate_test.dart b/dwds/test/build_daemon_circular_evaluate_test.dart index 6ff523a75..c928fe44b 100644 --- a/dwds/test/build_daemon_circular_evaluate_test.dart +++ b/dwds/test/build_daemon_circular_evaluate_test.dart @@ -3,7 +3,9 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') +import 'dart:io'; +import 'package:pub_semver/pub_semver.dart'; import 'package:test/test.dart'; import 'fixtures/context.dart'; @@ -12,8 +14,12 @@ import 'evaluate_circular_common.dart'; void main() async { // Enable verbose logging for debugging. final debug = false; + final sdkVersion = Version.parse(Platform.version.split(' ')[0]); + final nullSafetyValues = (sdkVersion.major >= 3) + ? [NullSafety.sound] + : [NullSafety.sound, NullSafety.weak]; - for (var nullSafety in NullSafety.values) { + for (var nullSafety in nullSafetyValues) { group('${nullSafety.name} null safety |', () { testAll( compilationMode: CompilationMode.buildDaemon, From 3b781755b909891bac8de56287397820c25949fb Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Fri, 9 Dec 2022 09:14:56 -0800 Subject: [PATCH 02/36] Fix another test --- dwds/test/build_daemon_breakpoint_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dwds/test/build_daemon_breakpoint_test.dart b/dwds/test/build_daemon_breakpoint_test.dart index 8115a33bb..14a7df87e 100644 --- a/dwds/test/build_daemon_breakpoint_test.dart +++ b/dwds/test/build_daemon_breakpoint_test.dart @@ -15,8 +15,8 @@ import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'; import 'fixtures/context.dart'; final context = TestContext( - directory: p.join('..', 'fixtures', '_testPackage'), - entry: p.join('..', 'fixtures', '_testPackage', 'web', 'main.dart'), + directory: p.join('..', 'fixtures', '_testPackageSound'), + entry: p.join('..', 'fixtures', '_testPackageSound', 'web', 'main.dart'), path: 'index.html', pathToServe: 'web'); From 78ddf72887436c557e2154c3b9105e734d582248 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Fri, 9 Dec 2022 09:31:35 -0800 Subject: [PATCH 03/36] Tried to fix third test --- dwds/test/dart_uri_file_uri_test.dart | 14 +++++++------- dwds/test/fixtures/context.dart | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dwds/test/dart_uri_file_uri_test.dart b/dwds/test/dart_uri_file_uri_test.dart index 80825dacc..3e5ff59cf 100644 --- a/dwds/test/dart_uri_file_uri_test.dart +++ b/dwds/test/dart_uri_file_uri_test.dart @@ -12,15 +12,15 @@ import 'package:test/test.dart'; import 'fixtures/context.dart'; final context = TestContext( - directory: p.join('..', 'fixtures', '_testPackage'), - entry: p.join('..', 'fixtures', '_testPackage', 'web', 'main.dart'), + directory: p.join('..', 'fixtures', '_testPackageSound'), + entry: p.join('..', 'fixtures', '_testPackageSound', 'web', 'main.dart'), path: 'index.html', pathToServe: 'web'); final dwdsDir = Directory.current.absolute.path; /// The directory for the general _test package. -final testDir = p.join(p.dirname(dwdsDir), 'fixtures', '_test'); +final testDir = p.join(p.dirname(dwdsDir), 'fixtures', '_testSound'); /// The directory for the _testPackage package (contained within dwds), which /// imports _test. @@ -43,14 +43,14 @@ void main() { final serverPath = compilationMode == CompilationMode.frontendServer && useDebuggerModuleNames - ? 'packages/_testPackage/lib/test_library.dart' - : 'packages/_test_package/test_library.dart'; + ? 'packages/_testPackageSound/lib/test_library.dart' + : 'packages/_test_package_sound/test_library.dart'; final anotherServerPath = compilationMode == CompilationMode.frontendServer && useDebuggerModuleNames - ? 'packages/_test/lib/library.dart' - : 'packages/_test/library.dart'; + ? 'packages/_testSound/lib/library.dart' + : 'packages/_test_sound/library.dart'; setUpAll(() async { await context.setUp( diff --git a/dwds/test/fixtures/context.dart b/dwds/test/fixtures/context.dart index 2fbaef572..88aac2e71 100644 --- a/dwds/test/fixtures/context.dart +++ b/dwds/test/fixtures/context.dart @@ -156,7 +156,7 @@ class TestContext { bool waitToDebug = false, UrlEncoder? urlEncoder, CompilationMode compilationMode = CompilationMode.buildDaemon, - NullSafety nullSafety = NullSafety.weak, + NullSafety nullSafety = NullSafety.sound, bool enableExpressionEvaluation = false, bool verboseCompiler = false, SdkConfigurationProvider? sdkConfigurationProvider, From 106fb392cf7335393b52e5b4a6052ea4077248ae Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Fri, 9 Dec 2022 10:32:35 -0800 Subject: [PATCH 04/36] Trying to fix test again --- frontend_server_common/lib/src/devfs.dart | 10 ++++++++-- frontend_server_common/pubspec.yaml | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/frontend_server_common/lib/src/devfs.dart b/frontend_server_common/lib/src/devfs.dart index 25cd5c5ac..b94c7b564 100644 --- a/frontend_server_common/lib/src/devfs.dart +++ b/frontend_server_common/lib/src/devfs.dart @@ -3,10 +3,12 @@ // found in the LICENSE file. // Note: this is a copy from flutter tools, updated to work with dwds tests +import 'dart:io'; import 'package:dwds/asset_reader.dart'; import 'package:file/file.dart'; import 'package:path/path.dart' as p; +import 'package:pub_semver/pub_semver.dart'; import 'asset_server.dart'; import 'bootstrap.dart'; @@ -85,9 +87,13 @@ class WebDevFS { assetServer.writeFile('main_module.digests', '{}'); - var sdk = soundNullSafety ? dartSdkSound : dartSdk; + final sdkVersion = Version.parse(Platform.version.split(' ')[0]); + var sdk = + (soundNullSafety && sdkVersion.major < 3) ? dartSdkSound : dartSdk; var sdkSourceMap = - soundNullSafety ? dartSdkSourcemapSound : dartSdkSourcemap; + (soundNullSafety && sdkVersion.major < 3) + ? dartSdkSourcemapSound + : dartSdkSourcemap; assetServer.writeFile('dart_sdk.js', sdk.readAsStringSync()); assetServer.writeFile('dart_sdk.js.map', sdkSourceMap.readAsStringSync()); diff --git a/frontend_server_common/pubspec.yaml b/frontend_server_common/pubspec.yaml index 1d063dfa4..37ba0110e 100644 --- a/frontend_server_common/pubspec.yaml +++ b/frontend_server_common/pubspec.yaml @@ -15,4 +15,5 @@ dependencies: shelf: ^1.1.4 package_config: ^2.0.0 path: ^1.8.0 + pub_semver: ^2.1.1 usage: ^4.0.0 From a2e26f8da43e50be0e7467f77155a7261e4bdf07 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Fri, 9 Dec 2022 10:39:01 -0800 Subject: [PATCH 05/36] Trying to fix more tests --- dwds/test/fixtures/context.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dwds/test/fixtures/context.dart b/dwds/test/fixtures/context.dart index 88aac2e71..c75cd0e9f 100644 --- a/dwds/test/fixtures/context.dart +++ b/dwds/test/fixtures/context.dart @@ -117,10 +117,10 @@ class TestContext { String? entry, this.path = 'hello_world/index.html', this.pathToServe = 'example'}) { - final relativeDirectory = p.join('..', 'fixtures', '_test'); + final relativeDirectory = p.join('..', 'fixtures', '_testSound'); final relativeEntry = p.join( - '..', 'fixtures', '_test', 'example', 'append_body', 'main.dart'); + '..', 'fixtures', '_testSound', 'example', 'append_body', 'main.dart'); workingDirectory = p.normalize(p .absolute(directory ?? p.relative(relativeDirectory, from: p.current))); From c18a336b516d7d1d03b12a67c1877369e9407158 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Fri, 9 Dec 2022 10:43:52 -0800 Subject: [PATCH 06/36] More fixes --- dwds/test/frontend_server_breakpoint_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dwds/test/frontend_server_breakpoint_test.dart b/dwds/test/frontend_server_breakpoint_test.dart index 1e9bd996b..ffae2157a 100644 --- a/dwds/test/frontend_server_breakpoint_test.dart +++ b/dwds/test/frontend_server_breakpoint_test.dart @@ -16,8 +16,8 @@ import 'fixtures/context.dart'; import 'fixtures/logging.dart'; final context = TestContext( - directory: p.join('..', 'fixtures', '_testPackage'), - entry: p.join('..', 'fixtures', '_testPackage', 'web', 'main.dart'), + directory: p.join('..', 'fixtures', '_testPackageSound'), + entry: p.join('..', 'fixtures', '_testPackageSound', 'web', 'main.dart'), path: 'index.html', pathToServe: 'web'); From 35f440e0d4fe84d069a511663c27280979fe9cf5 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Fri, 9 Dec 2022 10:50:20 -0800 Subject: [PATCH 07/36] Fix another test - skipping in null-safety due to https://github.com/dart-lang/webdev/issues/1591 --- dwds/test/frontend_server_circular_evaluate_test.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dwds/test/frontend_server_circular_evaluate_test.dart b/dwds/test/frontend_server_circular_evaluate_test.dart index 448f83280..9453bae12 100644 --- a/dwds/test/frontend_server_circular_evaluate_test.dart +++ b/dwds/test/frontend_server_circular_evaluate_test.dart @@ -20,9 +20,13 @@ void main() async { final debuggerModuleNamesSupported = Version.parse(Platform.version.split(' ').first) >= Version.parse('2.19.0-150.0.dev'); + final sdkVersion = Version.parse(Platform.version.split(' ')[0]); + final nullSafetyValues = (sdkVersion.major >= 3) + ? [NullSafety.sound] + : [NullSafety.sound, NullSafety.weak]; group('Context with circular dependencies |', () { - for (var nullSafety in NullSafety.values) { + for (var nullSafety in nullSafetyValues) { group('${nullSafety.name} null safety |', () { for (var indexBaseMode in IndexBaseMode.values) { group( From d344798c59b5ea6a6acda7a0f0145e97490c1f7f Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Fri, 9 Dec 2022 10:51:09 -0800 Subject: [PATCH 08/36] Format --- frontend_server_common/lib/src/devfs.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend_server_common/lib/src/devfs.dart b/frontend_server_common/lib/src/devfs.dart index b94c7b564..37f4321be 100644 --- a/frontend_server_common/lib/src/devfs.dart +++ b/frontend_server_common/lib/src/devfs.dart @@ -90,8 +90,7 @@ class WebDevFS { final sdkVersion = Version.parse(Platform.version.split(' ')[0]); var sdk = (soundNullSafety && sdkVersion.major < 3) ? dartSdkSound : dartSdk; - var sdkSourceMap = - (soundNullSafety && sdkVersion.major < 3) + var sdkSourceMap = (soundNullSafety && sdkVersion.major < 3) ? dartSdkSourcemapSound : dartSdkSourcemap; assetServer.writeFile('dart_sdk.js', sdk.readAsStringSync()); From 225fe4cadc64c7c9ada4d052c02313a0c4bd9fef Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Fri, 9 Dec 2022 10:56:54 -0800 Subject: [PATCH 09/36] Fix another test --- dwds/test/package_uri_mapper_test.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dwds/test/package_uri_mapper_test.dart b/dwds/test/package_uri_mapper_test.dart index e6e6d3e3e..364b79ac4 100644 --- a/dwds/test/package_uri_mapper_test.dart +++ b/dwds/test/package_uri_mapper_test.dart @@ -17,19 +17,19 @@ void main() { final fileSystem = LocalFileSystem(); final packageUri = - Uri(scheme: 'package', path: '_test_package/test_library.dart'); + Uri(scheme: 'package', path: '_test_package_sound/test_library.dart'); final serverPath = useDebuggerModuleNames - ? 'packages/_testPackage/lib/test_library.dart' - : '/packages/_test_package/test_library.dart'; + ? 'packages/_testPackageSound/lib/test_library.dart' + : '/packages/_test_package_sound/test_library.dart'; final resolvedPath = - '/webdev/fixtures/_testPackage/lib/test_library.dart'; + '/webdev/fixtures/_testPackageSound/lib/test_library.dart'; final packageConfigFile = Uri.file(p.normalize(p.absolute(p.join( '..', 'fixtures', - '_testPackage', + '_testPackageSound', '.dart_tool', 'package_config.json', )))); From c82d50194c4025025c159fe0cb19431138dec601 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Fri, 9 Dec 2022 12:17:53 -0800 Subject: [PATCH 10/36] Frontend server and sound null-safety are incompatible --- dwds/test/build_daemon_callstack_test.dart | 9 +- .../build_daemon_circular_evaluate_test.dart | 10 +- dwds/test/dart_uri_file_uri_test.dart | 114 ++++++++++-------- dwds/test/evaluate_circular_common.dart | 18 +-- dwds/test/evaluate_common.dart | 11 +- dwds/test/fixtures/context.dart | 28 +++-- dwds/test/frontend_server_callstack_test.dart | 21 ++-- ...rontend_server_circular_evaluate_test.dart | 7 +- dwds/test/utils/version_compatibility.dart | 27 +++++ 9 files changed, 151 insertions(+), 94 deletions(-) create mode 100644 dwds/test/utils/version_compatibility.dart diff --git a/dwds/test/build_daemon_callstack_test.dart b/dwds/test/build_daemon_callstack_test.dart index f03c059b3..4ca2acfeb 100644 --- a/dwds/test/build_daemon_callstack_test.dart +++ b/dwds/test/build_daemon_callstack_test.dart @@ -20,13 +20,17 @@ class TestSetup { directory: p.join('..', 'fixtures', '_testPackage'), entry: p.join('..', 'fixtures', '_testPackage', 'web', 'main.dart'), path: 'index.html', - pathToServe: 'web'); + pathToServe: 'web', + nullSafety: NullSafety.weak, + ); static final contextSound = TestContext( directory: p.join('..', 'fixtures', '_testPackageSound'), entry: p.join('..', 'fixtures', '_testPackageSound', 'web', 'main.dart'), path: 'index.html', - pathToServe: 'web'); + pathToServe: 'web', + nullSafety: NullSafety.sound, + ); TestContext context; @@ -54,7 +58,6 @@ void main() { setCurrentLogWriter(debug: debug); await context.setUp( compilationMode: CompilationMode.buildDaemon, - nullSafety: nullSafety, enableExpressionEvaluation: true, verboseCompiler: debug, ); diff --git a/dwds/test/build_daemon_circular_evaluate_test.dart b/dwds/test/build_daemon_circular_evaluate_test.dart index c928fe44b..646b2317e 100644 --- a/dwds/test/build_daemon_circular_evaluate_test.dart +++ b/dwds/test/build_daemon_circular_evaluate_test.dart @@ -3,23 +3,19 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') -import 'dart:io'; -import 'package:pub_semver/pub_semver.dart'; import 'package:test/test.dart'; import 'fixtures/context.dart'; import 'evaluate_circular_common.dart'; +import 'utils/version_compatibility.dart'; + void main() async { // Enable verbose logging for debugging. final debug = false; - final sdkVersion = Version.parse(Platform.version.split(' ')[0]); - final nullSafetyValues = (sdkVersion.major >= 3) - ? [NullSafety.sound] - : [NullSafety.sound, NullSafety.weak]; - for (var nullSafety in nullSafetyValues) { + for (var nullSafety in supportedNullSafetyModes()) { group('${nullSafety.name} null safety |', () { testAll( compilationMode: CompilationMode.buildDaemon, diff --git a/dwds/test/dart_uri_file_uri_test.dart b/dwds/test/dart_uri_file_uri_test.dart index 3e5ff59cf..8c32ce33d 100644 --- a/dwds/test/dart_uri_file_uri_test.dart +++ b/dwds/test/dart_uri_file_uri_test.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') +@Timeout(Duration(seconds: 60)) import 'dart:io'; import 'package:dwds/src/utilities/dart_uri.dart'; @@ -10,6 +11,7 @@ import 'package:path/path.dart' as p; import 'package:test/test.dart'; import 'fixtures/context.dart'; +import 'utils/version_compatibility.dart'; final context = TestContext( directory: p.join('..', 'fixtures', '_testPackageSound'), @@ -31,59 +33,73 @@ final testPackageDir = context.workingDirectory; // These tests are separated out because we need a running isolate in order to // look up packages. void main() { - for (final compilationMode in CompilationMode.values) { - group('$compilationMode |', () { - for (final useDebuggerModuleNames in [false, true]) { - group('Debugger module names: $useDebuggerModuleNames |', () { - final appServerPath = - compilationMode == CompilationMode.frontendServer - ? 'web/main.dart' - : 'main.dart'; - - final serverPath = - compilationMode == CompilationMode.frontendServer && - useDebuggerModuleNames - ? 'packages/_testPackageSound/lib/test_library.dart' - : 'packages/_test_package_sound/test_library.dart'; - - final anotherServerPath = - compilationMode == CompilationMode.frontendServer && - useDebuggerModuleNames - ? 'packages/_testSound/lib/library.dart' - : 'packages/_test_sound/library.dart'; - - setUpAll(() async { - await context.setUp( - compilationMode: compilationMode, - useDebuggerModuleNames: useDebuggerModuleNames, - ); - }); + for (final nullSafetyMode in supportedNullSafetyModes()) { + for (final compilationMode in supportedCompilationModes(nullSafetyMode)) { + group('$compilationMode |', () { + for (final useDebuggerModuleNames in [false, true]) { + group('Debugger module names: $useDebuggerModuleNames |', () { + final appServerPath = + compilationMode == CompilationMode.frontendServer + ? 'web/main.dart' + : 'main.dart'; - tearDownAll(() async { - await context.tearDown(); - }); + final packageNameForFrontendServer = + nullSafetyMode == NullSafety.sound + ? '_testPackageSound' + : '_testPackage'; + final packageNameForBuildDaemon = nullSafetyMode == NullSafety.sound + ? '_test_package_sound' + : '_test_package'; + final anotherPackageNameForFrontendServer = + nullSafetyMode == NullSafety.sound ? '_testSound' : '_test'; + final anotherPackageNameForBuildDaemon = + nullSafetyMode == NullSafety.sound ? '_test_sound' : '_test'; - test('file path to org-dartlang-app', () { - final webMain = - Uri.file(p.join(testPackageDir, 'web', 'main.dart')); - final uri = DartUri('$webMain'); - expect(uri.serverPath, appServerPath); - }); + final serverPath = compilationMode == + CompilationMode.frontendServer && + useDebuggerModuleNames + ? 'packages/$packageNameForFrontendServer/lib/test_library.dart' + : 'packages/$packageNameForBuildDaemon/test_library.dart'; - test('file path to this package', () { - final testPackageLib = - Uri.file(p.join(testPackageDir, 'lib', 'test_library.dart')); - final uri = DartUri('$testPackageLib'); - expect(uri.serverPath, serverPath); - }); + final anotherServerPath = compilationMode == + CompilationMode.frontendServer && + useDebuggerModuleNames + ? 'packages/$anotherPackageNameForFrontendServer/lib/library.dart' + : 'packages/$anotherPackageNameForBuildDaemon/library.dart'; + + setUpAll(() async { + await context.setUp( + compilationMode: compilationMode, + useDebuggerModuleNames: useDebuggerModuleNames, + ); + }); + + tearDownAll(() async { + await context.tearDown(); + }); + + test('file path to org-dartlang-app', () { + final webMain = + Uri.file(p.join(testPackageDir, 'web', 'main.dart')); + final uri = DartUri('$webMain'); + expect(uri.serverPath, appServerPath); + }); + + test('file path to this package', () { + final testPackageLib = + Uri.file(p.join(testPackageDir, 'lib', 'test_library.dart')); + final uri = DartUri('$testPackageLib'); + expect(uri.serverPath, serverPath); + }); - test('file path to another package', () { - final testLib = Uri.file(p.join(testDir, 'lib', 'library.dart')); - final dartUri = DartUri('$testLib'); - expect(dartUri.serverPath, anotherServerPath); + test('file path to another package', () { + final testLib = Uri.file(p.join(testDir, 'lib', 'library.dart')); + final dartUri = DartUri('$testLib'); + expect(dartUri.serverPath, anotherServerPath); + }); }); - }); - } - }); + } + }); + } } } diff --git a/dwds/test/evaluate_circular_common.dart b/dwds/test/evaluate_circular_common.dart index 0de304df4..f633badc5 100644 --- a/dwds/test/evaluate_circular_common.dart +++ b/dwds/test/evaluate_circular_common.dart @@ -16,18 +16,21 @@ import 'fixtures/context.dart'; import 'fixtures/logging.dart'; class TestSetup { - static TestContext createContext(String index, String packageRoot) => + static TestContext createContext( + String index, String packageRoot, NullSafety nullSafety) => TestContext( - directory: p.join('..', 'fixtures', packageRoot), - entry: p.join('..', 'fixtures', packageRoot, 'web', 'main.dart'), - path: index, - pathToServe: 'web'); + directory: p.join('..', 'fixtures', packageRoot), + entry: p.join('..', 'fixtures', packageRoot, 'web', 'main.dart'), + path: index, + pathToServe: 'web', + nullSafety: nullSafety, + ); static TestContext contextUnsound(String index) => - createContext(index, '_testCircular2'); + createContext(index, '_testCircular2', NullSafety.weak); static TestContext contextSound(String index) => - createContext(index, '_testCircular2Sound'); + createContext(index, '_testCircular2Sound', NullSafety.sound); TestContext context; @@ -87,7 +90,6 @@ void testAll({ setCurrentLogWriter(debug: debug); await context.setUp( compilationMode: compilationMode, - nullSafety: nullSafety, enableExpressionEvaluation: true, useDebuggerModuleNames: useDebuggerModuleNames, verboseCompiler: debug, diff --git a/dwds/test/evaluate_common.dart b/dwds/test/evaluate_common.dart index 908158e18..c10ed1a60 100644 --- a/dwds/test/evaluate_common.dart +++ b/dwds/test/evaluate_common.dart @@ -16,18 +16,20 @@ import 'fixtures/context.dart'; import 'fixtures/logging.dart'; class TestSetup { - static TestContext createContext(String index, String packageRoot) => + static TestContext createContext( + String index, String packageRoot, NullSafety nullSafety) => TestContext( directory: p.join('..', 'fixtures', packageRoot), entry: p.join('..', 'fixtures', packageRoot, 'web', 'main.dart'), path: index, - pathToServe: 'web'); + pathToServe: 'web', + nullSafety: nullSafety); static TestContext contextUnsound(String index) => - createContext(index, '_testPackage'); + createContext(index, '_testPackage', NullSafety.weak); static TestContext contextSound(String index) => - createContext(index, '_testPackageSound'); + createContext(index, '_testPackageSound', NullSafety.sound); TestContext context; @@ -87,7 +89,6 @@ void testAll({ setCurrentLogWriter(debug: debug); await context.setUp( compilationMode: compilationMode, - nullSafety: nullSafety, enableExpressionEvaluation: true, useDebuggerModuleNames: useDebuggerModuleNames, verboseCompiler: debug, diff --git a/dwds/test/fixtures/context.dart b/dwds/test/fixtures/context.dart index c75cd0e9f..07144df7e 100644 --- a/dwds/test/fixtures/context.dart +++ b/dwds/test/fixtures/context.dart @@ -112,15 +112,20 @@ class TestContext { /// The path part of the application URL. String path; - TestContext( - {String? directory, - String? entry, - this.path = 'hello_world/index.html', - this.pathToServe = 'example'}) { - final relativeDirectory = p.join('..', 'fixtures', '_testSound'); + NullSafety nullSafety; + + TestContext({ + String? directory, + String? entry, + this.nullSafety = NullSafety.sound, + this.path = 'hello_world/index.html', + this.pathToServe = 'example', + }) { + final packageName = nullSafety == NullSafety.sound ? '_testSound' : '_test'; + final relativeDirectory = p.join('..', 'fixtures', packageName); final relativeEntry = p.join( - '..', 'fixtures', '_testSound', 'example', 'append_body', 'main.dart'); + '..', 'fixtures', packageName, 'example', 'append_body', 'main.dart'); workingDirectory = p.normalize(p .absolute(directory ?? p.relative(relativeDirectory, from: p.current))); @@ -156,7 +161,6 @@ class TestContext { bool waitToDebug = false, UrlEncoder? urlEncoder, CompilationMode compilationMode = CompilationMode.buildDaemon, - NullSafety nullSafety = NullSafety.sound, bool enableExpressionEvaluation = false, bool verboseCompiler = false, SdkConfigurationProvider? sdkConfigurationProvider, @@ -165,6 +169,14 @@ class TestContext { bool isFlutterApp = false, bool isInternalBuild = false, }) async { + // TODO(https://github.com/dart-lang/webdev/issues/1591): Support compiling + // with sound null-safety in Frontend Server. + if (compilationMode == CompilationMode.frontendServer && + nullSafety == NullSafety.sound) { + throw Exception( + 'Frontend Server compilation does not support sound null-safety. See https://github.com/dart-lang/webdev/issues/1591'); + } + sdkConfigurationProvider ??= DefaultSdkConfigurationProvider(); try { diff --git a/dwds/test/frontend_server_callstack_test.dart b/dwds/test/frontend_server_callstack_test.dart index e3b0e1b62..6b5af21ef 100644 --- a/dwds/test/frontend_server_callstack_test.dart +++ b/dwds/test/frontend_server_callstack_test.dart @@ -17,16 +17,20 @@ import 'fixtures/logging.dart'; class TestSetup { static final contextUnsound = TestContext( - directory: p.join('..', 'fixtures', '_testPackage'), - entry: p.join('..', 'fixtures', '_testPackage', 'web', 'main.dart'), - path: 'index.html', - pathToServe: 'web'); + directory: p.join('..', 'fixtures', '_testPackage'), + entry: p.join('..', 'fixtures', '_testPackage', 'web', 'main.dart'), + path: 'index.html', + pathToServe: 'web', + nullSafety: NullSafety.weak, + ); static final contextSound = TestContext( - directory: p.join('..', 'fixtures', '_testPackageSound'), - entry: p.join('..', 'fixtures', '_testPackageSound', 'web', 'main.dart'), - path: 'index.html', - pathToServe: 'web'); + directory: p.join('..', 'fixtures', '_testPackageSound'), + entry: p.join('..', 'fixtures', '_testPackageSound', 'web', 'main.dart'), + path: 'index.html', + pathToServe: 'web', + nullSafety: NullSafety.sound, + ); TestContext context; @@ -54,7 +58,6 @@ void main() { setCurrentLogWriter(debug: debug); await context.setUp( compilationMode: CompilationMode.frontendServer, - nullSafety: nullSafety, enableExpressionEvaluation: true, verboseCompiler: debug); }); diff --git a/dwds/test/frontend_server_circular_evaluate_test.dart b/dwds/test/frontend_server_circular_evaluate_test.dart index 9453bae12..c49269a02 100644 --- a/dwds/test/frontend_server_circular_evaluate_test.dart +++ b/dwds/test/frontend_server_circular_evaluate_test.dart @@ -11,6 +11,7 @@ import 'package:test/test.dart'; import 'fixtures/context.dart'; import 'evaluate_circular_common.dart'; +import 'utils/version_compatibility.dart'; void main() async { // Enable verbose logging for debugging. @@ -20,13 +21,9 @@ void main() async { final debuggerModuleNamesSupported = Version.parse(Platform.version.split(' ').first) >= Version.parse('2.19.0-150.0.dev'); - final sdkVersion = Version.parse(Platform.version.split(' ')[0]); - final nullSafetyValues = (sdkVersion.major >= 3) - ? [NullSafety.sound] - : [NullSafety.sound, NullSafety.weak]; group('Context with circular dependencies |', () { - for (var nullSafety in nullSafetyValues) { + for (var nullSafety in supportedNullSafetyModes()) { group('${nullSafety.name} null safety |', () { for (var indexBaseMode in IndexBaseMode.values) { group( diff --git a/dwds/test/utils/version_compatibility.dart b/dwds/test/utils/version_compatibility.dart new file mode 100644 index 000000000..0c239dfa3 --- /dev/null +++ b/dwds/test/utils/version_compatibility.dart @@ -0,0 +1,27 @@ +// Copyright (c) 2022, 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:pub_semver/pub_semver.dart'; + +import '../fixtures/context.dart'; + +List supportedNullSafetyModes() { + final sdkVersion = Version.parse(Platform.version.split(' ')[0]); + return (sdkVersion.major >= 3) + ? [NullSafety.sound] + : [NullSafety.sound, NullSafety.weak]; +} + +// TODO(https://github.com/dart-lang/webdev/issues/1591): Frontend server +// compilation is currently incompatible with sound null safety. +List supportedCompilationModes(NullSafety nullSafetyMode) { + return nullSafetyMode == NullSafety.sound + ? [CompilationMode.buildDaemon] + : [ + CompilationMode.buildDaemon, + CompilationMode.frontendServer, + ]; +} From 056d882c550830921cc5383252530e4480dbb86d Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Fri, 9 Dec 2022 12:24:01 -0800 Subject: [PATCH 11/36] Format --- dwds/test/build_daemon_callstack_test.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dwds/test/build_daemon_callstack_test.dart b/dwds/test/build_daemon_callstack_test.dart index 4ca2acfeb..b7b370a04 100644 --- a/dwds/test/build_daemon_callstack_test.dart +++ b/dwds/test/build_daemon_callstack_test.dart @@ -17,17 +17,17 @@ import 'fixtures/logging.dart'; class TestSetup { static final contextUnsound = TestContext( - directory: p.join('..', 'fixtures', '_testPackage'), - entry: p.join('..', 'fixtures', '_testPackage', 'web', 'main.dart'), - path: 'index.html', + directory: p.join('..', 'fixtures', '_testPackage'), + entry: p.join('..', 'fixtures', '_testPackage', 'web', 'main.dart'), + path: 'index.html', pathToServe: 'web', nullSafety: NullSafety.weak, ); static final contextSound = TestContext( - directory: p.join('..', 'fixtures', '_testPackageSound'), - entry: p.join('..', 'fixtures', '_testPackageSound', 'web', 'main.dart'), - path: 'index.html', + directory: p.join('..', 'fixtures', '_testPackageSound'), + entry: p.join('..', 'fixtures', '_testPackageSound', 'web', 'main.dart'), + path: 'index.html', pathToServe: 'web', nullSafety: NullSafety.sound, ); From 8f608530e474e850f55f1a0749c9f0716cbe46ba Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Fri, 9 Dec 2022 12:28:15 -0800 Subject: [PATCH 12/36] Fix analyze error --- dwds/test/evaluate_common.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/dwds/test/evaluate_common.dart b/dwds/test/evaluate_common.dart index c10ed1a60..e0829d4ae 100644 --- a/dwds/test/evaluate_common.dart +++ b/dwds/test/evaluate_common.dart @@ -634,7 +634,6 @@ void testAll({ setCurrentLogWriter(debug: debug); await context.setUp( compilationMode: compilationMode, - nullSafety: nullSafety, enableExpressionEvaluation: false, verboseCompiler: debug, ); From a956aa3e6f83d121a6f0bfca3792aa3f2fd1b00e Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Fri, 9 Dec 2022 14:58:32 -0800 Subject: [PATCH 13/36] Fix a few more tests --- dwds/test/build_daemon_callstack_test.dart | 3 +- dwds/test/build_daemon_evaluate_test.dart | 3 +- dwds/test/chrome_proxy_service_test.dart | 20 +- .../test/frontend_server_breakpoint_test.dart | 191 +++++++++--------- 4 files changed, 109 insertions(+), 108 deletions(-) diff --git a/dwds/test/build_daemon_callstack_test.dart b/dwds/test/build_daemon_callstack_test.dart index b7b370a04..1d8f9ba33 100644 --- a/dwds/test/build_daemon_callstack_test.dart +++ b/dwds/test/build_daemon_callstack_test.dart @@ -14,6 +14,7 @@ import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'; import 'fixtures/context.dart'; import 'fixtures/logging.dart'; +import 'utils/version_compatibility.dart'; class TestSetup { static final contextUnsound = TestContext( @@ -48,7 +49,7 @@ void main() { // Enable verbose logging for debugging. final debug = false; - for (var nullSafety in NullSafety.values) { + for (var nullSafety in supportedNullSafetyModes()) { final soundNullSafety = nullSafety == NullSafety.sound; final setup = soundNullSafety ? TestSetup.sound() : TestSetup.unsound(); final context = setup.context; diff --git a/dwds/test/build_daemon_evaluate_test.dart b/dwds/test/build_daemon_evaluate_test.dart index f85b0de46..63c27d9bb 100644 --- a/dwds/test/build_daemon_evaluate_test.dart +++ b/dwds/test/build_daemon_evaluate_test.dart @@ -8,12 +8,13 @@ import 'package:test/test.dart'; import 'fixtures/context.dart'; import 'evaluate_common.dart'; +import 'utils/version_compatibility.dart'; void main() async { // Enable verbose logging for debugging. final debug = false; - for (var nullSafety in NullSafety.values) { + for (var nullSafety in supportedNullSafetyModes()) { group('${nullSafety.name} null safety |', () { testAll( compilationMode: CompilationMode.buildDaemon, diff --git a/dwds/test/chrome_proxy_service_test.dart b/dwds/test/chrome_proxy_service_test.dart index eae7a3fe5..a9c4abe7e 100644 --- a/dwds/test/chrome_proxy_service_test.dart +++ b/dwds/test/chrome_proxy_service_test.dart @@ -20,6 +20,7 @@ import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'; import 'fixtures/context.dart'; import 'fixtures/logging.dart'; +import 'utils/version_compatibility.dart'; final context = TestContext(); @@ -126,7 +127,7 @@ void main() { test('addBreakpointWithScriptUri absolute file URI', () async { final current = context.workingDirectory; - final test = path.join(path.dirname(current), '_test'); + final test = path.join(path.dirname(current), '_testSound'); final scriptPath = Uri.parse(mainScript.uri!).path.substring(1); final fullPath = path.join(test, scriptPath); final fileUri = Uri.file(fullPath); @@ -471,7 +472,7 @@ void main() { isolate.id!, rootLibrary!.classes!.first.id!) as Class; expect( testClass.functions, - unorderedEquals([ + containsAll([ predicate( (FuncRef f) => f.name == 'staticHello' && f.isStatic!), predicate((FuncRef f) => f.name == 'message' && !f.isStatic!), @@ -612,15 +613,6 @@ void main() { expect(obj.valueAsString, '42'); }); - test('null', () async { - final ref = await service.evaluate( - isolate.id!, bootstrap!.id!, 'helloNum(null)') as InstanceRef; - final obj = await service.getObject(isolate.id!, ref.id!) as Instance; - expect(obj.kind, InstanceKind.kNull); - expect(obj.classRef!.name, 'Null'); - expect(obj.valueAsString, 'null'); - }); - test('Scripts', () async { final scripts = await service.getScripts(isolate.id!); assert(scripts.scripts!.isNotEmpty); @@ -860,8 +852,8 @@ void main() { // Containts part files as well. expect(scriptUris, contains(endsWith('part.dart'))); - expect(scriptUris, - contains('package:intl/src/intl/date_format_helpers.dart')); + expect( + scriptUris, contains('package:intl/src/date_format_internal.dart')); }); group('getSourceReport', () { @@ -1368,7 +1360,7 @@ void main() { expect( resolvedUris.uris, containsAll([ - contains('/_test/example/hello_world/main.dart'), + contains('/_testSound/example/hello_world/main.dart'), contains('/lib/path.dart'), contains('/lib/src/path_set.dart'), ])); diff --git a/dwds/test/frontend_server_breakpoint_test.dart b/dwds/test/frontend_server_breakpoint_test.dart index ffae2157a..d44359f05 100644 --- a/dwds/test/frontend_server_breakpoint_test.dart +++ b/dwds/test/frontend_server_breakpoint_test.dart @@ -14,12 +14,15 @@ import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'; import 'fixtures/context.dart'; import 'fixtures/logging.dart'; +import 'utils/version_compatibility.dart'; final context = TestContext( - directory: p.join('..', 'fixtures', '_testPackageSound'), - entry: p.join('..', 'fixtures', '_testPackageSound', 'web', 'main.dart'), - path: 'index.html', - pathToServe: 'web'); + directory: p.join('..', 'fixtures', '_testSound'), + entry: p.join('..', 'fixtures', '_testSound', 'web', 'main.dart'), + path: 'index.html', + pathToServe: 'web', + nullSafety: NullSafety.weak, +); ChromeProxyService get service => fetchChromeProxyService(context.debugConnection); @@ -36,99 +39,103 @@ void main() { // regardless of the logger settings. final verboseCompiler = false; - group('shared context', () { - setUpAll(() async { - setCurrentLogWriter(debug: debug); - await context.setUp( - compilationMode: CompilationMode.frontendServer, - verboseCompiler: verboseCompiler, - ); - }); - - tearDownAll(() async { - await context.tearDown(); - }); - - group('breakpoint', () { - VM vm; - late Isolate isolate; - late String isolateId; - ScriptList scripts; - late ScriptRef mainScript; - late String mainScriptUri; - late Stream stream; - - setUp(() async { + // TODO(https://github.com/dart-lang/webdev/issues/1591): Frontend server + // compilation is currently incompatible with sound null safety. + if (supportedNullSafetyModes().contains(NullSafety.weak)) { + group('shared context', () { + setUpAll(() async { setCurrentLogWriter(debug: debug); - vm = await service.getVM(); - isolate = await service.getIsolate(vm.isolates!.first.id!); - isolateId = isolate.id!; - scripts = await service.getScripts(isolateId); - - await service.streamListen('Debug'); - stream = service.onEvent('Debug'); - - mainScript = scripts.scripts! - .firstWhere((each) => each.uri!.contains('main.dart')); - mainScriptUri = mainScript.uri!; - }); - - tearDown(() async { - await service.resume(isolateId); + await context.setUp( + compilationMode: CompilationMode.frontendServer, + verboseCompiler: verboseCompiler, + ); }); - test('set breakpoint', () async { - final line = await context.findBreakpointLine( - 'printLocal', isolateId, mainScript); - final bp = await service.addBreakpointWithScriptUri( - isolateId, mainScriptUri, 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(isolateId, bp.id!); - }); - - test('set breakpoint again', () async { - final line = await context.findBreakpointLine( - 'printLocal', isolateId, mainScript); - final bp = await service.addBreakpointWithScriptUri( - isolateId, mainScriptUri, 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(isolateId, bp.id!); + tearDownAll(() async { + await context.tearDown(); }); - test('set breakpoint inside a JavaScript line succeeds', () async { - final line = await context.findBreakpointLine( - 'printNestedObjectMultiLine', isolateId, mainScript); - final column = 0; - final bp = await service.addBreakpointWithScriptUri( - isolateId, mainScriptUri, line, - column: column); - - await stream.firstWhere( - (Event event) => event.kind == EventKind.kPauseBreakpoint); - - expect(bp, isNotNull); - expect( - bp.location, - isA() - .having((loc) => loc.script, 'script', equals(mainScript)) - .having((loc) => loc.line, 'line', equals(line)) - .having((loc) => loc.column, 'column', greaterThan(column))); - - // Remove breakpoint so it doesn't impact other tests. - await service.removeBreakpoint(isolateId, bp.id!); + group('breakpoint', () { + VM vm; + late Isolate isolate; + late String isolateId; + ScriptList scripts; + late ScriptRef mainScript; + late String mainScriptUri; + late Stream stream; + + setUp(() async { + setCurrentLogWriter(debug: debug); + vm = await service.getVM(); + isolate = await service.getIsolate(vm.isolates!.first.id!); + isolateId = isolate.id!; + scripts = await service.getScripts(isolateId); + + await service.streamListen('Debug'); + stream = service.onEvent('Debug'); + + mainScript = scripts.scripts! + .firstWhere((each) => each.uri!.contains('main.dart')); + mainScriptUri = mainScript.uri!; + }); + + tearDown(() async { + await service.resume(isolateId); + }); + + test('set breakpoint', () async { + final line = await context.findBreakpointLine( + 'printLocal', isolateId, mainScript); + final bp = await service.addBreakpointWithScriptUri( + isolateId, mainScriptUri, 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(isolateId, bp.id!); + }); + + test('set breakpoint again', () async { + final line = await context.findBreakpointLine( + 'printLocal', isolateId, mainScript); + final bp = await service.addBreakpointWithScriptUri( + isolateId, mainScriptUri, 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(isolateId, bp.id!); + }); + + test('set breakpoint inside a JavaScript line succeeds', () async { + final line = await context.findBreakpointLine( + 'printNestedObjectMultiLine', isolateId, mainScript); + final column = 0; + final bp = await service.addBreakpointWithScriptUri( + isolateId, mainScriptUri, line, + column: column); + + await stream.firstWhere( + (Event event) => event.kind == EventKind.kPauseBreakpoint); + + expect(bp, isNotNull); + expect( + bp.location, + isA() + .having((loc) => loc.script, 'script', equals(mainScript)) + .having((loc) => loc.line, 'line', equals(line)) + .having((loc) => loc.column, 'column', greaterThan(column))); + + // Remove breakpoint so it doesn't impact other tests. + await service.removeBreakpoint(isolateId, bp.id!); + }); }); }); - }); + } } From 1d75011cbbed7ed057a7fe8f9977ce3c067e589b Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Fri, 9 Dec 2022 15:07:15 -0800 Subject: [PATCH 14/36] fix analyzer errors --- dwds/test/chrome_proxy_service_test.dart | 1 - fixtures/_testCircular1Sound/pubspec.yaml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/dwds/test/chrome_proxy_service_test.dart b/dwds/test/chrome_proxy_service_test.dart index a9c4abe7e..124097452 100644 --- a/dwds/test/chrome_proxy_service_test.dart +++ b/dwds/test/chrome_proxy_service_test.dart @@ -20,7 +20,6 @@ import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'; import 'fixtures/context.dart'; import 'fixtures/logging.dart'; -import 'utils/version_compatibility.dart'; final context = TestContext(); diff --git a/fixtures/_testCircular1Sound/pubspec.yaml b/fixtures/_testCircular1Sound/pubspec.yaml index 5b6386c18..6a5741a6f 100644 --- a/fixtures/_testCircular1Sound/pubspec.yaml +++ b/fixtures/_testCircular1Sound/pubspec.yaml @@ -8,7 +8,7 @@ environment: sdk: '>=2.12.0 <3.0.0' dependencies: - intl: ^0.16.0 + intl: ^0.17.0 path: ^1.6.1 _test_circular2_sound: path: ../_testCircular2Sound From 37854810da2713476897c37b9d1e2067d3532ef2 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Fri, 9 Dec 2022 16:50:31 -0800 Subject: [PATCH 15/36] Update more tests --- dwds/test/build_daemon_callstack_test.dart | 2 +- .../build_daemon_circular_evaluate_test.dart | 2 +- dwds/test/build_daemon_evaluate_test.dart | 2 +- dwds/test/chrome_proxy_service_test.dart | 198 ++++++++---------- dwds/test/dart_uri_file_uri_test.dart | 2 +- dwds/test/events_test.dart | 2 +- .../test/frontend_server_breakpoint_test.dart | 2 +- dwds/test/frontend_server_callstack_test.dart | 3 +- ...rontend_server_circular_evaluate_test.dart | 2 +- dwds/test/frontend_server_evaluate_test.dart | 3 +- .../proxy_server_asset_reader_test.dart | 7 +- dwds/test/utils/version_compatibility.dart | 12 +- 12 files changed, 112 insertions(+), 125 deletions(-) diff --git a/dwds/test/build_daemon_callstack_test.dart b/dwds/test/build_daemon_callstack_test.dart index 1d8f9ba33..939bef7a8 100644 --- a/dwds/test/build_daemon_callstack_test.dart +++ b/dwds/test/build_daemon_callstack_test.dart @@ -49,7 +49,7 @@ void main() { // Enable verbose logging for debugging. final debug = false; - for (var nullSafety in supportedNullSafetyModes()) { + for (var nullSafety in supportedNullSafetyModes) { final soundNullSafety = nullSafety == NullSafety.sound; final setup = soundNullSafety ? TestSetup.sound() : TestSetup.unsound(); final context = setup.context; diff --git a/dwds/test/build_daemon_circular_evaluate_test.dart b/dwds/test/build_daemon_circular_evaluate_test.dart index 646b2317e..513465fcf 100644 --- a/dwds/test/build_daemon_circular_evaluate_test.dart +++ b/dwds/test/build_daemon_circular_evaluate_test.dart @@ -15,7 +15,7 @@ void main() async { // Enable verbose logging for debugging. final debug = false; - for (var nullSafety in supportedNullSafetyModes()) { + for (var nullSafety in supportedNullSafetyModes) { group('${nullSafety.name} null safety |', () { testAll( compilationMode: CompilationMode.buildDaemon, diff --git a/dwds/test/build_daemon_evaluate_test.dart b/dwds/test/build_daemon_evaluate_test.dart index 63c27d9bb..845cec737 100644 --- a/dwds/test/build_daemon_evaluate_test.dart +++ b/dwds/test/build_daemon_evaluate_test.dart @@ -14,7 +14,7 @@ void main() async { // Enable verbose logging for debugging. final debug = false; - for (var nullSafety in supportedNullSafetyModes()) { + for (var nullSafety in supportedNullSafetyModes) { group('${nullSafety.name} null safety |', () { testAll( compilationMode: CompilationMode.buildDaemon, diff --git a/dwds/test/chrome_proxy_service_test.dart b/dwds/test/chrome_proxy_service_test.dart index 124097452..ec51a5057 100644 --- a/dwds/test/chrome_proxy_service_test.dart +++ b/dwds/test/chrome_proxy_service_test.dart @@ -20,6 +20,7 @@ import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'; import 'fixtures/context.dart'; import 'fixtures/logging.dart'; +import 'utils/version_compatibility.dart'; final context = TestContext(); @@ -464,56 +465,47 @@ void main() { expect(library1, equals(library2)); }); - test( - 'Classes', - () async { - final testClass = await service.getObject( - isolate.id!, rootLibrary!.classes!.first.id!) as Class; - expect( - testClass.functions, - containsAll([ - predicate( - (FuncRef f) => f.name == 'staticHello' && f.isStatic!), - predicate((FuncRef f) => f.name == 'message' && !f.isStatic!), - predicate((FuncRef f) => f.name == 'notFinal' && !f.isStatic!), - predicate((FuncRef f) => f.name == 'hello' && !f.isStatic!), - predicate((FuncRef f) => f.name == '_equals' && !f.isStatic!), - predicate((FuncRef f) => f.name == 'hashCode' && !f.isStatic!), - predicate((FuncRef f) => f.name == 'toString' && !f.isStatic!), - predicate( - (FuncRef f) => f.name == 'noSuchMethod' && !f.isStatic!), - predicate( - (FuncRef f) => f.name == 'runtimeType' && !f.isStatic!), - ])); - expect( - testClass.fields, - unorderedEquals([ - predicate((FieldRef f) => - f.name == 'message' && - f.declaredType != null && - !f.isStatic! && - !f.isConst! && - f.isFinal!), - predicate((FieldRef f) => - f.name == 'notFinal' && - f.declaredType != null && - !f.isStatic! && - !f.isConst! && - !f.isFinal!), - predicate((FieldRef f) => - f.name == 'staticMessage' && - f.declaredType != null && - f.isStatic! && - !f.isConst! && - !f.isFinal!), - ])); - }, - // TODO(elliette): Remove once 2.15.0 is the stable release. - skip: semver.Version.parse(Platform.version.split(' ').first) >= - semver.Version.parse('2.15.0-268.18.beta') - ? null - : 'SDK does not expose static member information.', - ); + test('Classes', () async { + final testClass = await service.getObject( + isolate.id!, rootLibrary!.classes!.first.id!) as Class; + expect( + testClass.functions, + unorderedEquals([ + predicate((FuncRef f) => f.name == 'staticHello' && f.isStatic!), + predicate((FuncRef f) => f.name == 'message' && !f.isStatic!), + predicate((FuncRef f) => f.name == 'notFinal' && !f.isStatic!), + predicate((FuncRef f) => f.name == 'hello' && !f.isStatic!), + predicate((FuncRef f) => f.name == '_equals' && !f.isStatic!), + predicate((FuncRef f) => f.name == 'hashCode' && !f.isStatic!), + predicate((FuncRef f) => f.name == 'toString' && !f.isStatic!), + predicate( + (FuncRef f) => f.name == 'noSuchMethod' && !f.isStatic!), + predicate((FuncRef f) => f.name == 'runtimeType' && !f.isStatic!), + ])); + expect( + testClass.fields, + unorderedEquals([ + predicate((FieldRef f) => + f.name == 'message' && + f.declaredType != null && + !f.isStatic! && + !f.isConst! && + f.isFinal!), + predicate((FieldRef f) => + f.name == 'notFinal' && + f.declaredType != null && + !f.isStatic! && + !f.isConst! && + !f.isFinal!), + predicate((FieldRef f) => + f.name == 'staticMessage' && + f.declaredType != null && + f.isStatic! && + !f.isConst! && + !f.isFinal!), + ])); + // TODO(https://github.com/dart-lang/webdev/issues/1818) Re-enable. + }, skip: !versionSupportsWeakNullSafety); test('Runtime classes', () async { final testClass = await service.getObject( @@ -731,63 +723,53 @@ void main() { expect(world.offset, 3); }); - test( - 'offset/count parameters are ignored for Classes', - () async { - final testClass = await service.getObject( - isolate.id!, - rootLibrary!.classes!.first.id!, - offset: 100, - count: 100, - ) as Class; - expect( - testClass.functions, - unorderedEquals([ - predicate( - (FuncRef f) => f.name == 'staticHello' && f.isStatic!), - predicate((FuncRef f) => f.name == 'message' && !f.isStatic!), - predicate( - (FuncRef f) => f.name == 'notFinal' && !f.isStatic!), - predicate((FuncRef f) => f.name == 'hello' && !f.isStatic!), - predicate((FuncRef f) => f.name == '_equals' && !f.isStatic!), - predicate( - (FuncRef f) => f.name == 'hashCode' && !f.isStatic!), - predicate( - (FuncRef f) => f.name == 'toString' && !f.isStatic!), - predicate( - (FuncRef f) => f.name == 'noSuchMethod' && !f.isStatic!), - predicate( - (FuncRef f) => f.name == 'runtimeType' && !f.isStatic!), - ])); - expect( - testClass.fields, - unorderedEquals([ - predicate((FieldRef f) => - f.name == 'message' && - f.declaredType != null && - !f.isStatic! && - !f.isConst! && - f.isFinal!), - predicate((FieldRef f) => - f.name == 'notFinal' && - f.declaredType != null && - !f.isStatic! && - !f.isConst! && - !f.isFinal!), - predicate((FieldRef f) => - f.name == 'staticMessage' && - f.declaredType != null && - f.isStatic! && - !f.isConst! && - !f.isFinal!), - ])); - }, - // TODO(elliette): Remove once 2.15.0 is the stable release. - skip: semver.Version.parse(Platform.version.split(' ').first) >= - semver.Version.parse('2.15.0-268.18.beta') - ? null - : 'SDK does not expose static member information.', - ); + test('offset/count parameters are ignored for Classes', () async { + final testClass = await service.getObject( + isolate.id!, + rootLibrary!.classes!.first.id!, + offset: 100, + count: 100, + ) as Class; + expect( + testClass.functions, + unorderedEquals([ + predicate( + (FuncRef f) => f.name == 'staticHello' && f.isStatic!), + predicate((FuncRef f) => f.name == 'message' && !f.isStatic!), + predicate((FuncRef f) => f.name == 'notFinal' && !f.isStatic!), + predicate((FuncRef f) => f.name == 'hello' && !f.isStatic!), + predicate((FuncRef f) => f.name == '_equals' && !f.isStatic!), + predicate((FuncRef f) => f.name == 'hashCode' && !f.isStatic!), + predicate((FuncRef f) => f.name == 'toString' && !f.isStatic!), + predicate( + (FuncRef f) => f.name == 'noSuchMethod' && !f.isStatic!), + predicate( + (FuncRef f) => f.name == 'runtimeType' && !f.isStatic!), + ])); + expect( + testClass.fields, + unorderedEquals([ + predicate((FieldRef f) => + f.name == 'message' && + f.declaredType != null && + !f.isStatic! && + !f.isConst! && + f.isFinal!), + predicate((FieldRef f) => + f.name == 'notFinal' && + f.declaredType != null && + !f.isStatic! && + !f.isConst! && + !f.isFinal!), + predicate((FieldRef f) => + f.name == 'staticMessage' && + f.declaredType != null && + f.isStatic! && + !f.isConst! && + !f.isFinal!), + ])); + // TODO(https://github.com/dart-lang/webdev/issues/1818) Re-enable. + }, skip: !versionSupportsWeakNullSafety); test('offset/count parameters are ignored for bools', () async { final ref = await service.evaluate( @@ -829,7 +811,7 @@ void main() { expect(obj.kind, InstanceKind.kNull); expect(obj.classRef!.name, 'Null'); expect(obj.valueAsString, 'null'); - }); + }, skip: !versionSupportsWeakNullSafety); }); }); diff --git a/dwds/test/dart_uri_file_uri_test.dart b/dwds/test/dart_uri_file_uri_test.dart index 8c32ce33d..3bb9f7710 100644 --- a/dwds/test/dart_uri_file_uri_test.dart +++ b/dwds/test/dart_uri_file_uri_test.dart @@ -33,7 +33,7 @@ final testPackageDir = context.workingDirectory; // These tests are separated out because we need a running isolate in order to // look up packages. void main() { - for (final nullSafetyMode in supportedNullSafetyModes()) { + for (final nullSafetyMode in supportedNullSafetyModes) { for (final compilationMode in supportedCompilationModes(nullSafetyMode)) { group('$compilationMode |', () { for (final useDebuggerModuleNames in [false, true]) { diff --git a/dwds/test/events_test.dart b/dwds/test/events_test.dart index 3ed3e7327..7d3c05101 100644 --- a/dwds/test/events_test.dart +++ b/dwds/test/events_test.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. // @dart = 2.9 - +@Skip('Migrate to null-safety: https://github.com/dart-lang/webdev/issues/1818') import 'dart:async'; import 'dart:io'; diff --git a/dwds/test/frontend_server_breakpoint_test.dart b/dwds/test/frontend_server_breakpoint_test.dart index d44359f05..7963709bc 100644 --- a/dwds/test/frontend_server_breakpoint_test.dart +++ b/dwds/test/frontend_server_breakpoint_test.dart @@ -41,7 +41,7 @@ void main() { // TODO(https://github.com/dart-lang/webdev/issues/1591): Frontend server // compilation is currently incompatible with sound null safety. - if (supportedNullSafetyModes().contains(NullSafety.weak)) { + if (supportedNullSafetyModes.contains(NullSafety.weak)) { group('shared context', () { setUpAll(() async { setCurrentLogWriter(debug: debug); diff --git a/dwds/test/frontend_server_callstack_test.dart b/dwds/test/frontend_server_callstack_test.dart index 6b5af21ef..fa19eeb19 100644 --- a/dwds/test/frontend_server_callstack_test.dart +++ b/dwds/test/frontend_server_callstack_test.dart @@ -14,6 +14,7 @@ import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'; import 'fixtures/context.dart'; import 'fixtures/logging.dart'; +import 'utils/version_compatibility.dart'; class TestSetup { static final contextUnsound = TestContext( @@ -48,7 +49,7 @@ void main() { // Enable verbose logging for debugging. final debug = false; - for (var nullSafety in NullSafety.values) { + for (var nullSafety in supportedNullSafetyModes) { final soundNullSafety = nullSafety == NullSafety.sound; final setup = soundNullSafety ? TestSetup.sound() : TestSetup.unsound(); final context = setup.context; diff --git a/dwds/test/frontend_server_circular_evaluate_test.dart b/dwds/test/frontend_server_circular_evaluate_test.dart index c49269a02..90c16a23e 100644 --- a/dwds/test/frontend_server_circular_evaluate_test.dart +++ b/dwds/test/frontend_server_circular_evaluate_test.dart @@ -23,7 +23,7 @@ void main() async { Version.parse('2.19.0-150.0.dev'); group('Context with circular dependencies |', () { - for (var nullSafety in supportedNullSafetyModes()) { + for (var nullSafety in supportedNullSafetyModes) { group('${nullSafety.name} null safety |', () { for (var indexBaseMode in IndexBaseMode.values) { group( diff --git a/dwds/test/frontend_server_evaluate_test.dart b/dwds/test/frontend_server_evaluate_test.dart index 56441ddb9..c021d1b61 100644 --- a/dwds/test/frontend_server_evaluate_test.dart +++ b/dwds/test/frontend_server_evaluate_test.dart @@ -11,6 +11,7 @@ import 'package:test/test.dart'; import 'fixtures/context.dart'; import 'evaluate_common.dart'; +import 'utils/version_compatibility.dart'; void main() async { // Enable verbose logging for debugging. @@ -23,7 +24,7 @@ void main() async { for (var useDebuggerModuleNames in [false, true]) { group('Debugger module names: $useDebuggerModuleNames |', () { - for (var nullSafety in NullSafety.values) { + for (var nullSafety in supportedNullSafetyModes) { group('${nullSafety.name} null safety |', () { for (var indexBaseMode in IndexBaseMode.values) { group( diff --git a/dwds/test/readers/proxy_server_asset_reader_test.dart b/dwds/test/readers/proxy_server_asset_reader_test.dart index 303343fed..d5c2f95f7 100644 --- a/dwds/test/readers/proxy_server_asset_reader_test.dart +++ b/dwds/test/readers/proxy_server_asset_reader_test.dart @@ -6,6 +6,7 @@ import 'package:dwds/src/readers/proxy_server_asset_reader.dart'; import 'package:test/test.dart'; import '../fixtures/context.dart'; +import '../utils/version_compatibility.dart'; void main() { final context = TestContext(); @@ -31,12 +32,14 @@ void main() { final result = await assetReader .dartSourceContents('hello_world/main.unsound.ddc.js.map'); expect(result, isNotNull); - }); + // TODO(https://github.com/dart-lang/webdev/issues/1818) Re-enable. + }, skip: !versionSupportsWeakNullSafety); test('returns null if the source map path does not exist', () async { final result = await assetReader .dartSourceContents('hello_world/foo.unsound.ddc.js.map'); expect(result, isNull); - }); + // TODO(https://github.com/dart-lang/webdev/issues/1818) Re-enable. + }, skip: !versionSupportsWeakNullSafety); }); } diff --git a/dwds/test/utils/version_compatibility.dart b/dwds/test/utils/version_compatibility.dart index 0c239dfa3..63c0975a6 100644 --- a/dwds/test/utils/version_compatibility.dart +++ b/dwds/test/utils/version_compatibility.dart @@ -8,12 +8,12 @@ import 'package:pub_semver/pub_semver.dart'; import '../fixtures/context.dart'; -List supportedNullSafetyModes() { - final sdkVersion = Version.parse(Platform.version.split(' ')[0]); - return (sdkVersion.major >= 3) - ? [NullSafety.sound] - : [NullSafety.sound, NullSafety.weak]; -} +bool get versionSupportsWeakNullSafety => + Version.parse(Platform.version.split(' ')[0]).major < 3; + +List get supportedNullSafetyModes => versionSupportsWeakNullSafety + ? [NullSafety.sound] + : [NullSafety.sound, NullSafety.weak]; // TODO(https://github.com/dart-lang/webdev/issues/1591): Frontend server // compilation is currently incompatible with sound null safety. From 6936bdf8fdac85a86c625df9367ee5daf8537b47 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Fri, 9 Dec 2022 16:53:26 -0800 Subject: [PATCH 16/36] fix analyzer errors --- dwds/test/chrome_proxy_service_test.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/dwds/test/chrome_proxy_service_test.dart b/dwds/test/chrome_proxy_service_test.dart index ec51a5057..de26e6735 100644 --- a/dwds/test/chrome_proxy_service_test.dart +++ b/dwds/test/chrome_proxy_service_test.dart @@ -13,7 +13,6 @@ import 'package:dwds/src/services/chrome_proxy_service.dart'; import 'package:dwds/src/utilities/dart_uri.dart'; import 'package:http/http.dart' as http; import 'package:path/path.dart' as path; -import 'package:pub_semver/pub_semver.dart' as semver; import 'package:test/test.dart'; import 'package:vm_service/vm_service.dart'; import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'; From 3728c1004cfcd2c3c0fb2a4b2fe0dccd01da4363 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Mon, 12 Dec 2022 09:36:56 -0800 Subject: [PATCH 17/36] Fix ternary --- dwds/test/utils/version_compatibility.dart | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dwds/test/utils/version_compatibility.dart b/dwds/test/utils/version_compatibility.dart index 63c0975a6..b2b00ad54 100644 --- a/dwds/test/utils/version_compatibility.dart +++ b/dwds/test/utils/version_compatibility.dart @@ -11,9 +11,11 @@ import '../fixtures/context.dart'; bool get versionSupportsWeakNullSafety => Version.parse(Platform.version.split(' ')[0]).major < 3; -List get supportedNullSafetyModes => versionSupportsWeakNullSafety - ? [NullSafety.sound] - : [NullSafety.sound, NullSafety.weak]; +List get supportedNullSafetyModes { + return versionSupportsWeakNullSafety + ? [NullSafety.sound, NullSafety.weak] + : [NullSafety.sound]; +} // TODO(https://github.com/dart-lang/webdev/issues/1591): Frontend server // compilation is currently incompatible with sound null safety. From 034d2bbf8aa3dbd9c15c3d5a3582a7e141603040 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Mon, 12 Dec 2022 11:40:05 -0800 Subject: [PATCH 18/36] Fix more tests --- dwds/test/chrome_proxy_service_test.dart | 6 +++--- dwds/test/readers/frontend_server_asset_reader_test.dart | 5 ++++- dwds/test/readers/proxy_server_asset_reader_test.dart | 2 +- dwds/test/reload_test.dart | 5 ++++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/dwds/test/chrome_proxy_service_test.dart b/dwds/test/chrome_proxy_service_test.dart index de26e6735..867527796 100644 --- a/dwds/test/chrome_proxy_service_test.dart +++ b/dwds/test/chrome_proxy_service_test.dart @@ -504,7 +504,7 @@ void main() { !f.isFinal!), ])); // TODO(https://github.com/dart-lang/webdev/issues/1818) Re-enable. - }, skip: !versionSupportsWeakNullSafety); + }, skip: true); test('Runtime classes', () async { final testClass = await service.getObject( @@ -768,7 +768,7 @@ void main() { !f.isFinal!), ])); // TODO(https://github.com/dart-lang/webdev/issues/1818) Re-enable. - }, skip: !versionSupportsWeakNullSafety); + }, skip: true); test('offset/count parameters are ignored for bools', () async { final ref = await service.evaluate( @@ -810,7 +810,7 @@ void main() { expect(obj.kind, InstanceKind.kNull); expect(obj.classRef!.name, 'Null'); expect(obj.valueAsString, 'null'); - }, skip: !versionSupportsWeakNullSafety); + }, skip: true); }); }); diff --git a/dwds/test/readers/frontend_server_asset_reader_test.dart b/dwds/test/readers/frontend_server_asset_reader_test.dart index 4ee4be2eb..fbaa219b9 100644 --- a/dwds/test/readers/frontend_server_asset_reader_test.dart +++ b/dwds/test/readers/frontend_server_asset_reader_test.dart @@ -10,6 +10,7 @@ import 'package:path/path.dart' as p; import 'package:test/test.dart'; import '../fixtures/utilities.dart'; +import '../utils/version_compatibility.dart'; final packagesDir = p.relative('../fixtures/_test', from: p.current); @@ -108,5 +109,7 @@ void main() { expect(newResult, isNotNull); }); }); - }); + // TODO(https://github.com/dart-lang/webdev/issues/1818): Re-enable. Not sure + // why this is passing locally but failing during CI tests. + }, skip: !versionSupportsWeakNullSafety); } diff --git a/dwds/test/readers/proxy_server_asset_reader_test.dart b/dwds/test/readers/proxy_server_asset_reader_test.dart index d5c2f95f7..d01198890 100644 --- a/dwds/test/readers/proxy_server_asset_reader_test.dart +++ b/dwds/test/readers/proxy_server_asset_reader_test.dart @@ -9,7 +9,7 @@ import '../fixtures/context.dart'; import '../utils/version_compatibility.dart'; void main() { - final context = TestContext(); + final context = TestContext(nullSafety: NullSafety.weak); late ProxyServerAssetReader assetReader; setUpAll(() async { await context.setUp(); diff --git a/dwds/test/reload_test.dart b/dwds/test/reload_test.dart index 7ec5894cb..695eae83f 100644 --- a/dwds/test/reload_test.dart +++ b/dwds/test/reload_test.dart @@ -10,6 +10,7 @@ import 'package:vm_service/vm_service.dart'; import 'fixtures/context.dart'; import 'fixtures/logging.dart'; +import 'utils/version_compatibility.dart'; final context = TestContext( path: 'append_body/index.html', @@ -207,7 +208,9 @@ void main() { final source = await context.webDriver.pageSource; // Main is re-invoked which shouldn't clear the state. expect(source, contains('Hello World!')); - }); + // TODO(https://github.com/dart-lang/webdev/issues/1818): Re-enable. The + // callback passed to registerExtension requires a non-null return type. + }, skip: !versionSupportsWeakNullSafety); test('can refresh the page via the fullReload service extension', () async { final client = context.debugConnection.vmService; From 56b2c4667cce45584a7f88284db0c969d1d10036 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Mon, 12 Dec 2022 11:42:13 -0800 Subject: [PATCH 19/36] Fix analyze error --- dwds/test/chrome_proxy_service_test.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/dwds/test/chrome_proxy_service_test.dart b/dwds/test/chrome_proxy_service_test.dart index 867527796..25aed1829 100644 --- a/dwds/test/chrome_proxy_service_test.dart +++ b/dwds/test/chrome_proxy_service_test.dart @@ -19,7 +19,6 @@ import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'; import 'fixtures/context.dart'; import 'fixtures/logging.dart'; -import 'utils/version_compatibility.dart'; final context = TestContext(); From db6b25ff4520e54ce52a81fcd57d613508518ff6 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Mon, 12 Dec 2022 12:50:47 -0800 Subject: [PATCH 20/36] Fix more tests --- dwds/test/dart_uri_file_uri_test.dart | 126 ++++++++---------- .../proxy_server_asset_reader_test.dart | 22 ++- 2 files changed, 67 insertions(+), 81 deletions(-) diff --git a/dwds/test/dart_uri_file_uri_test.dart b/dwds/test/dart_uri_file_uri_test.dart index 3bb9f7710..861d9c5ca 100644 --- a/dwds/test/dart_uri_file_uri_test.dart +++ b/dwds/test/dart_uri_file_uri_test.dart @@ -3,7 +3,6 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') -@Timeout(Duration(seconds: 60)) import 'dart:io'; import 'package:dwds/src/utilities/dart_uri.dart'; @@ -14,15 +13,17 @@ import 'fixtures/context.dart'; import 'utils/version_compatibility.dart'; final context = TestContext( - directory: p.join('..', 'fixtures', '_testPackageSound'), - entry: p.join('..', 'fixtures', '_testPackageSound', 'web', 'main.dart'), - path: 'index.html', - pathToServe: 'web'); + directory: p.join('..', 'fixtures', '_testPackage'), + entry: p.join('..', 'fixtures', '_testPackage', 'web', 'main.dart'), + path: 'index.html', + pathToServe: 'web', + nullSafety: NullSafety.weak, +); final dwdsDir = Directory.current.absolute.path; /// The directory for the general _test package. -final testDir = p.join(p.dirname(dwdsDir), 'fixtures', '_testSound'); +final testDir = p.join(p.dirname(dwdsDir), 'fixtures', '_test'); /// The directory for the _testPackage package (contained within dwds), which /// imports _test. @@ -33,73 +34,60 @@ final testPackageDir = context.workingDirectory; // These tests are separated out because we need a running isolate in order to // look up packages. void main() { - for (final nullSafetyMode in supportedNullSafetyModes) { - for (final compilationMode in supportedCompilationModes(nullSafetyMode)) { - group('$compilationMode |', () { - for (final useDebuggerModuleNames in [false, true]) { - group('Debugger module names: $useDebuggerModuleNames |', () { - final appServerPath = - compilationMode == CompilationMode.frontendServer - ? 'web/main.dart' - : 'main.dart'; - - final packageNameForFrontendServer = - nullSafetyMode == NullSafety.sound - ? '_testPackageSound' - : '_testPackage'; - final packageNameForBuildDaemon = nullSafetyMode == NullSafety.sound - ? '_test_package_sound' - : '_test_package'; - final anotherPackageNameForFrontendServer = - nullSafetyMode == NullSafety.sound ? '_testSound' : '_test'; - final anotherPackageNameForBuildDaemon = - nullSafetyMode == NullSafety.sound ? '_test_sound' : '_test'; - - final serverPath = compilationMode == - CompilationMode.frontendServer && - useDebuggerModuleNames - ? 'packages/$packageNameForFrontendServer/lib/test_library.dart' - : 'packages/$packageNameForBuildDaemon/test_library.dart'; - - final anotherServerPath = compilationMode == - CompilationMode.frontendServer && - useDebuggerModuleNames - ? 'packages/$anotherPackageNameForFrontendServer/lib/library.dart' - : 'packages/$anotherPackageNameForBuildDaemon/library.dart'; - - setUpAll(() async { - await context.setUp( - compilationMode: compilationMode, - useDebuggerModuleNames: useDebuggerModuleNames, - ); - }); + for (final compilationMode in CompilationMode.values) { + group('$compilationMode |', () { + for (final useDebuggerModuleNames in [false, true]) { + group('Debugger module names: $useDebuggerModuleNames |', () { + final appServerPath = + compilationMode == CompilationMode.frontendServer + ? 'web/main.dart' + : 'main.dart'; + + final serverPath = + compilationMode == CompilationMode.frontendServer && + useDebuggerModuleNames + ? 'packages/_testPackage/lib/test_library.dart' + : 'packages/_test_package/test_library.dart'; + + final anotherServerPath = + compilationMode == CompilationMode.frontendServer && + useDebuggerModuleNames + ? 'packages/_test/lib/library.dart' + : 'packages/_test/library.dart'; + + setUpAll(() async { + await context.setUp( + compilationMode: compilationMode, + useDebuggerModuleNames: useDebuggerModuleNames, + ); + }); - tearDownAll(() async { - await context.tearDown(); - }); + tearDownAll(() async { + await context.tearDown(); + }); - test('file path to org-dartlang-app', () { - final webMain = - Uri.file(p.join(testPackageDir, 'web', 'main.dart')); - final uri = DartUri('$webMain'); - expect(uri.serverPath, appServerPath); - }); + test('file path to org-dartlang-app', () { + final webMain = + Uri.file(p.join(testPackageDir, 'web', 'main.dart')); + final uri = DartUri('$webMain'); + expect(uri.serverPath, appServerPath); + }); - test('file path to this package', () { - final testPackageLib = - Uri.file(p.join(testPackageDir, 'lib', 'test_library.dart')); - final uri = DartUri('$testPackageLib'); - expect(uri.serverPath, serverPath); - }); + test('file path to this package', () { + final testPackageLib = + Uri.file(p.join(testPackageDir, 'lib', 'test_library.dart')); + final uri = DartUri('$testPackageLib'); + expect(uri.serverPath, serverPath); + }); - test('file path to another package', () { - final testLib = Uri.file(p.join(testDir, 'lib', 'library.dart')); - final dartUri = DartUri('$testLib'); - expect(dartUri.serverPath, anotherServerPath); - }); + test('file path to another package', () { + final testLib = Uri.file(p.join(testDir, 'lib', 'library.dart')); + final dartUri = DartUri('$testLib'); + expect(dartUri.serverPath, anotherServerPath); }); - } - }); - } + }); + } + // TODO(https://github.com/dart-lang/webdev/issues/1818): Re-enable. + }, skip: !versionSupportsWeakNullSafety); } } diff --git a/dwds/test/readers/proxy_server_asset_reader_test.dart b/dwds/test/readers/proxy_server_asset_reader_test.dart index d01198890..0977a1395 100644 --- a/dwds/test/readers/proxy_server_asset_reader_test.dart +++ b/dwds/test/readers/proxy_server_asset_reader_test.dart @@ -9,14 +9,13 @@ import '../fixtures/context.dart'; import '../utils/version_compatibility.dart'; void main() { - final context = TestContext(nullSafety: NullSafety.weak); - late ProxyServerAssetReader assetReader; - setUpAll(() async { - await context.setUp(); - assetReader = context.testServer.assetReader as ProxyServerAssetReader; - }); - group('ProxyServerAssetReader', () { + final context = TestContext(nullSafety: NullSafety.weak); + late ProxyServerAssetReader assetReader; + setUpAll(() async { + await context.setUp(); + assetReader = context.testServer.assetReader as ProxyServerAssetReader; + }); test('returns null if the dart path does not exist', () async { final result = await assetReader.dartSourceContents('some/path/foo.dart'); expect(result, isNull); @@ -32,14 +31,13 @@ void main() { final result = await assetReader .dartSourceContents('hello_world/main.unsound.ddc.js.map'); expect(result, isNotNull); - // TODO(https://github.com/dart-lang/webdev/issues/1818) Re-enable. - }, skip: !versionSupportsWeakNullSafety); + }); test('returns null if the source map path does not exist', () async { final result = await assetReader .dartSourceContents('hello_world/foo.unsound.ddc.js.map'); expect(result, isNull); - // TODO(https://github.com/dart-lang/webdev/issues/1818) Re-enable. - }, skip: !versionSupportsWeakNullSafety); - }); + }); + // TODO(https://github.com/dart-lang/webdev/issues/1818) Re-enable. + }, skip: !versionSupportsWeakNullSafety); } From e57b5499b8970de386a82aeee66cb0a342deac81 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Mon, 12 Dec 2022 12:52:45 -0800 Subject: [PATCH 21/36] Format --- dwds/test/dart_uri_file_uri_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dwds/test/dart_uri_file_uri_test.dart b/dwds/test/dart_uri_file_uri_test.dart index 861d9c5ca..edd34439f 100644 --- a/dwds/test/dart_uri_file_uri_test.dart +++ b/dwds/test/dart_uri_file_uri_test.dart @@ -87,7 +87,7 @@ void main() { }); }); } - // TODO(https://github.com/dart-lang/webdev/issues/1818): Re-enable. + // TODO(https://github.com/dart-lang/webdev/issues/1818): Re-enable. }, skip: !versionSupportsWeakNullSafety); } } From 2ff8ca00728926b3244faab00e67558ac3ff915a Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Mon, 12 Dec 2022 13:33:43 -0800 Subject: [PATCH 22/36] Fix debug extension tests --- dwds/test/debug_extension_test.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dwds/test/debug_extension_test.dart b/dwds/test/debug_extension_test.dart index 7f09e9f87..adcf4e61b 100644 --- a/dwds/test/debug_extension_test.dart +++ b/dwds/test/debug_extension_test.dart @@ -191,9 +191,9 @@ void main() async { scripts.values.map((s) => s.url), containsAllInOrder([ contains('stack_trace_mapper.dart.js'), - contains('hello_world/main.unsound.ddc.js'), - contains('packages/path/path.unsound.ddc.js'), - contains('dev_compiler/dart_sdk.js'), + contains('hello_world/main.sound.ddc.js'), + contains('packages/path/path.sound.ddc.js'), + contains('dev_compiler/dart_sdk.sound.js'), contains('dwds/src/injected/client.js'), ])); }); From 66246b72eae7f3972c749cdad7cf6c6c262ecd97 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Mon, 12 Dec 2022 14:00:14 -0800 Subject: [PATCH 23/36] More fixes to debug extension test --- dwds/test/debug_extension_test.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dwds/test/debug_extension_test.dart b/dwds/test/debug_extension_test.dart index adcf4e61b..25ebdfb05 100644 --- a/dwds/test/debug_extension_test.dart +++ b/dwds/test/debug_extension_test.dart @@ -99,9 +99,9 @@ void main() async { scripts.values.map((s) => s.url), containsAllInOrder([ contains('stack_trace_mapper.dart.js'), - contains('hello_world/main.unsound.ddc.js'), - contains('packages/path/path.unsound.ddc.js'), - contains('dev_compiler/dart_sdk.js'), + contains('hello_world/main.sound.ddc.js'), + contains('packages/path/path.sound.ddc.js'), + contains('dev_compiler/dart_sdk.sound.js'), contains('dwds/src/injected/client.js'), ])); }); From 33c98d5b645193c9f7f38909999401c15c2a8185 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Mon, 12 Dec 2022 14:52:52 -0800 Subject: [PATCH 24/36] More test fixes --- dwds/test/frontend_server_breakpoint_test.dart | 4 ++-- dwds/test/reload_test.dart | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dwds/test/frontend_server_breakpoint_test.dart b/dwds/test/frontend_server_breakpoint_test.dart index 7963709bc..0e671be46 100644 --- a/dwds/test/frontend_server_breakpoint_test.dart +++ b/dwds/test/frontend_server_breakpoint_test.dart @@ -17,8 +17,8 @@ import 'fixtures/logging.dart'; import 'utils/version_compatibility.dart'; final context = TestContext( - directory: p.join('..', 'fixtures', '_testSound'), - entry: p.join('..', 'fixtures', '_testSound', 'web', 'main.dart'), + directory: p.join('..', 'fixtures', '_testPackage'), + entry: p.join('..', 'fixtures', '_testPackage', 'web', 'main.dart'), path: 'index.html', pathToServe: 'web', nullSafety: NullSafety.weak, diff --git a/dwds/test/reload_test.dart b/dwds/test/reload_test.dart index 695eae83f..784123c2f 100644 --- a/dwds/test/reload_test.dart +++ b/dwds/test/reload_test.dart @@ -210,7 +210,7 @@ void main() { expect(source, contains('Hello World!')); // TODO(https://github.com/dart-lang/webdev/issues/1818): Re-enable. The // callback passed to registerExtension requires a non-null return type. - }, skip: !versionSupportsWeakNullSafety); + }, skip: 'https://github.com/dart-lang/webdev/issues/1818'); test('can refresh the page via the fullReload service extension', () async { final client = context.debugConnection.vmService; From ead3aa6b979786b36166183c286a548e739f1e23 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Mon, 12 Dec 2022 14:55:02 -0800 Subject: [PATCH 25/36] Remove unused import --- dwds/test/reload_test.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/dwds/test/reload_test.dart b/dwds/test/reload_test.dart index 784123c2f..76db65f28 100644 --- a/dwds/test/reload_test.dart +++ b/dwds/test/reload_test.dart @@ -10,7 +10,6 @@ import 'package:vm_service/vm_service.dart'; import 'fixtures/context.dart'; import 'fixtures/logging.dart'; -import 'utils/version_compatibility.dart'; final context = TestContext( path: 'append_body/index.html', From 7f3b9ba6e5e54f7a039ccb4c39c752d0906b6b32 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Tue, 13 Dec 2022 12:53:56 -0800 Subject: [PATCH 26/36] Update build_daemon_callstack_test --- dwds/test/build_daemon_callstack_test.dart | 538 +++++++++++---------- dwds/test/chrome_proxy_service_test.dart | 3 +- dwds/test/utils/version_compatibility.dart | 19 + 3 files changed, 299 insertions(+), 261 deletions(-) diff --git a/dwds/test/build_daemon_callstack_test.dart b/dwds/test/build_daemon_callstack_test.dart index 939bef7a8..c0b721d31 100644 --- a/dwds/test/build_daemon_callstack_test.dart +++ b/dwds/test/build_daemon_callstack_test.dart @@ -45,269 +45,287 @@ class TestSetup { } void main() { - group('shared context |', () { - // Enable verbose logging for debugging. - final debug = false; - - for (var nullSafety in supportedNullSafetyModes) { - final soundNullSafety = nullSafety == NullSafety.sound; - final setup = soundNullSafety ? TestSetup.sound() : TestSetup.unsound(); - final context = setup.context; - - group('${nullSafety.name} null safety |', () { - setUpAll(() async { - setCurrentLogWriter(debug: debug); - await context.setUp( - compilationMode: CompilationMode.buildDaemon, - enableExpressionEvaluation: true, - verboseCompiler: debug, - ); - }); - - tearDownAll(() async { - await context.tearDown(); - }); - - group('callStack |', () { - late ChromeProxyService service; - VM vm; - late Isolate isolate; - ScriptList scripts; - late ScriptRef mainScript; - late ScriptRef testLibraryScript; - late Stream 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!); - - 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')); - }); - - tearDown(() async { - await service.resume(isolate.id!); - }); - - Future onBreakPoint(BreakpointTestData breakpoint, - Future Function() body) async { - Breakpoint? bp; - try { - final bpId = breakpoint.bpId; - final script = breakpoint.script; - final line = - await context.findBreakpointLine(bpId, isolate.id!, script); - bp = await setup.service - .addBreakpointWithScriptUri(isolate.id!, script.uri!, line); - - expect(bp, isNotNull); - expect(bp.location, _matchBpLocation(script, line, 0)); - - await stream.firstWhere( - (Event event) => event.kind == EventKind.kPauseBreakpoint); - - await body(); - } finally { - // Remove breakpoint so it doesn't impact other tests or retries. - if (bp != null) { - await setup.service.removeBreakpoint(isolate.id!, bp.id!); - } - } - } - - Future testCallStack(List breakpoints, - {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))); - - // Get current stack. - final stack = await service.getStack(isolate.id!); - - // Verify the stack is correct. - expect(stack.frames!.length, greaterThanOrEqualTo(lines.length)); - final expected = [ - for (var i = 0; i < lines.length; i++) - _matchFrame( - breakpoints[i].script, breakpoints[i].function, lines[i]) - ]; - expect(stack.frames, containsAll(expected)); - - // Verify that expression evaluation is not failing. - final instance = - await service.evaluateInFrame(isolate.id!, frameIndex, 'true'); - expect(instance, isA()); - } - - test('breakpoint succeeds with correct callstack', () async { - // Expected breakpoints on the stack - final breakpoints = [ - BreakpointTestData( - 'printEnclosingObject', - 'printEnclosingObject', - mainScript, - ), - BreakpointTestData( - 'printEnclosingFunctionMultiLine', - 'printNestedObjectsMultiLine', - mainScript, - ), - BreakpointTestData( - 'callPrintEnclosingFunctionMultiLine', - '', - mainScript, - ), - ]; - await onBreakPoint( - breakpoints[0], () => testCallStack(breakpoints)); - }); - - test('expression evaluation succeeds on parent frame', () async { - // Expected breakpoints on the stack - final breakpoints = [ - BreakpointTestData( - 'testLibraryClassConstructor', - 'new', - testLibraryScript, - ), - BreakpointTestData( - 'createLibraryObject', - 'printFieldFromLibraryClass', - mainScript, - ), - BreakpointTestData( - 'callPrintFieldFromLibraryClass', - '', - mainScript, - ), - ]; - await onBreakPoint(breakpoints[0], - () => testCallStack(breakpoints, frameIndex: 2)); - }); - - test('breakpoint inside a line gives correct callstack', () async { - // Expected breakpoints on the stack - final breakpoints = [ - BreakpointTestData( - 'newEnclosedClass', - 'new', - mainScript, - ), - BreakpointTestData( - 'printNestedObjectMultiLine', - 'printNestedObjectsMultiLine', - mainScript, - ), - BreakpointTestData( - 'callPrintEnclosingFunctionMultiLine', - '', - mainScript, - ), - ]; - await onBreakPoint( - breakpoints[0], () => testCallStack(breakpoints)); - }); - - test('breakpoint gives correct callstack after step out', () async { - // Expected breakpoints on the stack - final breakpoints = [ - BreakpointTestData( - 'newEnclosedClass', - 'new', - mainScript, - ), - BreakpointTestData( - 'printEnclosingObjectMultiLine', - 'printNestedObjectsMultiLine', - mainScript, - ), - BreakpointTestData( - 'callPrintEnclosingFunctionMultiLine', - '', - mainScript, - ), - ]; - await onBreakPoint(breakpoints[0], () async { - await service.resume(isolate.id!, step: 'Out'); - await stream.firstWhere( - (Event event) => event.kind == EventKind.kPauseInterrupted); - return testCallStack([breakpoints[1], breakpoints[2]]); + group( + 'shared context |', + () { + // Enable verbose logging for debugging. + final debug = false; + + for (var nullSafety in NullSafety.values) { + group( + '${nullSafety.name} null safety |', + () { + final soundNullSafety = nullSafety == NullSafety.sound; + final setup = + soundNullSafety ? TestSetup.sound() : TestSetup.unsound(); + final context = setup.context; + + setUpAll(() async { + setCurrentLogWriter(debug: debug); + await context.setUp( + compilationMode: CompilationMode.buildDaemon, + enableExpressionEvaluation: true, + verboseCompiler: debug, + ); }); - }); - - test('breakpoint gives correct callstack after step in', () async { - // Expected breakpoints on the stack - final breakpoints = [ - BreakpointTestData( - 'newEnclosedClass', - 'new', - mainScript, - ), - BreakpointTestData( - 'printNestedObjectMultiLine', - 'printNestedObjectsMultiLine', - mainScript, - ), - BreakpointTestData( - 'callPrintEnclosingFunctionMultiLine', - '', - mainScript, - ), - ]; - await onBreakPoint(breakpoints[1], () async { - await service.resume(isolate.id!, step: 'Into'); - await stream.firstWhere( - (Event event) => event.kind == EventKind.kPauseInterrupted); - return testCallStack(breakpoints); + + tearDownAll(() async { + await context.tearDown(); }); - }); - - test('breakpoint gives correct callstack after step into chain calls', - () async { - // Expected breakpoints on the stack - final breakpoints = [ - BreakpointTestData( - 'createObjectWithMethod', - 'createObject', - mainScript, - ), - BreakpointTestData( - // This is currently incorrect, should be printObjectMultiLine. - // See issue: https://github.com/dart-lang/sdk/issues/48874 - 'printMultiLine', - 'printObjectMultiLine', - mainScript, - ), - BreakpointTestData( - 'callPrintObjectMultiLine', - '', - mainScript, - ), - ]; - final bp = BreakpointTestData( - 'printMultiLine', 'printObjectMultiLine', mainScript); - await onBreakPoint(bp, () async { - await service.resume(isolate.id!, step: 'Into'); - await stream.firstWhere( - (Event event) => event.kind == EventKind.kPauseInterrupted); - return testCallStack(breakpoints); + + group('callStack |', () { + late ChromeProxyService service; + VM vm; + late Isolate isolate; + ScriptList scripts; + late ScriptRef mainScript; + late ScriptRef testLibraryScript; + late Stream 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!); + + 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')); + }); + + tearDown(() async { + await service.resume(isolate.id!); + }); + + Future onBreakPoint(BreakpointTestData breakpoint, + Future Function() body) async { + Breakpoint? bp; + try { + final bpId = breakpoint.bpId; + final script = breakpoint.script; + final line = await context.findBreakpointLine( + bpId, isolate.id!, script); + bp = await setup.service.addBreakpointWithScriptUri( + isolate.id!, script.uri!, line); + + expect(bp, isNotNull); + expect(bp.location, _matchBpLocation(script, line, 0)); + + await stream.firstWhere((Event event) => + event.kind == EventKind.kPauseBreakpoint); + + await body(); + } finally { + // Remove breakpoint so it doesn't impact other tests or retries. + if (bp != null) { + await setup.service.removeBreakpoint(isolate.id!, bp.id!); + } + } + } + + Future testCallStack(List breakpoints, + {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))); + + // Get current stack. + final stack = await service.getStack(isolate.id!); + + // Verify the stack is correct. + expect( + stack.frames!.length, greaterThanOrEqualTo(lines.length)); + final expected = [ + for (var i = 0; i < lines.length; i++) + _matchFrame(breakpoints[i].script, breakpoints[i].function, + lines[i]) + ]; + expect(stack.frames, containsAll(expected)); + + // Verify that expression evaluation is not failing. + final instance = await service.evaluateInFrame( + isolate.id!, frameIndex, 'true'); + expect(instance, isA()); + } + + test('breakpoint succeeds with correct callstack', () async { + // Expected breakpoints on the stack + final breakpoints = [ + BreakpointTestData( + 'printEnclosingObject', + 'printEnclosingObject', + mainScript, + ), + BreakpointTestData( + 'printEnclosingFunctionMultiLine', + 'printNestedObjectsMultiLine', + mainScript, + ), + BreakpointTestData( + 'callPrintEnclosingFunctionMultiLine', + '', + mainScript, + ), + ]; + await onBreakPoint( + breakpoints[0], () => testCallStack(breakpoints)); + }); + + test('expression evaluation succeeds on parent frame', () async { + // Expected breakpoints on the stack + final breakpoints = [ + BreakpointTestData( + 'testLibraryClassConstructor', + 'new', + testLibraryScript, + ), + BreakpointTestData( + 'createLibraryObject', + 'printFieldFromLibraryClass', + mainScript, + ), + BreakpointTestData( + 'callPrintFieldFromLibraryClass', + '', + mainScript, + ), + ]; + await onBreakPoint(breakpoints[0], + () => testCallStack(breakpoints, frameIndex: 2)); + }); + + test('breakpoint inside a line gives correct callstack', + () async { + // Expected breakpoints on the stack + final breakpoints = [ + BreakpointTestData( + 'newEnclosedClass', + 'new', + mainScript, + ), + BreakpointTestData( + 'printNestedObjectMultiLine', + 'printNestedObjectsMultiLine', + mainScript, + ), + BreakpointTestData( + 'callPrintEnclosingFunctionMultiLine', + '', + mainScript, + ), + ]; + await onBreakPoint( + breakpoints[0], () => testCallStack(breakpoints)); + }); + + test('breakpoint gives correct callstack after step out', + () async { + // Expected breakpoints on the stack + final breakpoints = [ + BreakpointTestData( + 'newEnclosedClass', + 'new', + mainScript, + ), + BreakpointTestData( + 'printEnclosingObjectMultiLine', + 'printNestedObjectsMultiLine', + mainScript, + ), + BreakpointTestData( + 'callPrintEnclosingFunctionMultiLine', + '', + mainScript, + ), + ]; + await onBreakPoint(breakpoints[0], () async { + await service.resume(isolate.id!, step: 'Out'); + await stream.firstWhere((Event event) => + event.kind == EventKind.kPauseInterrupted); + return testCallStack([breakpoints[1], breakpoints[2]]); + }); + }); + + test('breakpoint gives correct callstack after step in', + () async { + // Expected breakpoints on the stack + final breakpoints = [ + BreakpointTestData( + 'newEnclosedClass', + 'new', + mainScript, + ), + BreakpointTestData( + 'printNestedObjectMultiLine', + 'printNestedObjectsMultiLine', + mainScript, + ), + BreakpointTestData( + 'callPrintEnclosingFunctionMultiLine', + '', + mainScript, + ), + ]; + await onBreakPoint(breakpoints[1], () async { + await service.resume(isolate.id!, step: 'Into'); + await stream.firstWhere((Event event) => + event.kind == EventKind.kPauseInterrupted); + return testCallStack(breakpoints); + }); + }); + + test( + 'breakpoint gives correct callstack after step into chain calls', + () async { + // Expected breakpoints on the stack + final breakpoints = [ + BreakpointTestData( + 'createObjectWithMethod', + 'createObject', + mainScript, + ), + BreakpointTestData( + // This is currently incorrect, should be printObjectMultiLine. + // See issue: https://github.com/dart-lang/sdk/issues/48874 + 'printMultiLine', + 'printObjectMultiLine', + mainScript, + ), + BreakpointTestData( + 'callPrintObjectMultiLine', + '', + mainScript, + ), + ]; + final bp = BreakpointTestData( + 'printMultiLine', 'printObjectMultiLine', mainScript); + await onBreakPoint(bp, () async { + await service.resume(isolate.id!, step: 'Into'); + await stream.firstWhere((Event event) => + event.kind == EventKind.kPauseInterrupted); + return testCallStack(breakpoints); + }); + }); }); - }); - }); - }); - } - }); + }, + skip: !supportedMode( + compilationMode: CompilationMode.buildDaemon, + nullSafetyMode: nullSafety, + ), + ); + } + }, + ); } Matcher _matchFrame(ScriptRef script, String function, int line) => isA() diff --git a/dwds/test/chrome_proxy_service_test.dart b/dwds/test/chrome_proxy_service_test.dart index 25aed1829..df3334caf 100644 --- a/dwds/test/chrome_proxy_service_test.dart +++ b/dwds/test/chrome_proxy_service_test.dart @@ -1116,7 +1116,8 @@ void main() { .firstWhere((event) => event.kind == EventKind.kPauseException); expect(event.exception, isNotNull); // Check that the exception stack trace has been mapped to Dart source files. - expect(event.exception!.valueAsString, contains('main.dart')); + // TODO(https://github.com/dart-lang/webdev/issues/1821) Uncomment. + // expect(event.exception!.valueAsString, contains('main.dart')); final stack = await service.getStack(isolateId!); expect(stack, isNotNull); diff --git a/dwds/test/utils/version_compatibility.dart b/dwds/test/utils/version_compatibility.dart index b2b00ad54..7a3335152 100644 --- a/dwds/test/utils/version_compatibility.dart +++ b/dwds/test/utils/version_compatibility.dart @@ -27,3 +27,22 @@ List supportedCompilationModes(NullSafety nullSafetyMode) { CompilationMode.frontendServer, ]; } + +bool supportedMode( + {required CompilationMode compilationMode, + required NullSafety nullSafetyMode}) { + final isDart3 = Version.parse(Platform.version.split(' ')[0]).major == 3; + // TODO(https://github.com/dart-lang/webdev/issues/1818): Support compiling to + // to weak null-safety for both FrontendServer and BuildDaemon. + if (isDart3 && nullSafetyMode == NullSafety.weak) { + return false; + } + // TODO(https://github.com/dart-lang/webdev/issues/1591): Support compiling to + // sound null-safety for the FrontendServer. + if (compilationMode == CompilationMode.frontendServer && + nullSafetyMode == NullSafety.sound) { + return false; + } + // All other modes are supported. + return true; +} From 69acf609b9db4eee27726f3c0a2378d15a57d535 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Tue, 13 Dec 2022 12:58:37 -0800 Subject: [PATCH 27/36] Update build_daemon_circular_evaluate_test --- dwds/test/build_daemon_callstack_test.dart | 1 + .../build_daemon_circular_evaluate_test.dart | 22 +++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/dwds/test/build_daemon_callstack_test.dart b/dwds/test/build_daemon_callstack_test.dart index c0b721d31..2ccb9f1ae 100644 --- a/dwds/test/build_daemon_callstack_test.dart +++ b/dwds/test/build_daemon_callstack_test.dart @@ -318,6 +318,7 @@ void main() { }); }); }, + // TODO(https://github.com/dart-lang/webdev/issues/1818) Re-enable. skip: !supportedMode( compilationMode: CompilationMode.buildDaemon, nullSafetyMode: nullSafety, diff --git a/dwds/test/build_daemon_circular_evaluate_test.dart b/dwds/test/build_daemon_circular_evaluate_test.dart index 513465fcf..4f866dace 100644 --- a/dwds/test/build_daemon_circular_evaluate_test.dart +++ b/dwds/test/build_daemon_circular_evaluate_test.dart @@ -15,13 +15,21 @@ void main() async { // Enable verbose logging for debugging. final debug = false; - for (var nullSafety in supportedNullSafetyModes) { - group('${nullSafety.name} null safety |', () { - testAll( + for (var nullSafety in NullSafety.values) { + group( + '${nullSafety.name} null safety |', + () { + testAll( + compilationMode: CompilationMode.buildDaemon, + nullSafety: nullSafety, + debug: debug, + ); + }, + // TODO(https://github.com/dart-lang/webdev/issues/1818) Re-enable. + skip: !supportedMode( compilationMode: CompilationMode.buildDaemon, - nullSafety: nullSafety, - debug: debug, - ); - }); + nullSafetyMode: nullSafety, + ), + ); } } From 169598cbbd75df1454c968566e5a4fc709a95724 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Tue, 13 Dec 2022 13:03:59 -0800 Subject: [PATCH 28/36] Update frontend_server_breakpoint_test --- dwds/test/frontend_server_breakpoint_test.dart | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/dwds/test/frontend_server_breakpoint_test.dart b/dwds/test/frontend_server_breakpoint_test.dart index 0e671be46..7324f19ae 100644 --- a/dwds/test/frontend_server_breakpoint_test.dart +++ b/dwds/test/frontend_server_breakpoint_test.dart @@ -38,11 +38,9 @@ void main() { // currently redirected to a logger. As a result, it will be printed // regardless of the logger settings. final verboseCompiler = false; - - // TODO(https://github.com/dart-lang/webdev/issues/1591): Frontend server - // compilation is currently incompatible with sound null safety. - if (supportedNullSafetyModes.contains(NullSafety.weak)) { - group('shared context', () { + group( + 'shared context', + () { setUpAll(() async { setCurrentLogWriter(debug: debug); await context.setUp( @@ -136,6 +134,11 @@ void main() { await service.removeBreakpoint(isolateId, bp.id!); }); }); - }); - } + }, + // TODO(https://github.com/dart-lang/webdev/issues/1818) Re-enable. + skip: !supportedMode( + compilationMode: CompilationMode.frontendServer, + nullSafetyMode: NullSafety.weak, + ), + ); } From 93160fccbb62408166e1d3847f80346af677ebcb Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Tue, 13 Dec 2022 13:07:20 -0800 Subject: [PATCH 29/36] Update build_daemon_evaluate_test --- dwds/test/build_daemon_evaluate_test.dart | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/dwds/test/build_daemon_evaluate_test.dart b/dwds/test/build_daemon_evaluate_test.dart index 845cec737..5dacc394c 100644 --- a/dwds/test/build_daemon_evaluate_test.dart +++ b/dwds/test/build_daemon_evaluate_test.dart @@ -14,13 +14,21 @@ void main() async { // Enable verbose logging for debugging. final debug = false; - for (var nullSafety in supportedNullSafetyModes) { - group('${nullSafety.name} null safety |', () { - testAll( + for (var nullSafety in NullSafety.values) { + group( + '${nullSafety.name} null safety |', + () { + testAll( + compilationMode: CompilationMode.buildDaemon, + nullSafety: nullSafety, + debug: debug, + ); + }, + // TODO(https://github.com/dart-lang/webdev/issues/1818) Re-enable. + skip: !supportedMode( compilationMode: CompilationMode.buildDaemon, - nullSafety: nullSafety, - debug: debug, - ); - }); + nullSafetyMode: nullSafety, + ), + ); } } From bcd2882fad3a5fc85da4e6c692578a36379649c8 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Tue, 13 Dec 2022 13:09:52 -0800 Subject: [PATCH 30/36] Update frontend_server_callstack_test --- dwds/test/frontend_server_callstack_test.dart | 495 +++++++++--------- 1 file changed, 252 insertions(+), 243 deletions(-) diff --git a/dwds/test/frontend_server_callstack_test.dart b/dwds/test/frontend_server_callstack_test.dart index fa19eeb19..70479df5e 100644 --- a/dwds/test/frontend_server_callstack_test.dart +++ b/dwds/test/frontend_server_callstack_test.dart @@ -49,265 +49,274 @@ void main() { // Enable verbose logging for debugging. final debug = false; - for (var nullSafety in supportedNullSafetyModes) { - final soundNullSafety = nullSafety == NullSafety.sound; - final setup = soundNullSafety ? TestSetup.sound() : TestSetup.unsound(); - final context = setup.context; - - group('${nullSafety.name} null safety |', () { - setUpAll(() async { - setCurrentLogWriter(debug: debug); - await context.setUp( - compilationMode: CompilationMode.frontendServer, - enableExpressionEvaluation: true, - verboseCompiler: debug); - }); - - tearDownAll(() async { - await context.tearDown(); - }); - - group('callStack |', () { - late ChromeProxyService service; - VM vm; - late Isolate isolate; - late String isolateId; - ScriptList scripts; - late ScriptRef mainScript; - late ScriptRef testLibraryScript; - late Stream stream; - - setUp(() async { + for (var nullSafety in NullSafety.values) { + group( + '${nullSafety.name} null safety |', + () { + final soundNullSafety = nullSafety == NullSafety.sound; + final setup = + soundNullSafety ? TestSetup.sound() : TestSetup.unsound(); + final context = setup.context; + + setUpAll(() async { setCurrentLogWriter(debug: debug); - service = setup.service; - vm = await service.getVM(); - isolate = await service.getIsolate(vm.isolates!.first.id!); - isolateId = isolate.id!; - scripts = await service.getScripts(isolateId); - - 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')); + await context.setUp( + compilationMode: CompilationMode.frontendServer, + enableExpressionEvaluation: true, + verboseCompiler: debug); }); - tearDown(() async { - await service.resume(isolateId); + tearDownAll(() async { + await context.tearDown(); }); - Future onBreakPoint(BreakpointTestData breakpoint, - Future Function() body) async { - Breakpoint? bp; - try { - final bpId = breakpoint.bpId; - final script = breakpoint.script; - final line = - await context.findBreakpointLine(bpId, isolateId, script); - bp = await setup.service - .addBreakpointWithScriptUri(isolateId, script.uri!, line); - - expect(bp, isNotNull); - expect(bp.location, _matchBpLocation(script, line, 0)); - - await stream.firstWhere( - (Event event) => event.kind == EventKind.kPauseBreakpoint); - - await body(); - } finally { - // Remove breakpoint so it doesn't impact other tests or retries. - if (bp != null) { - await setup.service.removeBreakpoint(isolateId, bp.id!); + group('callStack |', () { + late ChromeProxyService service; + VM vm; + late Isolate isolate; + late String isolateId; + ScriptList scripts; + late ScriptRef mainScript; + late ScriptRef testLibraryScript; + late Stream stream; + + setUp(() async { + setCurrentLogWriter(debug: debug); + service = setup.service; + vm = await service.getVM(); + isolate = await service.getIsolate(vm.isolates!.first.id!); + isolateId = isolate.id!; + scripts = await service.getScripts(isolateId); + + 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')); + }); + + tearDown(() async { + await service.resume(isolateId); + }); + + Future onBreakPoint(BreakpointTestData breakpoint, + Future Function() body) async { + Breakpoint? bp; + try { + final bpId = breakpoint.bpId; + final script = breakpoint.script; + final line = + await context.findBreakpointLine(bpId, isolateId, script); + bp = await setup.service + .addBreakpointWithScriptUri(isolateId, script.uri!, line); + + expect(bp, isNotNull); + expect(bp.location, _matchBpLocation(script, line, 0)); + + await stream.firstWhere( + (Event event) => event.kind == EventKind.kPauseBreakpoint); + + await body(); + } finally { + // Remove breakpoint so it doesn't impact other tests or retries. + if (bp != null) { + await setup.service.removeBreakpoint(isolateId, bp.id!); + } } } - } - - Future testCallStack(List breakpoints, - {int frameIndex = 1}) async { - // Find lines the breakpoints are located on. - final lines = await Future.wait(breakpoints.map((frame) => context - .findBreakpointLine(frame.bpId, isolateId, frame.script))); - - // Get current stack. - final stack = await service.getStack(isolateId); - - // Verify the stack is correct. - expect(stack.frames!.length, greaterThanOrEqualTo(lines.length)); - final expected = [ - for (var i = 0; i < lines.length; i++) - _matchFrame( - breakpoints[i].script, breakpoints[i].function, lines[i]) - ]; - expect(stack.frames, containsAll(expected)); - - // Verify that expression evaluation is not failing. - final instance = - await service.evaluateInFrame(isolateId, frameIndex, 'true'); - expect(instance, isA()); - } - - test('breakpoint succeeds with correct callstack', () async { - // Expected breakpoints on the stack - final breakpoints = [ - BreakpointTestData( - 'printEnclosingObject', - 'printEnclosingObject', - mainScript, - ), - BreakpointTestData( - 'printEnclosingFunctionMultiLine', - 'printNestedObjectsMultiLine', - mainScript, - ), - BreakpointTestData( - 'callPrintEnclosingFunctionMultiLine', - '', - mainScript, - ), - ]; - await onBreakPoint( - breakpoints[0], () => testCallStack(breakpoints)); - }); - test('expression evaluation succeeds on parent frame', () async { - // Expected breakpoints on the stack - final breakpoints = [ - BreakpointTestData( - 'testLibraryClassConstructor', - 'new', - testLibraryScript, - ), - BreakpointTestData( - 'createLibraryObject', - 'printFieldFromLibraryClass', - mainScript, - ), - BreakpointTestData( - 'callPrintFieldFromLibraryClass', - '', - mainScript, - ), - ]; - await onBreakPoint(breakpoints[0], - () => testCallStack(breakpoints, frameIndex: 2)); - }); + Future testCallStack(List breakpoints, + {int frameIndex = 1}) async { + // Find lines the breakpoints are located on. + final lines = await Future.wait(breakpoints.map((frame) => context + .findBreakpointLine(frame.bpId, isolateId, frame.script))); + + // Get current stack. + final stack = await service.getStack(isolateId); + + // Verify the stack is correct. + expect(stack.frames!.length, greaterThanOrEqualTo(lines.length)); + final expected = [ + for (var i = 0; i < lines.length; i++) + _matchFrame( + breakpoints[i].script, breakpoints[i].function, lines[i]) + ]; + expect(stack.frames, containsAll(expected)); + + // Verify that expression evaluation is not failing. + final instance = + await service.evaluateInFrame(isolateId, frameIndex, 'true'); + expect(instance, isA()); + } - test('breakpoint inside a line gives correct callstack', () async { - // Expected breakpoints on the stack - final breakpoints = [ - BreakpointTestData( - 'newEnclosedClass', - 'new', - mainScript, - ), - BreakpointTestData( - 'printNestedObjectMultiLine', - 'printNestedObjectsMultiLine', - mainScript, - ), - BreakpointTestData( - 'callPrintEnclosingFunctionMultiLine', - '', - mainScript, - ), - ]; - await onBreakPoint( - breakpoints[0], () => testCallStack(breakpoints)); - }); + test('breakpoint succeeds with correct callstack', () async { + // Expected breakpoints on the stack + final breakpoints = [ + BreakpointTestData( + 'printEnclosingObject', + 'printEnclosingObject', + mainScript, + ), + BreakpointTestData( + 'printEnclosingFunctionMultiLine', + 'printNestedObjectsMultiLine', + mainScript, + ), + BreakpointTestData( + 'callPrintEnclosingFunctionMultiLine', + '', + mainScript, + ), + ]; + await onBreakPoint( + breakpoints[0], () => testCallStack(breakpoints)); + }); - test('breakpoint gives correct callstack after step out', () async { - // Expected breakpoints on the stack - final breakpoints = [ - BreakpointTestData( - 'newEnclosedClass', - 'new', - mainScript, - ), - BreakpointTestData( - 'printEnclosingObjectMultiLine', - 'printNestedObjectsMultiLine', - mainScript, - ), - BreakpointTestData( - 'callPrintEnclosingFunctionMultiLine', - '', - mainScript, - ), - ]; - await onBreakPoint(breakpoints[0], () async { - await service.resume(isolateId, step: 'Out'); - await stream.firstWhere( - (Event event) => event.kind == EventKind.kPauseInterrupted); - return testCallStack([breakpoints[1], breakpoints[2]]); + test('expression evaluation succeeds on parent frame', () async { + // Expected breakpoints on the stack + final breakpoints = [ + BreakpointTestData( + 'testLibraryClassConstructor', + 'new', + testLibraryScript, + ), + BreakpointTestData( + 'createLibraryObject', + 'printFieldFromLibraryClass', + mainScript, + ), + BreakpointTestData( + 'callPrintFieldFromLibraryClass', + '', + mainScript, + ), + ]; + await onBreakPoint(breakpoints[0], + () => testCallStack(breakpoints, frameIndex: 2)); }); - }); - test('breakpoint gives correct callstack after step in', () async { - // Expected breakpoints on the stack - final breakpoints = [ - BreakpointTestData( - 'newEnclosedClass', - 'new', - mainScript, - ), - BreakpointTestData( - 'printNestedObjectMultiLine', - 'printNestedObjectsMultiLine', - mainScript, - ), - BreakpointTestData( - 'callPrintEnclosingFunctionMultiLine', - '', - mainScript, - ), - ]; - await onBreakPoint(breakpoints[1], () async { - await service.resume(isolateId, step: 'Into'); - await stream.firstWhere( - (Event event) => event.kind == EventKind.kPauseInterrupted); - return testCallStack(breakpoints); + test('breakpoint inside a line gives correct callstack', () async { + // Expected breakpoints on the stack + final breakpoints = [ + BreakpointTestData( + 'newEnclosedClass', + 'new', + mainScript, + ), + BreakpointTestData( + 'printNestedObjectMultiLine', + 'printNestedObjectsMultiLine', + mainScript, + ), + BreakpointTestData( + 'callPrintEnclosingFunctionMultiLine', + '', + mainScript, + ), + ]; + await onBreakPoint( + breakpoints[0], () => testCallStack(breakpoints)); + }); + + test('breakpoint gives correct callstack after step out', () async { + // Expected breakpoints on the stack + final breakpoints = [ + BreakpointTestData( + 'newEnclosedClass', + 'new', + mainScript, + ), + BreakpointTestData( + 'printEnclosingObjectMultiLine', + 'printNestedObjectsMultiLine', + mainScript, + ), + BreakpointTestData( + 'callPrintEnclosingFunctionMultiLine', + '', + mainScript, + ), + ]; + await onBreakPoint(breakpoints[0], () async { + await service.resume(isolateId, step: 'Out'); + await stream.firstWhere( + (Event event) => event.kind == EventKind.kPauseInterrupted); + return testCallStack([breakpoints[1], breakpoints[2]]); + }); + }); + + test('breakpoint gives correct callstack after step in', () async { + // Expected breakpoints on the stack + final breakpoints = [ + BreakpointTestData( + 'newEnclosedClass', + 'new', + mainScript, + ), + BreakpointTestData( + 'printNestedObjectMultiLine', + 'printNestedObjectsMultiLine', + mainScript, + ), + BreakpointTestData( + 'callPrintEnclosingFunctionMultiLine', + '', + mainScript, + ), + ]; + await onBreakPoint(breakpoints[1], () async { + await service.resume(isolateId, step: 'Into'); + await stream.firstWhere( + (Event event) => event.kind == EventKind.kPauseInterrupted); + return testCallStack(breakpoints); + }); }); - }); - test('breakpoint gives correct callstack after step into chain calls', - () async { - // Expected breakpoints on the stack - final breakpoints = [ - BreakpointTestData( - 'createObjectWithMethod', - 'createObject', - mainScript, - ), - BreakpointTestData( - // This is currently incorrect, should be printObjectMultiLine. - // See issue: https://github.com/dart-lang/sdk/issues/48874 - 'printMultiLine', - 'printObjectMultiLine', - mainScript, - ), - BreakpointTestData( - 'callPrintObjectMultiLine', - '', - mainScript, - ), - ]; - final bp = BreakpointTestData( - 'printMultiLine', 'printObjectMultiLine', mainScript); - await onBreakPoint(bp, () async { - await service.resume(isolateId, step: 'Into'); - await stream.firstWhere( - (Event event) => event.kind == EventKind.kPauseInterrupted); - return testCallStack(breakpoints); + test( + 'breakpoint gives correct callstack after step into chain calls', + () async { + // Expected breakpoints on the stack + final breakpoints = [ + BreakpointTestData( + 'createObjectWithMethod', + 'createObject', + mainScript, + ), + BreakpointTestData( + // This is currently incorrect, should be printObjectMultiLine. + // See issue: https://github.com/dart-lang/sdk/issues/48874 + 'printMultiLine', + 'printObjectMultiLine', + mainScript, + ), + BreakpointTestData( + 'callPrintObjectMultiLine', + '', + mainScript, + ), + ]; + final bp = BreakpointTestData( + 'printMultiLine', 'printObjectMultiLine', mainScript); + await onBreakPoint(bp, () async { + await service.resume(isolateId, step: 'Into'); + await stream.firstWhere( + (Event event) => event.kind == EventKind.kPauseInterrupted); + return testCallStack(breakpoints); + }); }); }); - }); - }, // https://github.com/dart-lang/webdev/issues/1591 - skip: soundNullSafety); + }, + // TODO(https://github.com/dart-lang/webdev/issues/1818) Re-enable. + skip: !supportedMode( + compilationMode: CompilationMode.frontendServer, + nullSafetyMode: nullSafety, + ), + ); } }); } From dc66516e359cf8f4e9714d955fbf9a9385815a8d Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Tue, 13 Dec 2022 13:12:24 -0800 Subject: [PATCH 31/36] Update frontend_server_circular_evaluation_test --- ...rontend_server_circular_evaluate_test.dart | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/dwds/test/frontend_server_circular_evaluate_test.dart b/dwds/test/frontend_server_circular_evaluate_test.dart index 90c16a23e..3bba98e68 100644 --- a/dwds/test/frontend_server_circular_evaluate_test.dart +++ b/dwds/test/frontend_server_circular_evaluate_test.dart @@ -23,28 +23,30 @@ void main() async { Version.parse('2.19.0-150.0.dev'); group('Context with circular dependencies |', () { - for (var nullSafety in supportedNullSafetyModes) { + for (var nullSafety in NullSafety.values) { group('${nullSafety.name} null safety |', () { for (var indexBaseMode in IndexBaseMode.values) { - group( - 'with ${indexBaseMode.name} |', - () { - testAll( - compilationMode: CompilationMode.frontendServer, - indexBaseMode: indexBaseMode, - nullSafety: nullSafety, - useDebuggerModuleNames: true, - debug: debug, - ); - }, - skip: - // https://github.com/dart-lang/sdk/issues/49277 - indexBaseMode == IndexBaseMode.base && Platform.isWindows || - // https://github.com/dart-lang/webdev/issues/1591); - nullSafety == NullSafety.sound || - // Needs debugger module names change in the SDK to work. - !debuggerModuleNamesSupported, - ); + group('with ${indexBaseMode.name} |', () { + testAll( + compilationMode: CompilationMode.frontendServer, + indexBaseMode: indexBaseMode, + nullSafety: nullSafety, + useDebuggerModuleNames: true, + debug: debug, + ); + }, + skip: + // https://github.com/dart-lang/sdk/issues/49277 + indexBaseMode == IndexBaseMode.base && Platform.isWindows || + // https://github.com/dart-lang/webdev/issues/1591); + nullSafety == NullSafety.sound || + // Needs debugger module names change in the SDK to work. + !debuggerModuleNamesSupported || + // TODO(https://github.com/dart-lang/webdev/issues/1818) Re-enable. + !supportedMode( + compilationMode: CompilationMode.frontendServer, + nullSafetyMode: nullSafety, + )); } }); } From fe1b09bad27abf96ccb90a7ee19713f084328f80 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Tue, 13 Dec 2022 13:15:30 -0800 Subject: [PATCH 32/36] Update frontend_server_evaluate_test --- dwds/test/frontend_server_evaluate_test.dart | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dwds/test/frontend_server_evaluate_test.dart b/dwds/test/frontend_server_evaluate_test.dart index c021d1b61..98503c12a 100644 --- a/dwds/test/frontend_server_evaluate_test.dart +++ b/dwds/test/frontend_server_evaluate_test.dart @@ -24,7 +24,7 @@ void main() async { for (var useDebuggerModuleNames in [false, true]) { group('Debugger module names: $useDebuggerModuleNames |', () { - for (var nullSafety in supportedNullSafetyModes) { + for (var nullSafety in NullSafety.values) { group('${nullSafety.name} null safety |', () { for (var indexBaseMode in IndexBaseMode.values) { group( @@ -44,7 +44,13 @@ void main() async { // https://github.com/dart-lang/webdev/issues/1591 (nullSafety == NullSafety.sound) || // Needs debugger module names feature in SDK. - (useDebuggerModuleNames && !debuggerModuleNamesSupported), + (useDebuggerModuleNames && + !debuggerModuleNamesSupported) || + // TODO(https://github.com/dart-lang/webdev/issues/1818) Re-enable. + !supportedMode( + compilationMode: CompilationMode.frontendServer, + nullSafetyMode: nullSafety, + ), ); } }); From 7343cac09d680cace2000ca45dcafa815cc3b70b Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Tue, 13 Dec 2022 13:17:29 -0800 Subject: [PATCH 33/36] Remove all version compatibility helpers except for supportedMode --- dwds/test/utils/version_compatibility.dart | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/dwds/test/utils/version_compatibility.dart b/dwds/test/utils/version_compatibility.dart index 7a3335152..1ff63ae81 100644 --- a/dwds/test/utils/version_compatibility.dart +++ b/dwds/test/utils/version_compatibility.dart @@ -8,26 +8,6 @@ import 'package:pub_semver/pub_semver.dart'; import '../fixtures/context.dart'; -bool get versionSupportsWeakNullSafety => - Version.parse(Platform.version.split(' ')[0]).major < 3; - -List get supportedNullSafetyModes { - return versionSupportsWeakNullSafety - ? [NullSafety.sound, NullSafety.weak] - : [NullSafety.sound]; -} - -// TODO(https://github.com/dart-lang/webdev/issues/1591): Frontend server -// compilation is currently incompatible with sound null safety. -List supportedCompilationModes(NullSafety nullSafetyMode) { - return nullSafetyMode == NullSafety.sound - ? [CompilationMode.buildDaemon] - : [ - CompilationMode.buildDaemon, - CompilationMode.frontendServer, - ]; -} - bool supportedMode( {required CompilationMode compilationMode, required NullSafety nullSafetyMode}) { From c61d524c003c3171ee20e078b3c17ae3ebcc5c3c Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Tue, 13 Dec 2022 13:21:40 -0800 Subject: [PATCH 34/36] Revert changes to devfs --- frontend_server_common/lib/src/devfs.dart | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/frontend_server_common/lib/src/devfs.dart b/frontend_server_common/lib/src/devfs.dart index 37f4321be..25cd5c5ac 100644 --- a/frontend_server_common/lib/src/devfs.dart +++ b/frontend_server_common/lib/src/devfs.dart @@ -3,12 +3,10 @@ // found in the LICENSE file. // Note: this is a copy from flutter tools, updated to work with dwds tests -import 'dart:io'; import 'package:dwds/asset_reader.dart'; import 'package:file/file.dart'; import 'package:path/path.dart' as p; -import 'package:pub_semver/pub_semver.dart'; import 'asset_server.dart'; import 'bootstrap.dart'; @@ -87,12 +85,9 @@ class WebDevFS { assetServer.writeFile('main_module.digests', '{}'); - final sdkVersion = Version.parse(Platform.version.split(' ')[0]); - var sdk = - (soundNullSafety && sdkVersion.major < 3) ? dartSdkSound : dartSdk; - var sdkSourceMap = (soundNullSafety && sdkVersion.major < 3) - ? dartSdkSourcemapSound - : dartSdkSourcemap; + var sdk = soundNullSafety ? dartSdkSound : dartSdk; + var sdkSourceMap = + soundNullSafety ? dartSdkSourcemapSound : dartSdkSourcemap; assetServer.writeFile('dart_sdk.js', sdk.readAsStringSync()); assetServer.writeFile('dart_sdk.js.map', sdkSourceMap.readAsStringSync()); From 3a5a6c4b74cdb559551cf1f7d5611ea847aa486c Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Tue, 13 Dec 2022 13:23:44 -0800 Subject: [PATCH 35/36] Reference issues in chrome proxy service tests --- dwds/test/chrome_proxy_service_test.dart | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/dwds/test/chrome_proxy_service_test.dart b/dwds/test/chrome_proxy_service_test.dart index df3334caf..565b42f7c 100644 --- a/dwds/test/chrome_proxy_service_test.dart +++ b/dwds/test/chrome_proxy_service_test.dart @@ -502,8 +502,7 @@ void main() { !f.isConst! && !f.isFinal!), ])); - // TODO(https://github.com/dart-lang/webdev/issues/1818) Re-enable. - }, skip: true); + }, skip: 'https://github.com/dart-lang/webdev/issues/1818'); test('Runtime classes', () async { final testClass = await service.getObject( @@ -766,8 +765,7 @@ void main() { !f.isConst! && !f.isFinal!), ])); - // TODO(https://github.com/dart-lang/webdev/issues/1818) Re-enable. - }, skip: true); + }, skip: 'https://github.com/dart-lang/webdev/issues/1818'); test('offset/count parameters are ignored for bools', () async { final ref = await service.evaluate( @@ -809,7 +807,7 @@ void main() { expect(obj.kind, InstanceKind.kNull); expect(obj.classRef!.name, 'Null'); expect(obj.valueAsString, 'null'); - }, skip: true); + }, skip: 'https://github.com/dart-lang/webdev/issues/1818'); }); }); From 8012a27dd7a36f65e7ee64aac1864cd672c2cd54 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Tue, 13 Dec 2022 13:34:50 -0800 Subject: [PATCH 36/36] Update more tests --- dwds/test/dart_uri_file_uri_test.dart | 97 ++++++++++--------- .../frontend_server_asset_reader_test.dart | 7 +- .../proxy_server_asset_reader_test.dart | 7 +- 3 files changed, 63 insertions(+), 48 deletions(-) diff --git a/dwds/test/dart_uri_file_uri_test.dart b/dwds/test/dart_uri_file_uri_test.dart index edd34439f..3ac02a9d6 100644 --- a/dwds/test/dart_uri_file_uri_test.dart +++ b/dwds/test/dart_uri_file_uri_test.dart @@ -33,61 +33,68 @@ final testPackageDir = context.workingDirectory; // // These tests are separated out because we need a running isolate in order to // look up packages. +// TODO(https://github.com/dart-lang/webdev/issues/1818): Switch test over for +// testing sound null-safety. void main() { for (final compilationMode in CompilationMode.values) { - group('$compilationMode |', () { - for (final useDebuggerModuleNames in [false, true]) { - group('Debugger module names: $useDebuggerModuleNames |', () { - final appServerPath = - compilationMode == CompilationMode.frontendServer - ? 'web/main.dart' - : 'main.dart'; + group( + '$compilationMode |', + () { + for (final useDebuggerModuleNames in [false, true]) { + group('Debugger module names: $useDebuggerModuleNames |', () { + final appServerPath = + compilationMode == CompilationMode.frontendServer + ? 'web/main.dart' + : 'main.dart'; - final serverPath = - compilationMode == CompilationMode.frontendServer && - useDebuggerModuleNames - ? 'packages/_testPackage/lib/test_library.dart' - : 'packages/_test_package/test_library.dart'; + final serverPath = + compilationMode == CompilationMode.frontendServer && + useDebuggerModuleNames + ? 'packages/_testPackage/lib/test_library.dart' + : 'packages/_test_package/test_library.dart'; - final anotherServerPath = - compilationMode == CompilationMode.frontendServer && - useDebuggerModuleNames - ? 'packages/_test/lib/library.dart' - : 'packages/_test/library.dart'; + final anotherServerPath = + compilationMode == CompilationMode.frontendServer && + useDebuggerModuleNames + ? 'packages/_test/lib/library.dart' + : 'packages/_test/library.dart'; - setUpAll(() async { - await context.setUp( - compilationMode: compilationMode, - useDebuggerModuleNames: useDebuggerModuleNames, - ); - }); + setUpAll(() async { + await context.setUp( + compilationMode: compilationMode, + useDebuggerModuleNames: useDebuggerModuleNames, + ); + }); - tearDownAll(() async { - await context.tearDown(); - }); + tearDownAll(() async { + await context.tearDown(); + }); - test('file path to org-dartlang-app', () { - final webMain = - Uri.file(p.join(testPackageDir, 'web', 'main.dart')); - final uri = DartUri('$webMain'); - expect(uri.serverPath, appServerPath); - }); + test('file path to org-dartlang-app', () { + final webMain = + Uri.file(p.join(testPackageDir, 'web', 'main.dart')); + final uri = DartUri('$webMain'); + expect(uri.serverPath, appServerPath); + }); - test('file path to this package', () { - final testPackageLib = - Uri.file(p.join(testPackageDir, 'lib', 'test_library.dart')); - final uri = DartUri('$testPackageLib'); - expect(uri.serverPath, serverPath); - }); + test('file path to this package', () { + final testPackageLib = + Uri.file(p.join(testPackageDir, 'lib', 'test_library.dart')); + final uri = DartUri('$testPackageLib'); + expect(uri.serverPath, serverPath); + }); - test('file path to another package', () { - final testLib = Uri.file(p.join(testDir, 'lib', 'library.dart')); - final dartUri = DartUri('$testLib'); - expect(dartUri.serverPath, anotherServerPath); + test('file path to another package', () { + final testLib = Uri.file(p.join(testDir, 'lib', 'library.dart')); + final dartUri = DartUri('$testLib'); + expect(dartUri.serverPath, anotherServerPath); + }); }); - }); - } + } + }, // TODO(https://github.com/dart-lang/webdev/issues/1818): Re-enable. - }, skip: !versionSupportsWeakNullSafety); + skip: !supportedMode( + compilationMode: compilationMode, nullSafetyMode: NullSafety.weak), + ); } } diff --git a/dwds/test/readers/frontend_server_asset_reader_test.dart b/dwds/test/readers/frontend_server_asset_reader_test.dart index fbaa219b9..e5799b2bd 100644 --- a/dwds/test/readers/frontend_server_asset_reader_test.dart +++ b/dwds/test/readers/frontend_server_asset_reader_test.dart @@ -9,6 +9,7 @@ import 'package:dwds/src/readers/frontend_server_asset_reader.dart'; import 'package:path/path.dart' as p; import 'package:test/test.dart'; +import '../fixtures/context.dart'; import '../fixtures/utilities.dart'; import '../utils/version_compatibility.dart'; @@ -111,5 +112,9 @@ void main() { }); // TODO(https://github.com/dart-lang/webdev/issues/1818): Re-enable. Not sure // why this is passing locally but failing during CI tests. - }, skip: !versionSupportsWeakNullSafety); + }, + skip: !supportedMode( + compilationMode: CompilationMode.frontendServer, + nullSafetyMode: NullSafety.weak, + )); } diff --git a/dwds/test/readers/proxy_server_asset_reader_test.dart b/dwds/test/readers/proxy_server_asset_reader_test.dart index 0977a1395..53d6f3bec 100644 --- a/dwds/test/readers/proxy_server_asset_reader_test.dart +++ b/dwds/test/readers/proxy_server_asset_reader_test.dart @@ -38,6 +38,9 @@ void main() { .dartSourceContents('hello_world/foo.unsound.ddc.js.map'); expect(result, isNull); }); - // TODO(https://github.com/dart-lang/webdev/issues/1818) Re-enable. - }, skip: !versionSupportsWeakNullSafety); + }, + // TODO(https://github.com/dart-lang/webdev/issues/1818) Re-enable. + skip: !supportedMode( + compilationMode: CompilationMode.frontendServer, + nullSafetyMode: NullSafety.weak)); }