From 58957570dba4313b4980c1d6e6053f3ef861c6dd Mon Sep 17 00:00:00 2001 From: Ashu999 Date: Fri, 5 Jul 2024 11:10:46 +0530 Subject: [PATCH] use get_test_process_cmd() to get base command --- crates/cli_bin/tests/common/mod.rs | 10 +++++++++- crates/cli_bin/tests/patterns_test.rs | 9 ++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/crates/cli_bin/tests/common/mod.rs b/crates/cli_bin/tests/common/mod.rs index 07a408a28..3c79929f3 100644 --- a/crates/cli_bin/tests/common/mod.rs +++ b/crates/cli_bin/tests/common/mod.rs @@ -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; @@ -15,6 +16,13 @@ pub fn get_test_cmd() -> Result { Ok(cmd) } +#[allow(dead_code)] +pub fn get_test_process_cmd() -> Result { + 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 { diff --git a/crates/cli_bin/tests/patterns_test.rs b/crates/cli_bin/tests/patterns_test.rs index e8c50bcaf..bbca569d4 100644 --- a/crates/cli_bin/tests/patterns_test.rs +++ b/crates/cli_bin/tests/patterns_test.rs @@ -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; @@ -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) @@ -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)