diff --git a/crates/cli/tests/editor.rs b/crates/cli/tests/editor.rs index 6b6cc80253..132ff61a4c 100644 --- a/crates/cli/tests/editor.rs +++ b/crates/cli/tests/editor.rs @@ -8,12 +8,12 @@ mod editor_launch_test { thread, }; - use cli_utils::helpers::build_roc_bin_cached; + use cli_utils::helpers::build_roc_bin; use roc_cli::CMD_EDIT; use roc_command_utils::root_dir; use std::io::Read; - #[ignore = "we don't want to bring up the editor window during regular tests, only on specific CI machines"] + #[ignore = "We don't want to bring up the editor window during regular tests, only on specific CI machines."] #[test] fn launch_test() { launch(None); @@ -32,7 +32,7 @@ mod editor_launch_test { env::set_current_dir(&root_dir) .unwrap_or_else(|_| panic!("Failed to set current dir to {:?}", root_dir)); - let roc_binary_path = build_roc_bin_cached(); + let roc_binary_path = build_roc_bin(&vec!["--features", "editor"]); let mut cmd_args = vec![CMD_EDIT]; diff --git a/crates/cli_utils/src/helpers.rs b/crates/cli_utils/src/helpers.rs index 7895bfb1af..e9eb3ed1ff 100644 --- a/crates/cli_utils/src/helpers.rs +++ b/crates/cli_utils/src/helpers.rs @@ -39,39 +39,49 @@ pub fn build_roc_bin_cached() -> PathBuf { let roc_binary_path = path_to_roc_binary(); if !roc_binary_path.exists() { - // Remove the /target/release/roc part - let root_project_dir = roc_binary_path - .parent() - .unwrap() - .parent() - .unwrap() - .parent() - .unwrap(); + build_roc_bin(&[]); + } - // cargo build --bin roc - // (with --release iff the test is being built with --release) - let args = if cfg!(debug_assertions) { - vec!["build", "--bin", "roc"] - } else { - vec!["build", "--release", "--bin", "roc"] - }; + roc_binary_path +} - let mut cargo_cmd = cargo(); +pub fn build_roc_bin(extra_args: &[&str]) -> PathBuf { + let roc_binary_path = path_to_roc_binary(); - cargo_cmd.current_dir(root_project_dir).args(&args); + // Remove the /target/release/roc part + let root_project_dir = roc_binary_path + .parent() + .unwrap() + .parent() + .unwrap() + .parent() + .unwrap(); - let cargo_cmd_str = format!("{:?}", cargo_cmd); + // cargo build --bin roc + // (with --release iff the test is being built with --release) + let mut args = if cfg!(debug_assertions) { + vec!["build", "--bin", "roc"] + } else { + vec!["build", "--release", "--bin", "roc"] + }; - let cargo_output = cargo_cmd.output().unwrap(); + args.extend(extra_args); - if !cargo_output.status.success() { - panic!( - "The following cargo command failed:\n\n {}\n\n stdout was:\n\n {}\n\n stderr was:\n\n {}\n", - cargo_cmd_str, - String::from_utf8(cargo_output.stdout).unwrap(), - String::from_utf8(cargo_output.stderr).unwrap() - ); - } + let mut cargo_cmd = cargo(); + + cargo_cmd.current_dir(root_project_dir).args(&args); + + let cargo_cmd_str = format!("{:?}", cargo_cmd); + + let cargo_output = cargo_cmd.output().unwrap(); + + if !cargo_output.status.success() { + panic!( + "The following cargo command failed:\n\n {}\n\n stdout was:\n\n {}\n\n stderr was:\n\n {}\n", + cargo_cmd_str, + String::from_utf8(cargo_output.stdout).unwrap(), + String::from_utf8(cargo_output.stderr).unwrap() + ); } roc_binary_path