Browse Source

Localize path split and join to one function

urgh
Sean Leather 6 years ago
parent
commit
dde1fe97bf
  1. 12
      tests/support/mod.rs

12
tests/support/mod.rs

@ -1,7 +1,7 @@
#![allow(dead_code)] #![allow(dead_code)]
use std::env; use std::env;
use std::ffi::OsStr; use std::ffi::{OsStr, OsString};
use std::fs::{self, File}; use std::fs::{self, File};
use std::io::prelude::*; use std::io::prelude::*;
use std::path::PathBuf; use std::path::PathBuf;
@ -57,8 +57,6 @@ impl Test {
pub fn gcc(&self) -> cc::Build { pub fn gcc(&self) -> cc::Build {
let mut cfg = cc::Build::new(); let mut cfg = cc::Build::new();
let mut path = env::split_paths(&env::var_os("PATH").unwrap()).collect::<Vec<_>>();
path.insert(0, self.td.path().to_owned());
let target = if self.msvc { let target = if self.msvc {
"x86_64-pc-windows-msvc" "x86_64-pc-windows-msvc"
} else { } else {
@ -70,7 +68,7 @@ impl Test {
.opt_level(2) .opt_level(2)
.debug(false) .debug(false)
.out_dir(self.td.path()) .out_dir(self.td.path())
.__set_env("PATH", env::join_paths(path).unwrap()) .__set_env("PATH", self.path())
.__set_env("GCCTEST_OUT_DIR", self.td.path()); .__set_env("GCCTEST_OUT_DIR", self.td.path());
if self.msvc { if self.msvc {
cfg.compiler(self.td.path().join("cl")); cfg.compiler(self.td.path().join("cl"));
@ -79,6 +77,12 @@ impl Test {
cfg cfg
} }
fn path(&self) -> OsString {
let mut path = env::split_paths(&env::var_os("PATH").unwrap()).collect::<Vec<_>>();
path.insert(0, self.td.path().to_owned());
env::join_paths(path).unwrap()
}
pub fn cmd(&self, i: u32) -> Execution { pub fn cmd(&self, i: u32) -> Execution {
let mut s = String::new(); let mut s = String::new();
File::open(self.td.path().join(format!("out{}", i))) File::open(self.td.path().join(format!("out{}", i)))

Loading…
Cancel
Save