Lines
94.59 %
Functions
100 %
Branches
//! The snapshot's text form: one `==` block per (fixture, mode, hosts, world)
//! holding the whole [`Behaviour`], preceded by the compilation's measured
//! counters, so a reviewer reads a transition as a diff of plain lines.
use super::super::CompileMode;
use super::super::behaviour_oracle::{Behaviour, Logged};
use super::super::stats::CompileStats;
pub(super) struct Row {
pub(super) id: String,
pub(super) mode: CompileMode,
pub(super) hosts: &'static str,
pub(super) behaviours: Vec<Behaviour>,
pub(super) stats: CompileStats,
}
fn logged(message: &Logged) -> String {
match message {
Logged::Text(text) => format!("{text:?}"),
Logged::InvalidUtf8(bytes) => format!("invalid utf-8 {bytes:?}"),
Logged::Unreadable => "unreadable".to_string(),
fn render_behaviour(out: &mut String, row: &Row, behaviour: &Behaviour) {
out.push_str(&format!(
"== {} | {:?} | hosts={} | {}\n",
row.id, row.mode, row.hosts, behaviour.world
));
out.push_str(&format!("outcome: {:?}\n", behaviour.outcome));
out.push_str(&format!("applies: {:?}\n", behaviour.applies));
for (severity, message) in &behaviour.output {
out.push_str(&format!("log: {severity} {}\n", logged(message)));
for effect in &behaviour.effects {
out.push_str(&format!("effect: {effect}\n"));
pub(super) fn render_rows(rows: &[Row]) -> String {
let mut out = String::new();
for row in rows {
"== {} | {:?} | hosts={} | stats\nfolds: {}\nmacro_bodies_reading_globals: {}\n\
stored_globals: {}\npossibly_storing: {}\nopaque_macro_uses: {}\n",
row.id,
row.mode,
row.hosts,
row.stats.folds,
row.stats.macro_bodies_reading_globals,
row.stats.stored_globals,
row.stats.possibly_storing,
row.stats.opaque_macro_uses
for behaviour in &row.behaviours {
render_behaviour(&mut out, row, behaviour);
out