Skip to content

Commit b43413f

Browse files
authored
Merge pull request #406 from spl/test-path-fn
Localize path split and join to one function
2 parents f3e4fc1 + dde1fe9 commit b43413f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/support/mod.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![allow(dead_code)]
22

33
use std::env;
4-
use std::ffi::OsStr;
4+
use std::ffi::{OsStr, OsString};
55
use std::fs::{self, File};
66
use std::io::prelude::*;
77
use std::path::PathBuf;
@@ -57,8 +57,6 @@ impl Test {
5757

5858
pub fn gcc(&self) -> cc::Build {
5959
let mut cfg = cc::Build::new();
60-
let mut path = env::split_paths(&env::var_os("PATH").unwrap()).collect::<Vec<_>>();
61-
path.insert(0, self.td.path().to_owned());
6260
let target = if self.msvc {
6361
"x86_64-pc-windows-msvc"
6462
} else {
@@ -70,7 +68,7 @@ impl Test {
7068
.opt_level(2)
7169
.debug(false)
7270
.out_dir(self.td.path())
73-
.__set_env("PATH", env::join_paths(path).unwrap())
71+
.__set_env("PATH", self.path())
7472
.__set_env("GCCTEST_OUT_DIR", self.td.path());
7573
if self.msvc {
7674
cfg.compiler(self.td.path().join("cl"));
@@ -79,6 +77,12 @@ impl Test {
7977
cfg
8078
}
8179

80+
fn path(&self) -> OsString {
81+
let mut path = env::split_paths(&env::var_os("PATH").unwrap()).collect::<Vec<_>>();
82+
path.insert(0, self.td.path().to_owned());
83+
env::join_paths(path).unwrap()
84+
}
85+
8286
pub fn cmd(&self, i: u32) -> Execution {
8387
let mut s = String::new();
8488
File::open(self.td.path().join(format!("out{}", i)))

0 commit comments

Comments
 (0)