Skip to content

Commit ab8183d

Browse files
committed
dsada
1 parent 6dd49aa commit ab8183d

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

test/src/e2e_vm_tests/mod.rs

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use core::fmt;
1414
use forc_pkg::manifest::{GenericManifestFile, ManifestFile};
1515
use forc_pkg::BuildProfile;
1616
use forc_test::ecal::Syscall;
17+
use forc_tracing::ansi_output_enabled;
1718
use forc_util::tx_utils::decode_log_data;
1819
use fuel_vm::fuel_tx;
1920
use fuel_vm::prelude::*;
@@ -1512,29 +1513,33 @@ fn print_run_results(
15121513
);
15131514
} else {
15141515
tracing::info!("_________________________________");
1516+
let result_label = if number_of_tests_failed == 0 {
1517+
format_maybe_colored("ok", |txt| txt.green().bold())
1518+
} else {
1519+
format_maybe_colored("failed", |txt| txt.red().bold())
1520+
};
15151521
tracing::info!(
15161522
"Sway tests result: {}. {} total, {} passed; {} failed; {} disabled [test duration: {}]",
1517-
if number_of_tests_failed == 0 {
1518-
"ok".green().bold()
1519-
} else {
1520-
"failed".red().bold()
1521-
},
1523+
result_label,
15221524
tests_in_run.total_number_of_tests,
15231525
number_of_tests_executed - number_of_tests_failed,
15241526
number_of_tests_failed,
15251527
tests_in_run.disabled_tests.len(),
15261528
util::duration_to_str(duration),
15271529
);
15281530
if number_of_tests_failed > 0 {
1529-
tracing::info!("{}", "Failing tests:".red().bold());
1531+
tracing::info!(
1532+
"{}",
1533+
format_maybe_colored("Failing tests:", |txt| txt.red().bold())
1534+
);
15301535
tracing::info!(
15311536
" {}",
15321537
failed_tests
15331538
.iter()
15341539
.map(|failed_test| format!(
15351540
"{} ... {}",
1536-
failed_test.bold(),
1537-
"failed".red().bold()
1541+
format_maybe_colored(failed_test, |txt| txt.bold()),
1542+
format_maybe_colored("failed", |txt| txt.red().bold())
15381543
))
15391544
.collect::<Vec<_>>()
15401545
.join("\n ")
@@ -1938,6 +1943,17 @@ fn get_test_abi_from_value(value: &toml::Value) -> Result<BuildTarget> {
19381943
}
19391944
}
19401945

1946+
fn format_maybe_colored(
1947+
text: &str,
1948+
formatter: impl FnOnce(&str) -> colored::ColoredString,
1949+
) -> String {
1950+
if ansi_output_enabled() {
1951+
formatter(text).to_string()
1952+
} else {
1953+
text.to_owned()
1954+
}
1955+
}
1956+
19411957
fn get_build_profile_from_value(value: &toml::Value) -> Result<&'static str> {
19421958
match value.as_str() {
19431959
Some(profile) => match profile {

test/src/snapshot/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,9 @@ fn run_cmds(
328328
let o = duct::cmd!("bash", "-c", cmd.clone())
329329
.dir(repo_root.clone())
330330
.stderr_to_stdout()
331-
.stdout_capture();
331+
.stdout_capture()
332+
.env("FORC_TERM_COLOR", "never")
333+
.env("NO_COLOR", "1");
332334

333335
let o = if let Some(last_output) = last_output.as_ref() {
334336
o.stdin_bytes(last_output.as_bytes())

0 commit comments

Comments
 (0)