about summary refs log tree commit diff
path: root/src/tools/compiletest
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2016-12-29 17:26:41 -0800
committerGitHub <noreply@github.com>2016-12-29 17:26:41 -0800
commit334af886589f2854d9027d60fa79a62b6e5b4980 (patch)
tree2a89fce194c11bcdb8e9f86f940cd2a7b5108213 /src/tools/compiletest
parent19e187c17539728ea661e17f4d0b63a6d07d5b99 (diff)
parente5c778228e2e825002bc4eb1e62cfc35afce0dd4 (diff)
downloadrust-334af886589f2854d9027d60fa79a62b6e5b4980.tar.gz
rust-334af886589f2854d9027d60fa79a62b6e5b4980.zip
Rollup 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
Diffstat (limited to 'src/tools/compiletest')
-rw-r--r--src/tools/compiletest/src/runtest.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index d729deb8605..05f9beca3d1 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -1619,10 +1619,48 @@ actual:\n\
     }
 
     fn fatal_proc_rec(&self, err: &str, proc_res: &ProcRes) -> ! {
+        self.try_print_open_handles();
         self.error(err);
         proc_res.fatal(None);
     }
 
+    // This function is a poor man's attempt to debug rust-lang/rust#38620, if
+    // that's closed then this should be deleted
+    //
+    // This is a very "opportunistic" debugging attempt, so we ignore all
+    // errors here.
+    fn try_print_open_handles(&self) {
+        if !cfg!(windows) {
+            return
+        }
+        if self.config.mode != Incremental {
+            return
+        }
+
+        let filename = match self.testpaths.file.file_stem() {
+            Some(path) => path,
+            None => return,
+        };
+
+        let mut cmd = Command::new("handle.exe");
+        cmd.arg("-a").arg("-u");
+        cmd.arg(filename);
+        cmd.arg("-nobanner");
+        let output = match cmd.output() {
+            Ok(output) => output,
+            Err(_) => return,
+        };
+        println!("---------------------------------------------------");
+        println!("ran extra command to debug rust-lang/rust#38620: ");
+        println!("{:?}", cmd);
+        println!("result: {}", output.status);
+        println!("--- stdout ----------------------------------------");
+        println!("{}", String::from_utf8_lossy(&output.stdout));
+        println!("--- stderr ----------------------------------------");
+        println!("{}", String::from_utf8_lossy(&output.stderr));
+        println!("---------------------------------------------------");
+    }
+
     fn _arm_exec_compiled_test(&self, env: Vec<(String, String)>) -> ProcRes {
         let args = self.make_run_args();
         let cmdline = self.make_cmdline("", &args.prog, &args.args);