Skip to content

Commit 75f5981

Browse files
committed
Auto merge of #38695 - alexcrichton:debug-appveyor, r=brson
appveyor: Attempt to debug flaky test runs This commit is an attempt to debug #38620 since we're unable to reproduce it locally. It follows the [advice] of those with AppVeyor to use the `handle.exe` tool to try to debug what processes have a handle to the file open. This won't be guaranteed to actually help us, but hopefully it'll diagnose something at some point? [advice]: http://help.appveyor.com/discussions/questions/2898
2 parents e7c788a + e5c7782 commit 75f5981

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

appveyor.yml

+7
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ install:
9696
- 7z x -y sccache.tar > nul
9797
- set PATH=%PATH%;%CD%\sccache2
9898

99+
# Help debug some handle issues on AppVeyor
100+
- ps: Invoke-WebRequest -Uri https://download.sysinternals.com/files/Handle.zip -OutFile handle.zip
101+
- mkdir handle
102+
- ps: Expand-Archive handle.zip -dest handle
103+
- set PATH=%PATH%;%CD%\handle
104+
- handle.exe -accepteula -help
105+
99106
test_script:
100107
- git submodule update --init
101108
- set SRC=.

src/tools/compiletest/src/runtest.rs

+38
Original file line numberDiff line numberDiff line change
@@ -1619,10 +1619,48 @@ actual:\n\
16191619
}
16201620

16211621
fn fatal_proc_rec(&self, err: &str, proc_res: &ProcRes) -> ! {
1622+
self.try_print_open_handles();
16221623
self.error(err);
16231624
proc_res.fatal(None);
16241625
}
16251626

1627+
// This function is a poor man's attempt to debug rust-lang/rust#38620, if
1628+
// that's closed then this should be deleted
1629+
//
1630+
// This is a very "opportunistic" debugging attempt, so we ignore all
1631+
// errors here.
1632+
fn try_print_open_handles(&self) {
1633+
if !cfg!(windows) {
1634+
return
1635+
}
1636+
if self.config.mode != Incremental {
1637+
return
1638+
}
1639+
1640+
let filename = match self.testpaths.file.file_stem() {
1641+
Some(path) => path,
1642+
None => return,
1643+
};
1644+
1645+
let mut cmd = Command::new("handle.exe");
1646+
cmd.arg("-a").arg("-u");
1647+
cmd.arg(filename);
1648+
cmd.arg("-nobanner");
1649+
let output = match cmd.output() {
1650+
Ok(output) => output,
1651+
Err(_) => return,
1652+
};
1653+
println!("---------------------------------------------------");
1654+
println!("ran extra command to debug rust-lang/rust#38620: ");
1655+
println!("{:?}", cmd);
1656+
println!("result: {}", output.status);
1657+
println!("--- stdout ----------------------------------------");
1658+
println!("{}", String::from_utf8_lossy(&output.stdout));
1659+
println!("--- stderr ----------------------------------------");
1660+
println!("{}", String::from_utf8_lossy(&output.stderr));
1661+
println!("---------------------------------------------------");
1662+
}
1663+
16261664
fn _arm_exec_compiled_test(&self, env: Vec<(String, String)>) -> ProcRes {
16271665
let args = self.make_run_args();
16281666
let cmdline = self.make_cmdline("", &args.prog, &args.args);

0 commit comments

Comments
 (0)