Skip to content

Commit

Permalink
comment the infra for stderr checking in beta
Browse files Browse the repository at this point in the history
  • Loading branch information
KodrAus committed Aug 11, 2021
1 parent 7ae1fad commit cf728d0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/compiletest.rs
Expand Up @@ -13,13 +13,24 @@ fn compile_fail() {
t.compile_fail("tests/compile-fail/*.rs");
}

// Compiler messages may change between versions
// We don't want to have to track these too closely for `bitflags`, but
// having some message to check makes sure user-facing errors are sensical.
//
// The approach we use is to run the test on all compilers, but only check stderr
// output on beta (which is the next stable release). We do this by default ignoring
// any `.stderr` files in the `compile-fail` directory, and copying `.stderr.beta` files
// when we happen to be running on a beta compiler.
fn prepare_stderr_files(path: impl AsRef<Path>) -> io::Result<()> {
for entry in fs::read_dir(path)? {
let entry = entry?;

if entry.path().extension().and_then(OsStr::to_str) == Some("beta") {
let renamed = entry.path().with_extension("");

// Unconditionally remove a corresponding `.stderr` file for a `.stderr.beta`
// file if it exists. On `beta` compilers, we'll recreate it. On other compilers,
// we don't want to end up checking it anyways.
if renamed.exists() {
fs::remove_file(&renamed)?;
}
Expand Down

0 comments on commit cf728d0

Please sign in to comment.