Merge branch 'main' of github.com:roc-lang/roc into simplify_examples

This commit is contained in:
Anton-4 2022-10-07 16:00:32 +02:00
commit c6ec3d5d30
No known key found for this signature in database
GPG key ID: A13F4A6E21141925
65 changed files with 3191 additions and 679 deletions

View file

@ -22,7 +22,7 @@ pub struct Out {
pub status: ExitStatus,
}
pub fn run_roc<I, S>(args: I, stdin_vals: &[&str]) -> Out
pub fn run_roc<I, S>(args: I, stdin_vals: &[&str], extra_env: &[(&str, &str)]) -> Out
where
I: IntoIterator<Item = S>,
S: AsRef<OsStr>,
@ -62,7 +62,7 @@ where
}
}
run_with_stdin(&roc_binary_path, args, stdin_vals)
run_with_stdin_and_env(&roc_binary_path, args, stdin_vals, extra_env)
}
pub fn run_glue<I, S>(args: I) -> Out
@ -118,6 +118,19 @@ pub fn strip_colors(str: &str) -> String {
}
pub fn run_with_stdin<I, S>(path: &Path, args: I, stdin_vals: &[&str]) -> Out
where
I: IntoIterator<Item = S>,
S: AsRef<OsStr>,
{
run_with_stdin_and_env(path, args, stdin_vals, &[])
}
pub fn run_with_stdin_and_env<I, S>(
path: &Path,
args: I,
stdin_vals: &[&str],
extra_env: &[(&str, &str)],
) -> Out
where
I: IntoIterator<Item = S>,
S: AsRef<OsStr>,
@ -128,6 +141,10 @@ where
cmd.arg(arg);
}
for (k, v) in extra_env {
cmd.env(k, v);
}
let mut child = cmd
.stdin(Stdio::piped())
.stdout(Stdio::piped())