fix editor test

This commit is contained in:
Anton-4 2023-03-14 18:24:30 +01:00
parent 16f32c9409
commit 0605639fa8
No known key found for this signature in database
GPG key ID: 0971D718C0A9B937
2 changed files with 40 additions and 30 deletions

View file

@ -8,12 +8,12 @@ mod editor_launch_test {
thread, thread,
}; };
use cli_utils::helpers::build_roc_bin_cached; use cli_utils::helpers::build_roc_bin;
use roc_cli::CMD_EDIT; use roc_cli::CMD_EDIT;
use roc_command_utils::root_dir; use roc_command_utils::root_dir;
use std::io::Read; 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] #[test]
fn launch_test() { fn launch_test() {
launch(None); launch(None);
@ -32,7 +32,7 @@ mod editor_launch_test {
env::set_current_dir(&root_dir) env::set_current_dir(&root_dir)
.unwrap_or_else(|_| panic!("Failed to set current dir to {:?}", 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]; let mut cmd_args = vec![CMD_EDIT];

View file

@ -39,39 +39,49 @@ pub fn build_roc_bin_cached() -> PathBuf {
let roc_binary_path = path_to_roc_binary(); let roc_binary_path = path_to_roc_binary();
if !roc_binary_path.exists() { if !roc_binary_path.exists() {
// Remove the /target/release/roc part build_roc_bin(&[]);
let root_project_dir = roc_binary_path }
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap();
// cargo build --bin roc roc_binary_path
// (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"]
};
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() { let mut cargo_cmd = cargo();
panic!(
"The following cargo command failed:\n\n {}\n\n stdout was:\n\n {}\n\n stderr was:\n\n {}\n", cargo_cmd.current_dir(root_project_dir).args(&args);
cargo_cmd_str,
String::from_utf8(cargo_output.stdout).unwrap(), let cargo_cmd_str = format!("{:?}", cargo_cmd);
String::from_utf8(cargo_output.stderr).unwrap()
); 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 roc_binary_path