Skip to content

Commit

Permalink
use get_test_process_cmd() to get base command
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashu999 committed Jul 5, 2024
1 parent 7884371 commit 5895757
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 9 additions & 1 deletion crates/cli_bin/tests/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{env, path};
use std::{env, path, process};

use anyhow::Result;
use assert_cmd::cargo::CommandCargoExt;
use assert_cmd::Command;

use marzano_gritmodule::config::GRIT_GLOBAL_DIR_ENV;
Expand All @@ -15,6 +16,13 @@ pub fn get_test_cmd() -> Result<Command> {
Ok(cmd)
}

#[allow(dead_code)]
pub fn get_test_process_cmd() -> Result<process::Command> {
let mut cmd = process::Command::cargo_bin(BIN_NAME)?;
cmd.env("GRIT_TELEMETRY_DISABLED", "true");
Ok(cmd)
}

// This is used in tests
#[allow(dead_code)]
pub fn get_fixtures_root() -> Result<std::path::PathBuf> {
Expand Down
9 changes: 4 additions & 5 deletions crates/cli_bin/tests/patterns_test.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
use std::{
env, fs,
io::{BufRead, BufReader},
process::{Command, Stdio},
process::Stdio,
sync::mpsc,
thread,
time::Duration,
};

use anyhow::Result;
use assert_cmd::cargo::CommandCargoExt;
use insta::assert_snapshot;

use crate::common::{get_fixture, get_test_cmd, BIN_NAME};
use crate::common::{get_fixture, get_test_cmd, get_test_process_cmd};

mod common;

Expand Down Expand Up @@ -329,7 +328,7 @@ fn patterns_test_watch_mode_case_patterns_changed() -> Result<()> {
let temp_dir_path = temp_dir.path().to_owned();

let _cmd_handle = thread::spawn(move || {
let mut cmd = Command::cargo_bin(BIN_NAME)
let mut cmd = get_test_process_cmd()
.unwrap()
.args(&["patterns", "test", "--watch"])
.current_dir(&temp_dir_path)
Expand Down Expand Up @@ -381,7 +380,7 @@ fn patterns_test_watch_mode_case_no_pattern_to_test() -> Result<()> {
let temp_dir_path = temp_dir.path().to_owned();

let _cmd_handle = thread::spawn(move || {
let mut cmd = Command::cargo_bin(BIN_NAME)
let mut cmd = get_test_process_cmd()
.unwrap()
.args(&["patterns", "test", "--watch"])
.current_dir(&temp_dir_path)
Expand Down

0 comments on commit 5895757

Please sign in to comment.