mirror of
https://gitee.com/openharmony/third_party_rust_bitflags
synced 2024-11-23 07:10:11 +00:00
allow stderr to be ignored on non-beta compilers
This commit is contained in:
parent
ab6c459cb4
commit
eb31b1ae4b
@ -24,6 +24,7 @@ compiler_builtins = { version = '0.1.2', optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
trybuild = "1.0"
|
||||
rustversion = "1.0"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
serde_json = "1.0"
|
||||
|
1
tests/compile-fail/.gitignore
vendored
Normal file
1
tests/compile-fail/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.stderr
|
@ -1,5 +1,44 @@
|
||||
use std::{
|
||||
fs,
|
||||
ffi::OsStr,
|
||||
io,
|
||||
path::Path,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn compile_fail() {
|
||||
prepare_stderr_files("tests/compile-fail").unwrap();
|
||||
|
||||
let t = trybuild::TestCases::new();
|
||||
t.compile_fail("tests/compile-fail/*.rs");
|
||||
}
|
||||
|
||||
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("");
|
||||
|
||||
if renamed.exists() {
|
||||
fs::remove_file(&renamed)?;
|
||||
}
|
||||
|
||||
rename_beta_stderr(entry.path(), renamed)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[rustversion::beta]
|
||||
fn rename_beta_stderr(from: impl AsRef<Path>, to: impl AsRef<Path>) -> io::Result<()> {
|
||||
fs::copy(from, to)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[rustversion::not(beta)]
|
||||
fn rename_beta_stderr(_: impl AsRef<Path>, _: impl AsRef<Path>) -> io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user