From 4f55e8968dcfa7bd4c21ea74339b04acb36176ae Mon Sep 17 00:00:00 2001 From: Omar Abdulla Date: Sun, 24 Aug 2025 23:01:30 +0300 Subject: [PATCH] Update report to use better map data structures --- Cargo.lock | 1 + crates/core/src/main.rs | 11 ++++++----- crates/report/Cargo.toml | 1 + crates/report/src/aggregator.rs | 9 +++++---- crates/report/src/runner_event.rs | 5 +++-- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9372616..ef552af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4589,6 +4589,7 @@ name = "revive-dt-report" version = "0.1.0" dependencies = [ "anyhow", + "indexmap 2.10.0", "paste", "revive-dt-common", "revive-dt-compiler", diff --git a/crates/core/src/main.rs b/crates/core/src/main.rs index e3c17ac..6db04de 100644 --- a/crates/core/src/main.rs +++ b/crates/core/src/main.rs @@ -16,6 +16,7 @@ use anyhow::Context; use clap::Parser; use futures::stream; use futures::{Stream, StreamExt}; +use indexmap::IndexMap; use revive_dt_node_interaction::EthereumNode; use revive_dt_report::{ReportAggregator, Reporter, TestSpecificReporter, TestSpecifier}; use temp_dir::TempDir; @@ -261,7 +262,7 @@ where .reporter .report_test_ignored_event( "Either the leader or the follower do not support the target desired by the test", - HashMap::from_iter([ + IndexMap::from_iter([ ( "test_desired_targets".to_string(), serde_json::to_value(test.metadata.targets.as_ref()) @@ -295,7 +296,7 @@ where .reporter .report_test_ignored_event( "Metadata file is ignored, therefore all cases are ignored", - HashMap::new(), + IndexMap::new(), ) .expect("Can't fail"); false @@ -315,7 +316,7 @@ where .reporter .report_test_ignored_event( "Case is ignored", - HashMap::new(), + IndexMap::new(), ) .expect("Can't fail"); false @@ -344,7 +345,7 @@ where .reporter .report_test_ignored_event( "EVM version is incompatible with either the leader or the follower", - HashMap::from_iter([ + IndexMap::from_iter([ ( "test_desired_evm_version".to_string(), serde_json::to_value(test.metadata.required_evm_version) @@ -395,7 +396,7 @@ where .reporter .report_test_ignored_event( "Compilers do not support this mode either for the leader or for the follower.", - HashMap::from_iter([ + IndexMap::from_iter([ ( "leader_support".to_string(), serde_json::to_value(leader_support) diff --git a/crates/report/Cargo.toml b/crates/report/Cargo.toml index ac05025..33982fb 100644 --- a/crates/report/Cargo.toml +++ b/crates/report/Cargo.toml @@ -15,6 +15,7 @@ revive-dt-compiler = { workspace = true } anyhow = { workspace = true } paste = { workspace = true } +indexmap = { workspace = true, features = ["serde"] } semver = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } diff --git a/crates/report/src/aggregator.rs b/crates/report/src/aggregator.rs index ea35b22..02c53ae 100644 --- a/crates/report/src/aggregator.rs +++ b/crates/report/src/aggregator.rs @@ -2,12 +2,13 @@ //! reporters and combines them into a single unified report. use std::{ - collections::{BTreeSet, HashMap, HashSet}, + collections::{BTreeMap, BTreeSet, HashMap, HashSet}, fs::OpenOptions, time::{SystemTime, UNIX_EPOCH}, }; use anyhow::Result; +use indexmap::IndexMap; use revive_dt_compiler::Mode; use revive_dt_config::Arguments; use revive_dt_format::{case::CaseIdx, corpus::Corpus}; @@ -157,9 +158,9 @@ pub struct Report { /// The list of metadata files that were found by the tool. pub metadata_files: BTreeSet, /// Information relating to each test case. - #[serde_as(as = "HashMap<_, HashMap>>")] + #[serde_as(as = "BTreeMap<_, HashMap>>")] pub test_case_information: - HashMap>>, + BTreeMap>>, } impl Report { @@ -188,5 +189,5 @@ pub struct TestCaseIgnoreInformation { pub reason: String, /// Additional fields that describe more information on why the test case is ignored. #[serde(flatten)] - pub additional_fields: HashMap, + pub additional_fields: IndexMap, } diff --git a/crates/report/src/runner_event.rs b/crates/report/src/runner_event.rs index 81f3d81..bf1b8d6 100644 --- a/crates/report/src/runner_event.rs +++ b/crates/report/src/runner_event.rs @@ -1,8 +1,9 @@ //! The types associated with the events sent by the runner to the reporter. #![allow(dead_code)] -use std::{collections::HashMap, sync::Arc}; +use std::sync::Arc; +use indexmap::IndexMap; use revive_dt_format::corpus::Corpus; use revive_dt_format::metadata::Metadata; use tokio::sync::{broadcast, oneshot}; @@ -264,7 +265,7 @@ define_event! { /// A reason for the test to be ignored. reason: String, /// Additional fields that describe more information on why the test was ignored. - additional_fields: HashMap + additional_fields: IndexMap }, } }