mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-26 19:00:28 -04:00
FEATURE: Add a counter for our assertion output per file.
This commit is contained in:
parent
cacb345000
commit
c4505ac2ab
@ -94,6 +94,7 @@ type BuildResult = Result<(), Box<dyn Error>>;
|
|||||||
|
|
||||||
/// AssertCollector collects the results of assertions in the UCG AST.
|
/// AssertCollector collects the results of assertions in the UCG AST.
|
||||||
pub struct AssertCollector {
|
pub struct AssertCollector {
|
||||||
|
pub counter: i32,
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
pub summary: String,
|
pub summary: String,
|
||||||
pub failures: String,
|
pub failures: String,
|
||||||
@ -168,6 +169,7 @@ impl<'a> FileBuilder<'a> {
|
|||||||
import_path: import_paths,
|
import_path: import_paths,
|
||||||
validate_mode: false,
|
validate_mode: false,
|
||||||
assert_collector: AssertCollector {
|
assert_collector: AssertCollector {
|
||||||
|
counter: 0,
|
||||||
success: true,
|
success: true,
|
||||||
summary: String::new(),
|
summary: String::new(),
|
||||||
failures: String::new(),
|
failures: String::new(),
|
||||||
@ -188,6 +190,7 @@ impl<'a> FileBuilder<'a> {
|
|||||||
import_path: self.import_path,
|
import_path: self.import_path,
|
||||||
validate_mode: false,
|
validate_mode: false,
|
||||||
assert_collector: AssertCollector {
|
assert_collector: AssertCollector {
|
||||||
|
counter: 0,
|
||||||
success: true,
|
success: true,
|
||||||
summary: String::new(),
|
summary: String::new(),
|
||||||
failures: String::new(),
|
failures: String::new(),
|
||||||
@ -1358,14 +1361,15 @@ impl<'a> FileBuilder<'a> {
|
|||||||
|
|
||||||
fn record_assert_result(&mut self, msg: &str, is_success: bool) {
|
fn record_assert_result(&mut self, msg: &str, is_success: bool) {
|
||||||
if !is_success {
|
if !is_success {
|
||||||
let msg = format!("NOT OK - {}\n", msg);
|
let msg = format!("{} - NOT OK: {}\n", self.assert_collector.counter, msg);
|
||||||
self.assert_collector.summary.push_str(&msg);
|
self.assert_collector.summary.push_str(&msg);
|
||||||
self.assert_collector.failures.push_str(&msg);
|
self.assert_collector.failures.push_str(&msg);
|
||||||
self.assert_collector.success = false;
|
self.assert_collector.success = false;
|
||||||
} else {
|
} else {
|
||||||
let msg = format!("OK - {}\n", msg);
|
let msg = format!("{} - OK: {}\n", self.assert_collector.counter, msg);
|
||||||
self.assert_collector.summary.push_str(&msg);
|
self.assert_collector.summary.push_str(&msg);
|
||||||
}
|
}
|
||||||
|
self.assert_collector.counter += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_assert(
|
fn build_assert(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user