@@ -584,9 +584,7 @@ abstract class HotReloadSuiteRunner {
584584 label: test.name);
585585 File .fromUri (previousTempUri).deleteSync ();
586586 File .fromUri (currentTempUri).deleteSync ();
587- var (filteredDiffOutput, filteredCurrentDiff) =
588- _filterLineDeltas (diffOutput, currentDiff);
589- if (filteredDiffOutput != filteredCurrentDiff) {
587+ if (diffOutput != currentDiff) {
590588 reportDiffOutcome (
591589 test.name,
592590 currentEdit.fileUri,
@@ -906,47 +904,23 @@ abstract class HotReloadSuiteRunner {
906904 {String label = '' , bool commented = true , bool trimHeaders = true }) {
907905 final file1Path = file1.toFilePath ();
908906 final file2Path = file2.toFilePath ();
909- final diffArgs = [
910- '-u' ,
911- '--width=120' ,
912- '--expand-tabs' ,
913- file1Path,
914- file2Path
915- ];
916- _debugPrint ("Running diff with 'diff ${diffArgs .join (' ' )}'." ,
907+ final diffArgs = ['diff' , '-u' , file1Path, file2Path];
908+ _debugPrint ("Running diff with 'git diff ${diffArgs .join (' ' )}'." ,
917909 label: label);
918- final diffProcess = Process .runSync ('diff ' , diffArgs);
910+ final diffProcess = Process .runSync ('git ' , diffArgs);
919911 final errOutput = diffProcess.stderr as String ;
920912 if (errOutput.isNotEmpty) {
921- throw Exception ('diff failed with:\n $errOutput ' );
913+ throw Exception ('git diff failed with:\n $errOutput ' );
922914 }
923915 var output = diffProcess.stdout as String ;
924916 if (trimHeaders) {
925- // Skip the first two lines.
917+ // Skip the diff header. 'git diff' has 5 lines in its header .
926918 // TODO(markzipan): Add support for Windows-style line endings.
927- output = output.split ('\n ' ).skip (2 ).join ('\n ' );
919+ output = output.split ('\n ' ).skip (5 ).join ('\n ' );
928920 }
929921 return commented ? '$testDiffSeparator \n /*\n $output */' : output;
930922 }
931923
932- /// Removes diff lines that show added or removed newlines.
933- ///
934- /// 'diff' can be unstable across platforms around newline offsets.
935- (String , String ) _filterLineDeltas (String diff1, String diff2) {
936- bool isBlankLineOrDelta (String s) {
937- var trimmed = s.trim ();
938- return trimmed.isEmpty ||
939- (trimmed.startsWith ('+' ) || trimmed.startsWith ('-' )) &&
940- trimmed.length == 1 ;
941- }
942-
943- var diff1Lines = LineSplitter ().convert (diff1)
944- ..removeWhere (isBlankLineOrDelta);
945- var diff2Lines = LineSplitter ().convert (diff2)
946- ..removeWhere (isBlankLineOrDelta);
947- return (diff1Lines.join ('\n ' ), diff2Lines.join ('\n ' ));
948- }
949-
950924 /// Returns the code and diff portions of [file] with all leading and trailing
951925 /// whitespace trimmed.
952926 (String , String ) _splitTestByDiff (Uri file) {
0 commit comments