Skip to content

Commit b9e7cb6

Browse files
nshahanCommit Queue
authored and
Commit Queue
committed
[ddc] Move D8 implementation to D8SuiteRunner
Merge setup, generate bootstrap and run test logic into a single method. Change-Id: I5e0045c5e84b5a1966bff79bd37b759fe4b789bc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393440 Commit-Queue: Nicholas Shahan <[email protected]> Reviewed-by: Lasse Nielsen <[email protected]> Reviewed-by: Mark Zhou <[email protected]>
1 parent 7c3e294 commit b9e7cb6

File tree

1 file changed

+17
-45
lines changed

1 file changed

+17
-45
lines changed

pkg/dev_compiler/test/hot_reload_suite.dart

Lines changed: 17 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -697,21 +697,7 @@ abstract class HotReloadSuiteRunner {
697697
var testPassed = false;
698698
switch (options.runtime) {
699699
case RuntimePlatforms.d8:
700-
// Run the compiled JS generations with D8.
701-
_print('Creating D8 hot reload test suite.', label: test.name);
702-
// TODO(nshahan): Clean this up! The cast here just serves as a way to
703-
// allow for smaller refactor changes.
704-
final d8Suite = (this as D8SuiteRunner)
705-
..bootstrapJsUri =
706-
tempDirectory.uri.resolve('generation0/bootstrap.js')
707-
..outputSink = outputSink;
708-
await d8Suite.setupTest(
709-
testName: test.name,
710-
scriptDescriptors: filesystem!.scriptDescriptorForBootstrap,
711-
generationToModifiedFiles: filesystem!.generationsToModifiedFilePaths,
712-
);
713-
final d8ExitCode = await d8Suite.runTestOld(testName: test.name);
714-
testPassed = d8ExitCode == 0;
700+
throw UnsupportedError('Now implemented in D8SuiteRunner.');
715701
case RuntimePlatforms.chrome:
716702
// Run the compiled JS generations with Chrome.
717703
_print('Creating Chrome hot reload test suite.', label: test.name);
@@ -989,49 +975,35 @@ class D8SuiteRunner extends DdcSuiteRunner {
989975
buildRootUri.resolve('gen/utils/ddc/canary/sdk/ddc/dart_sdk.js');
990976
final Uri ddcModuleLoaderJsUri =
991977
sdkRoot.resolve('pkg/dev_compiler/lib/js/ddc/ddc_module_loader.js');
992-
late StreamSink<List<int>> outputSink;
993978

994979
D8SuiteRunner(super.options);
995980

996-
String _generateBootstrapper({
997-
required List<Map<String, String?>> scriptDescriptors,
998-
required ddc_helpers.FileDataPerGeneration generationToModifiedFiles,
999-
}) {
1000-
return ddc_helpers.generateD8Bootstrapper(
981+
@override
982+
Future<bool> runTest(
983+
HotReloadTest test, Directory tempDirectory, IOSink outputSink) async {
984+
// Run the compiled JS generations with D8.
985+
_print('Creating D8 hot reload test suite.', label: test.name);
986+
bootstrapJsUri = tempDirectory.uri.resolve('generation0/bootstrap.js');
987+
_print('Preparing to run D8 test.', label: test.name);
988+
final d8BootstrapJS = ddc_helpers.generateD8Bootstrapper(
1001989
ddcModuleLoaderJsPath: escapedString(ddcModuleLoaderJsUri.toFilePath()),
1002990
dartSdkJsPath: escapedString(dartSdkJsUri.toFilePath()),
1003991
entrypointModuleName: escapedString(entrypointModuleName),
1004992
entrypointLibraryExportName: escapedString(entrypointLibraryExportName),
1005-
scriptDescriptors: scriptDescriptors,
1006-
modifiedFilesPerGeneration: generationToModifiedFiles,
993+
scriptDescriptors: filesystem!.scriptDescriptorForBootstrap,
994+
modifiedFilesPerGeneration: filesystem!.generationsToModifiedFilePaths,
1007995
);
1008-
}
1009-
1010-
Future<void> setupTest({
1011-
String? testName,
1012-
List<Map<String, String?>>? scriptDescriptors,
1013-
ddc_helpers.FileDataPerGeneration? generationToModifiedFiles,
1014-
}) async {
1015-
_print('Preparing to run D8 test.', label: testName);
1016-
if (scriptDescriptors == null || generationToModifiedFiles == null) {
1017-
throw ArgumentError('D8SuiteRunner requires that "scriptDescriptors" '
1018-
'and "generationToModifiedFiles" be provided during setup.');
1019-
}
1020-
final d8BootstrapJS = _generateBootstrapper(
1021-
scriptDescriptors: scriptDescriptors,
1022-
generationToModifiedFiles: generationToModifiedFiles);
1023-
File.fromUri(bootstrapJsUri).writeAsStringSync(d8BootstrapJS);
1024-
_debugPrint('Writing D8 bootstrapper: $bootstrapJsUri', label: testName);
1025-
}
1026-
1027-
Future<int> runTestOld({String? testName}) async {
996+
_debugPrint('Writing D8 bootstrapper: $bootstrapJsUri', label: test.name);
997+
final bootstrapJSFile = File.fromUri(bootstrapJsUri)
998+
..writeAsStringSync(d8BootstrapJS);
999+
_debugPrint('Running test in D8.', label: test.name);
10281000
final process = await startProcess('D8', config.binary.toFilePath(), [
10291001
config.sealNativeObjectScript.toFilePath(),
10301002
config.preamblesScript.toFilePath(),
1031-
bootstrapJsUri.toFilePath()
1003+
bootstrapJSFile.path
10321004
]);
10331005
unawaited(process.stdout.pipe(outputSink));
1034-
return process.exitCode;
1006+
return await process.exitCode == 0;
10351007
}
10361008
}
10371009

0 commit comments

Comments
 (0)