When running under compare-mode=nll, generate expected output to foo.nll.stderr
This allows easy revision of the update-references.sh script (included here) so that it can update the expected output for nll rather than stderr. It also reminds the rustc developer via the filename that they are looking at output generated under comapre-mode=nll. One could argue that there is still a problem with the strategy encoded here: if we reach a scenario where a change to the compiler brings the output under AST and NLL modes back into sync, this code will continue to still generate output to distinct `foo.stderr` and `foo.nll.stderr` files, and will continue to copy those two files back to corresponding distinct files in the source tree, even if the *content* of the two files is now the same. * Arguably the "right thing" to do in that case is to remove the `foo.nll.stderr` file entirely. * However, I think the real answer is that we will probably want to double-check such cases by hand anyway. We should be regularly double-checking the diffs between `foo.stderr` and `foo.nll.stderr`, and if we see a zero-diff case, then we should evaluate whether that is correct, and if so, remove the file by hand.) * In any case, I think the default behavior encoded here (or at least *intended* to be encoded here) is superior to the alternative of *only* generating a `foo.nll.stderr` file if one already existed in the source tree at the time that `compiletest` was invoked (and otherwise unconditionally generating a `foo.stderr` file, as was the behavior prior to this commit), because that alternative is more likely to cause rustc developers to overwrite a `foo.stderr` file with the stderr output from a compare-mode=nll run, which will then break the *normal* `compiletest` run and probably be much more confusing for the average rustc developer.
This commit is contained in:
parent
1a4326d3fb
commit
33bcb4ed16
@ -33,6 +33,7 @@ shift
|
||||
|
||||
while [[ "$1" != "" ]]; do
|
||||
STDERR_NAME="${1/%.rs/.stderr}"
|
||||
STDERR_NLL_NAME="${1/%.rs/.nll.stderr}"
|
||||
STDOUT_NAME="${1/%.rs/.stdout}"
|
||||
shift
|
||||
if [ -f $BUILD_DIR/$STDOUT_NAME ] && \
|
||||
@ -45,4 +46,9 @@ while [[ "$1" != "" ]]; do
|
||||
echo updating $MYDIR/$STDERR_NAME
|
||||
cp $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME
|
||||
fi
|
||||
if [ -f $BUILD_DIR/$STDERR_NLL_NAME ] && \
|
||||
! (diff $BUILD_DIR/$STDERR_NLL_NAME $MYDIR/$STDERR_NLL_NAME >& /dev/null); then
|
||||
echo updating $MYDIR/$STDERR_NLL_NAME
|
||||
cp $BUILD_DIR/$STDERR_NLL_NAME $MYDIR/$STDERR_NLL_NAME
|
||||
fi
|
||||
done
|
||||
|
@ -2811,7 +2811,7 @@ impl<'test> TestCx<'test> {
|
||||
normalized
|
||||
}
|
||||
|
||||
fn load_expected_output(&self, kind: &str) -> String {
|
||||
fn expected_output_path(&self, kind: &str) -> PathBuf {
|
||||
let mut path = expected_output_path(&self.testpaths,
|
||||
self.revision,
|
||||
&self.config.compare_mode,
|
||||
@ -2822,6 +2822,11 @@ impl<'test> TestCx<'test> {
|
||||
path = expected_output_path(&self.testpaths, self.revision, &None, kind);
|
||||
}
|
||||
|
||||
path
|
||||
}
|
||||
|
||||
fn load_expected_output(&self, kind: &str) -> String {
|
||||
let path = self.expected_output_path(kind);
|
||||
if path.exists() {
|
||||
match self.load_expected_output_from_path(&path) {
|
||||
Ok(x) => x,
|
||||
@ -2875,7 +2880,8 @@ impl<'test> TestCx<'test> {
|
||||
}
|
||||
}
|
||||
|
||||
let output_file = self.output_base_name().with_extension(kind);
|
||||
let expected_output_path = self.expected_output_path(kind);
|
||||
let output_file = self.output_base_name().with_file_name(&expected_output_path);
|
||||
match File::create(&output_file).and_then(|mut f| f.write_all(actual.as_bytes())) {
|
||||
Ok(()) => {}
|
||||
Err(e) => self.fatal(&format!(
|
||||
|
Loading…
Reference in New Issue
Block a user