dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.09k stars 1.56k forks source link

[ddc] pkg/dev_compiler/test/expression_compiler/ tests failing in canary mode with "ddc" modules #56642

Open nshahan opened 2 weeks ago

nshahan commented 2 weeks ago

I'm expecting that all all expression compiler tests running in canary mode with "ddc" modules will be broken temporarily.

I'm approving these:

pkg/dev_compiler/test/expression_compiler/assertions_enabled_ddc_test RuntimeError (expected Pass)
pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_dart_2_17_test RuntimeError (expected Pass)
pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_dart_3_0_test RuntimeError (expected Pass)
pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_ddc_agnostic_shard_1_test Timeout (expected Pass)
pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_ddc_agnostic_shard_2_test Timeout (expected Pass)
pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_ddc_null_safe_test Timeout (expected Pass)
pkg/dev_compiler/test/expression_compiler/runtime_debugger_api_test Timeout (expected Pass)

Feel free to add more as they are detected as failures.

These should start running again after the changes to move class hierarchy linking are landed. At that time the bootstrap code will need updates to start the app using the updated "ddc" module format.

akshit397a commented 1 week ago

To Address the above issue i suggest that

  1. Approve the Temporary Failures of the specified tests => Runtime Error: Mark the tests as expected failures. => Timeouts: Document the expected timeouts.

  2. Bootstrap Code Update: Once the changes are in place, update the bootstrap code whose sample is given below.

  3. Re-enable Tests: Resume running the tests after the bootstrap code has been updated.

  4. Verify : Add more tests to the approval list if new failures are detected.

Sample 1:

import './ddc_module_loader.js'; function main() { import('./lib/main.dart').catch((error) => console.error(error)); runApp(); } main(); function runApp() { const root = document.createElement('div'); root.id = 'root'; document.body.appendChild(root); renderApp(root); } function renderApp(container) { const app = new App(); container.appendChild(app.render()); }

Sample 2:

import 'package:my_app/main.dart' as app; void main() { ddcBootstrap(() { app.main(); }); }

void ddcBootstrap(Function startApp) { loadModules().then((_) { startApp(); }).catchError((error) { print("Error loading modules: $error"); }); }

Future loadModules() async { await Future.wait([ loadModule('core'), loadModule('runtime'), loadModule('app_module'), ]); }

Future loadModule(String moduleName) async { final moduleUrl = '/path/to/ddc/modules/$moduleName.js'; await loadJavaScriptModule(moduleUrl); }

Future loadJavaScriptModule(String url) { final completer = Completer(); final script = ScriptElement() ..src = url ..onLoad.listen(() => completer.complete()) ..onError.listen(() => completer.completeError("Failed to load module: $url")); document.head?.append(script); return completer.future; }

According to me these woulde work