diff --git a/testing/file_test/autoupdate.cpp b/testing/file_test/autoupdate.cpp index 718d7e60f8d3..b945e42feea6 100644 --- a/testing/file_test/autoupdate.cpp +++ b/testing/file_test/autoupdate.cpp @@ -286,17 +286,18 @@ auto AutoupdateFileTest( .insert({non_check_line.line_number(), ++output_line_number}) .second); + // If we just added the AUTOUPDATE line, include any early STDERR lines + // now, so that the initial batch of CHECK lines have STDERR before + // STDOUT. This also ensures we don't insert a blank line before the + // STDERR checks if there are no more lines after AUTOUPDATE. + if (autoupdate_line_number == non_check_line.line_number()) { + add_check_lines(stderr_check_lines, stderr_check_line, + non_check_line.line_number(), non_check_line.indent()); + } + // STDOUT check lines are placed after the line they refer to, or at the // end of the file if none of them refers to a line. if (reached_autoupdate && any_attached_stdout_lines) { - // Include any early STDERR lines now, so that the initial batch of - // CHECK lines have STDERR before STDOUT. - if (autoupdate_line_number == non_check_line.line_number()) { - add_check_lines(stderr_check_lines, stderr_check_line, - non_check_line.line_number(), - non_check_line.indent()); - } - add_check_lines(stdout_check_lines, stdout_check_line, non_check_line.line_number(), non_check_line.indent()); } diff --git a/toolchain/driver/testdata/fail_missing_file.carbon b/toolchain/driver/testdata/fail_missing_file.carbon index 45528c34d07c..3d87be4cd51d 100644 --- a/toolchain/driver/testdata/fail_missing_file.carbon +++ b/toolchain/driver/testdata/fail_missing_file.carbon @@ -5,5 +5,4 @@ // ARGS: compile --phase=lex nonexistent.carbon // // AUTOUPDATE - // CHECK:STDERR: nonexistent.carbon: Error opening file for read: No such file or directory