-
Notifications
You must be signed in to change notification settings - Fork 85
Plumbing flags required for running tests with the DDC module system. #2295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
61f964b
e17f872
6a01aad
2e4d0a2
188a5ae
c055748
cc66e55
e37da6b
dcbea77
40ac194
83d5feb
6d5bcfe
2cff2ce
84ee640
77bd6eb
43e6446
69fa508
7330d99
b30a41f
5b9854e
c606696
dafca8a
819bcf5
42c674e
f4ae7e2
4f143c9
ac28b96
e4c7df0
dbcb892
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
export 'src/utilities/ddc_names.dart'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
// 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:async'; | ||
import 'dart:convert'; | ||
import 'dart:io'; | ||
|
||
|
@@ -14,8 +15,9 @@ import 'package:dwds/src/connections/app_connection.dart'; | |
import 'package:dwds/src/connections/debug_connection.dart'; | ||
import 'package:dwds/src/debugging/webkit_debugger.dart'; | ||
import 'package:dwds/src/loaders/build_runner_require.dart'; | ||
import 'package:dwds/src/loaders/frontend_server_legacy.dart'; | ||
import 'package:dwds/src/loaders/frontend_server_require.dart'; | ||
import 'package:dwds/src/loaders/require.dart'; | ||
import 'package:dwds/src/loaders/strategy.dart'; | ||
import 'package:dwds/src/readers/proxy_server_asset_reader.dart'; | ||
import 'package:dwds/src/services/chrome_proxy_service.dart'; | ||
import 'package:dwds/src/services/expression_compiler_service.dart'; | ||
|
@@ -58,7 +60,17 @@ Matcher isRPCErrorWithCode(int code) => | |
isA<RPCError>().having((e) => e.code, 'code', equals(code)); | ||
Matcher throwsRPCErrorWithCode(int code) => throwsA(isRPCErrorWithCode(code)); | ||
|
||
enum CompilationMode { buildDaemon, frontendServer } | ||
enum CompilationMode { | ||
buildDaemon, | ||
// Uses DDC's AMD module system | ||
frontendServer, | ||
// Uses DDC's DDC/legacy module system | ||
frontendServerDdc; | ||
Markzipan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
bool get usesFrontendServer => | ||
Markzipan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
this == CompilationMode.frontendServer || | ||
this == CompilationMode.frontendServerDdc; | ||
} | ||
|
||
class TestContext { | ||
final TestProject project; | ||
|
@@ -204,7 +216,7 @@ class TestContext { | |
ExpressionCompiler? expressionCompiler; | ||
AssetReader assetReader; | ||
Stream<BuildResults> buildResults; | ||
RequireStrategy requireStrategy; | ||
LoadStrategy loadStrategy; | ||
String basePath = ''; | ||
String filePathToServe = project.filePathToServe; | ||
|
||
|
@@ -268,7 +280,7 @@ class TestContext { | |
expressionCompiler = ddcService; | ||
} | ||
|
||
requireStrategy = BuildRunnerRequireStrategyProvider( | ||
loadStrategy = BuildRunnerRequireStrategyProvider( | ||
assetHandler, | ||
testSettings.reloadConfiguration, | ||
assetReader, | ||
|
@@ -332,7 +344,73 @@ class TestContext { | |
basePath = webRunner.devFS.assetServer.basePath; | ||
assetReader = webRunner.devFS.assetServer; | ||
_assetHandler = webRunner.devFS.assetServer.handleRequest; | ||
requireStrategy = FrontendServerRequireStrategyProvider( | ||
loadStrategy = FrontendServerRequireStrategyProvider( | ||
testSettings.reloadConfiguration, | ||
assetReader, | ||
packageUriMapper, | ||
() async => {}, | ||
buildSettings, | ||
).strategy; | ||
|
||
buildResults = const Stream<BuildResults>.empty(); | ||
} | ||
break; | ||
case CompilationMode.frontendServerDdc: | ||
Markzipan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
filePathToServe = webCompatiblePath([ | ||
project.directoryToServe, | ||
project.filePathToServe, | ||
]); | ||
|
||
_logger.info('Serving: $filePathToServe'); | ||
|
||
final entry = p.toUri( | ||
p.join(project.webAssetsPath, project.dartEntryFileName), | ||
); | ||
final fileSystem = LocalFileSystem(); | ||
final packageUriMapper = await PackageUriMapper.create( | ||
fileSystem, | ||
project.packageConfigFile, | ||
useDebuggerModuleNames: testSettings.useDebuggerModuleNames, | ||
); | ||
|
||
final compilerOptions = TestCompilerOptions( | ||
nullSafety: project.nullSafety, | ||
experiments: buildSettings.experiments, | ||
canaryFeatures: buildSettings.canaryFeatures, | ||
moduleFormat: 'ddc', | ||
); | ||
|
||
_webRunner = ResidentWebRunner( | ||
mainUri: entry, | ||
urlTunneler: debugSettings.urlEncoder, | ||
projectDirectory: p.toUri(project.absolutePackageDirectory), | ||
packageConfigFile: project.packageConfigFile, | ||
packageUriMapper: packageUriMapper, | ||
fileSystemRoots: [p.toUri(project.absolutePackageDirectory)], | ||
fileSystemScheme: 'org-dartlang-app', | ||
outputPath: outputDir.path, | ||
compilerOptions: compilerOptions, | ||
sdkLayout: sdkLayout, | ||
verbose: testSettings.verboseCompiler, | ||
); | ||
|
||
final assetServerPort = await findUnusedPort(); | ||
await webRunner.run( | ||
fileSystem, | ||
appMetadata.hostname, | ||
assetServerPort, | ||
filePathToServe, | ||
); | ||
|
||
if (testSettings.enableExpressionEvaluation) { | ||
expressionCompiler = webRunner.expressionCompiler; | ||
} | ||
|
||
basePath = webRunner.devFS.assetServer.basePath; | ||
assetReader = webRunner.devFS.assetServer; | ||
_assetHandler = webRunner.devFS.assetServer.handleRequest; | ||
loadStrategy = FrontendServerLegacyStrategyProvider( | ||
testSettings.reloadConfiguration, | ||
assetReader, | ||
packageUriMapper, | ||
|
@@ -380,6 +458,10 @@ class TestContext { | |
), | ||
); | ||
} | ||
|
||
// The debugger tab must be enabled and connected before certain | ||
// listeners in DWDS run. | ||
final tabConnectionCompleter = Completer(); | ||
final connection = ChromeConnection('localhost', debugPort); | ||
|
||
_testServer = await TestServer.start( | ||
|
@@ -389,11 +471,12 @@ class TestContext { | |
port: port, | ||
assetHandler: assetHandler, | ||
assetReader: assetReader, | ||
strategy: requireStrategy, | ||
strategy: loadStrategy, | ||
target: project.directoryToServe, | ||
buildResults: buildResults, | ||
chromeConnection: () async => connection, | ||
autoRun: testSettings.autoRun, | ||
completeBeforeHandlingConnections: tabConnectionCompleter.future, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'l like to understand this better - could you please add a description in comments describing why it this needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a short description to the this PR's description.
Basically, there's a race condition between two 'sister' async events that only succeeds if events happen to interleave. Basically Promise Train A -> B -> C and Train X -> Y -> Z hangs iff the execution is not A -> X -> B -> Y (or something similar). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am curious about the exact details here (given that the plumbing changes the interface and will need a major version update) - could you please add more information on what exactly is the set of events and how it hangs? Also adding the comments in code so we can avoid this in the future. |
||
); | ||
|
||
_appUrl = basePath.isEmpty | ||
|
@@ -406,7 +489,9 @@ class TestContext { | |
if (tab != null) { | ||
_tabConnection = await tab.connect(); | ||
await tabConnection.runtime.enable(); | ||
await tabConnection.debugger.enable(); | ||
await tabConnection.debugger | ||
.enable() | ||
.then((_) => tabConnectionCompleter.complete()); | ||
} else { | ||
throw StateError('Unable to connect to tab.'); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
@Tags(['daily']) | ||
@TestOn('vm') | ||
@Timeout(Duration(minutes: 5)) | ||
|
||
import 'dart:io'; | ||
|
||
import 'package:test/test.dart'; | ||
import 'package:test_common/test_sdk_configuration.dart'; | ||
|
||
import 'evaluate_common.dart'; | ||
import 'fixtures/context.dart'; | ||
import 'fixtures/project.dart'; | ||
|
||
void main() async { | ||
// Enable verbose logging for debugging. | ||
final debug = false; | ||
|
||
final provider = | ||
TestSdkConfigurationProvider(verbose: debug, ddcModuleSystem: true); | ||
tearDownAll(provider.dispose); | ||
|
||
for (var useDebuggerModuleNames in [false, true]) { | ||
group('Debugger module names: $useDebuggerModuleNames |', () { | ||
final nullSafety = NullSafety.sound; | ||
group('${nullSafety.name} null safety | DDC module system |', () { | ||
for (var indexBaseMode in IndexBaseMode.values) { | ||
group( | ||
'with ${indexBaseMode.name} |', | ||
() { | ||
testAll( | ||
provider: provider, | ||
compilationMode: CompilationMode.frontendServerDdc, | ||
indexBaseMode: indexBaseMode, | ||
nullSafety: nullSafety, | ||
useDebuggerModuleNames: useDebuggerModuleNames, | ||
debug: debug, | ||
); | ||
}, | ||
// https://github.com/dart-lang/sdk/issues/49277 | ||
skip: indexBaseMode == IndexBaseMode.base && Platform.isWindows, | ||
); | ||
} | ||
}); | ||
}); | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.