cli-test: Add current working directory to PATH
This commit is contained in:
parent
3018223328
commit
547614a5bb
|
|
@ -170,13 +170,19 @@ pub struct TestFormula {
|
||||||
impl TestFormula {
|
impl TestFormula {
|
||||||
pub fn new(cwd: PathBuf) -> Self {
|
pub fn new(cwd: PathBuf) -> Self {
|
||||||
Self {
|
Self {
|
||||||
cwd,
|
cwd: cwd.clone(),
|
||||||
env: HashMap::new(),
|
env: HashMap::new(),
|
||||||
homes: HashMap::new(),
|
homes: HashMap::new(),
|
||||||
tests: Vec::new(),
|
tests: Vec::new(),
|
||||||
subs: Substitutions::new(),
|
subs: Substitutions::new(),
|
||||||
bins: env::var("PATH")
|
bins: env::var("PATH")
|
||||||
.map(|p| p.split(':').map(PathBuf::from).collect())
|
.map(|env_path| {
|
||||||
|
let mut bins: Vec<PathBuf> = env_path.split(':').map(PathBuf::from).collect();
|
||||||
|
// Add current working directory to `$PATH`,
|
||||||
|
// this makes it more convenient to execute scripts during testing.
|
||||||
|
bins.push(cwd);
|
||||||
|
bins
|
||||||
|
})
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -534,7 +540,9 @@ $ rad sync
|
||||||
.as_bytes()
|
.as_bytes()
|
||||||
.to_owned();
|
.to_owned();
|
||||||
|
|
||||||
let mut actual = TestFormula::new(PathBuf::new());
|
let cwd = PathBuf::from("radicle-cli-test");
|
||||||
|
|
||||||
|
let mut actual = TestFormula::new(cwd.clone());
|
||||||
let path = Path::new("test.md").to_path_buf();
|
let path = Path::new("test.md").to_path_buf();
|
||||||
actual
|
actual
|
||||||
.read(path.as_path(), io::BufReader::new(io::Cursor::new(input)))
|
.read(path.as_path(), io::BufReader::new(io::Cursor::new(input)))
|
||||||
|
|
@ -542,14 +550,18 @@ $ rad sync
|
||||||
|
|
||||||
let expected = TestFormula {
|
let expected = TestFormula {
|
||||||
homes: HashMap::new(),
|
homes: HashMap::new(),
|
||||||
cwd: PathBuf::new(),
|
cwd: cwd.clone(),
|
||||||
env: HashMap::new(),
|
env: HashMap::new(),
|
||||||
subs: Substitutions::new(),
|
subs: Substitutions::new(),
|
||||||
bins: env::var("PATH")
|
bins: {
|
||||||
.unwrap()
|
let mut bins: Vec<_> = env::var("PATH")
|
||||||
.split(':')
|
.unwrap_or_default()
|
||||||
.map(PathBuf::from)
|
.split(':')
|
||||||
.collect(),
|
.map(PathBuf::from)
|
||||||
|
.collect();
|
||||||
|
bins.push(cwd);
|
||||||
|
bins
|
||||||
|
},
|
||||||
tests: vec![
|
tests: vec![
|
||||||
Test {
|
Test {
|
||||||
context: vec![String::from("Let's try to track @dave and @sean:")],
|
context: vec![String::from("Let's try to track @dave and @sean:")],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue