Skip to content

Commit 679271e

Browse files
MarkzipanCommit Queue
authored andcommitted
[ddc] Porting hot restart tests to the hot reload framework.
The old hot restart tests only tested DDC-internal state changes, not 'true' hot restart. The 'dart.hotRestart' runtime call is due to be deprecated. Change-Id: I34e32342bca6fabc886d8283e32ae510f8d49874 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389400 Reviewed-by: Nicholas Shahan <[email protected]> Commit-Queue: Mark Zhou <[email protected]>
1 parent d53711d commit 679271e

File tree

19 files changed

+563
-345
lines changed

19 files changed

+563
-345
lines changed

pkg/dev_compiler/test/hot_reload_suite.dart

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,9 @@ Future<void> main(List<String> args) async {
408408
label: testName);
409409
File.fromUri(previousTempUri).deleteSync();
410410
File.fromUri(currentTempUri).deleteSync();
411-
if (diffOutput != currentDiff) {
411+
var (filteredDiffOutput, filteredCurrentDiff) =
412+
_filterLineDeltas(diffOutput, currentDiff);
413+
if (filteredDiffOutput != filteredCurrentDiff) {
412414
reportDiffOutcome(
413415
file,
414416
'Unexpected diff found for $file:\n'
@@ -834,6 +836,22 @@ String _diffWithFileUris(Uri file1, Uri file2,
834836
return commented ? '$testDiffSeparator\n/*\n$output*/' : output;
835837
}
836838

839+
/// Removes diff lines that show added or removed newlines.
840+
///
841+
/// 'diff' can be unstable across platforms around newline offsets.
842+
(String, String) _filterLineDeltas(String diff1, String diff2) {
843+
bool isBlankLineOrDelta(String s) {
844+
return s.trim().isEmpty ||
845+
(s.startsWith('+') || s.startsWith('-')) && s.trim().length == 1;
846+
}
847+
848+
var diff1Lines = LineSplitter().convert(diff1)
849+
..removeWhere(isBlankLineOrDelta);
850+
var diff2Lines = LineSplitter().convert(diff2)
851+
..removeWhere(isBlankLineOrDelta);
852+
return (diff1Lines.join('\n'), diff2Lines.join('\n'));
853+
}
854+
837855
/// Returns the code and diff portions of [file].
838856
(String, String) _splitTestByDiff(Uri file) {
839857
final text = File.fromUri(file).readAsStringSync();

tests/dartdevc/hot_restart_late_test.dart

Lines changed: 0 additions & 135 deletions
This file was deleted.

tests/dartdevc/hot_restart_static_test.dart

Lines changed: 0 additions & 143 deletions
This file was deleted.

tests/dartdevc/hot_restart_timer_test.dart

Lines changed: 0 additions & 60 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"exclude": ["vm"]
3+
}

0 commit comments

Comments
 (0)