31dc969da2
Refactors the hot reload test suite to support non-FE server based hot reload. Similar to DartPad it uses a DDC process running in '--persistent_worker' mode and sends bazel requests for each reload. I call this "stateless" mode because the compilation process itself is not maintaining any state. The necessary metadata is passed from one compilation to the other via a delta dill. This differs from the "stateful" mode where the FE server persists a kernel AST in memory from one compilation to the next. Disregarding the browsers there are effectively 3 run modes now: - web stateful - web stateless (new) - vm stateful One key difference between the "stateless" and "stateful" modes is the output format of the JS files. In stateful mode DDC emits a file per library being re-compiled. In stateless mode DDC is emitting a single file with all the libraries. DartPad's workflow is slightly simpler than what's seen in the stateless mode here. It only supports editing a single library so we skip processing any metadata. To simulate this I've added the special 'main_only' which passes a single library for each reload generation. I've verified that this would fail if not for the change recently made to ddc_module_loader.js. Change-Id: If05da6dbeded4dd20e9e6d9dfaed52151541a19b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434340 Commit-Queue: Nate Biggs <natebiggs@google.com> Reviewed-by: Mark Zhou <markzipan@google.com> Reviewed-by: Kevin Moore <kevmoo@google.com> Reviewed-by: Nicholas Shahan <nshahan@google.com>
39 lines
844 B
Dart
39 lines
844 B
Dart
// Copyright (c) 2025, 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 'package:expect/expect.dart';
|
|
import 'package:reload_test/reload_test_utils.dart';
|
|
|
|
import 'b.dart';
|
|
|
|
f() => "$line part4";
|
|
|
|
Future<void> main() async {
|
|
var last = f();
|
|
Expect.equals('part1 part2', last);
|
|
Expect.equals(0, hotReloadGeneration);
|
|
await hotReload();
|
|
|
|
last = f();
|
|
Expect.equals('part1 part3', last);
|
|
Expect.equals(1, hotReloadGeneration);
|
|
await hotReload();
|
|
|
|
last = f();
|
|
Expect.equals('part1 part4', last);
|
|
Expect.equals(2, hotReloadGeneration);
|
|
}
|
|
|
|
/** DIFF **/
|
|
/*
|
|
|
|
import 'b.dart';
|
|
|
|
-f() => "$line part3";
|
|
+f() => "$line part4";
|
|
|
|
Future<void> main() async {
|
|
var last = f();
|
|
*/
|