-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Misc tweaks #50276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Misc tweaks #50276
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,39 @@ use std::str; | |
|
||
use extract_gdb_version; | ||
|
||
#[cfg(windows)] | ||
fn disable_error_reporting<F: FnOnce() -> R, R>(f: F) -> R { | ||
use std::sync::Mutex; | ||
const SEM_NOGPFAULTERRORBOX: u32 = 0x0002; | ||
extern "system" { | ||
fn SetErrorMode(mode: u32) -> u32; | ||
} | ||
|
||
lazy_static! { | ||
static ref LOCK: Mutex<()> = { | ||
Mutex::new(()) | ||
}; | ||
} | ||
// Error mode is a global variable, so lock it so only one thread will change it | ||
let _lock = LOCK.lock().unwrap(); | ||
|
||
// Tell Windows to not show any UI on errors (such as terminating abnormally). | ||
// This is important for running tests, since some of them use abnormal | ||
// termination by design. This mode is inherited by all child processes. | ||
unsafe { | ||
let old_mode = SetErrorMode(SEM_NOGPFAULTERRORBOX); // read inherited flags | ||
SetErrorMode(old_mode | SEM_NOGPFAULTERRORBOX); | ||
let r = f(); | ||
SetErrorMode(old_mode); | ||
r | ||
} | ||
} | ||
|
||
#[cfg(not(windows))] | ||
fn disable_error_reporting<F: FnOnce() -> R, R>(f: F) -> R { | ||
f() | ||
} | ||
|
||
/// The name of the environment variable that holds dynamic library locations. | ||
pub fn dylib_env_var() -> &'static str { | ||
if cfg!(windows) { | ||
|
@@ -1578,8 +1611,7 @@ impl<'test> TestCx<'test> { | |
let newpath = env::join_paths(&path).unwrap(); | ||
command.env(dylib_env_var(), newpath); | ||
|
||
let mut child = command | ||
.spawn() | ||
let mut child = disable_error_reporting(|| command.spawn()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't this mean that we're only executing one test at a time since this is globally serialized? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah oops yes, indeed! |
||
.expect(&format!("failed to exec `{:?}`", &command)); | ||
if let Some(input) = input { | ||
child | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You forgot to
use std::sync::Mutex;
.