Skip to content

Commit

Permalink
Global temporary directory
Browse files Browse the repository at this point in the history
  • Loading branch information
jdub committed Nov 6, 2016
1 parent 3ad7a9e commit f4158e5
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion libbindgen/tests/tests.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
extern crate diff;
#[macro_use]
extern crate lazy_static;
extern crate libbindgen;
extern crate tempdir;
extern crate diff;

use std::env;
use std::fs;
use std::io::{BufReader, BufRead, Read};
use std::path::{Path, PathBuf};
use tempdir::TempDir;

lazy_static! {
static ref TEMP_DIR: PathBuf = TempDir::new("libbindgen-tests")
.expect("Couldn't create temporary directory")
.into_path();
}

fn spawn_bindgen(header: &PathBuf, builder: libbindgen::Builder) -> Result<(), ()> {
let file_name = header.file_name()
.expect("spawn_bindgen expects a file");
Expand Down Expand Up @@ -131,6 +139,10 @@ fn run_bindgen_tests() {

let num_failures = failures.len();

let temp_dir = TEMP_DIR.as_path();
fs::remove_dir_all(temp_dir)
.expect(format!("Couldn't clean up temporary directory: {:?}", temp_dir).as_str());

if num_failures > 0 {
panic!("{} test failures!", num_failures);
}
Expand Down

0 comments on commit f4158e5

Please sign in to comment.