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

This commit is contained in:
Anton-4 2022-09-28 19:48:46 +02:00
commit eaacb86ad9
No known key found for this signature in database
GPG key ID: A13F4A6E21141925
15 changed files with 271 additions and 170 deletions

View file

@ -48,12 +48,12 @@ fn check_cmd_output(
let out = if cmd_str.contains("cfold") {
let child = thread::Builder::new()
.stack_size(CFOLD_STACK_SIZE)
.spawn(move || run_cmd(&cmd_str, [stdin_str], &[]))
.spawn(move || run_cmd(&cmd_str, [stdin_str], &[], []))
.unwrap();
child.join().unwrap()
} else {
run_cmd(&cmd_str, [stdin_str], &[])
run_cmd(&cmd_str, [stdin_str], &[], [])
};
if !&out.stdout.ends_with(expected_ending) {
@ -96,13 +96,14 @@ fn bench_cmd<T: Measurement>(
if let Some(bench_group) = bench_group_opt {
bench_group.bench_function(&format!("Benchmarking {:?}", executable_filename), |b| {
b.iter(|| run_cmd(black_box(&cmd_str), black_box([stdin_str]), &[]))
b.iter(|| run_cmd(black_box(&cmd_str), black_box([stdin_str]), &[], []))
});
} else {
run_cmd(
black_box(file.with_file_name(executable_filename).to_str().unwrap()),
black_box([stdin_str]),
&[],
[],
);
}
}

View file

@ -161,10 +161,11 @@ where
}
}
pub fn run_cmd<'a, I: IntoIterator<Item = &'a str>>(
pub fn run_cmd<'a, I: IntoIterator<Item = &'a str>, E: IntoIterator<Item = (&'a str, &'a str)>>(
cmd_name: &str,
stdin_vals: I,
args: &[String],
env: E,
) -> Out {
let mut cmd = Command::new(cmd_name);
@ -172,6 +173,10 @@ pub fn run_cmd<'a, I: IntoIterator<Item = &'a str>>(
cmd.arg(arg);
}
for (env, val) in env.into_iter() {
cmd.env(env, val);
}
let mut child = cmd
.stdin(Stdio::piped())
.stdout(Stdio::piped())