Skip to content

Commit

Permalink
Output .mmd and .dot files in the target directory
Browse files Browse the repository at this point in the history
  • Loading branch information
ggiraldez committed Nov 26, 2024
1 parent 1490a46 commit 1b12974
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions crates/solidity/outputs/cargo/tests/src/bindings_output/runner.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::fs;

use anyhow::Result;
use infra_utils::cargo::CargoWorkspace;
use infra_utils::codegen::CodegenFileSystem;
Expand Down Expand Up @@ -26,6 +28,11 @@ pub fn run(group_name: &str, test_name: &str) -> Result<()> {
.join("bindings_output")
.join(group_name)
.join(test_name);
let target_dir = CargoWorkspace::locate_source_crate("solidity_testing_snapshots")?
.join("target/bindings_output")
.join(group_name)
.join(test_name);
fs::create_dir_all(&target_dir)?;

let mut fs = CodegenFileSystem::new(&test_dir)?;

Expand Down Expand Up @@ -76,24 +83,19 @@ pub fn run(group_name: &str, test_name: &str) -> Result<()> {

if !GitHub::is_running_in_ci() {
// Don't run this in CI, since the graph outputs are not committed
// to the repository and hence we cannot verify their contents,
// which is what `fs.write_file` does in CI.
// to the repository.
let graph_output = render_mermaid_graph(&parsed_parts);
match last_graph_output {
Some(ref last) if last == &graph_output => (),
_ => {
let snapshot_path = test_dir
.join("generated")
.join(format!("{version}-{status}.mmd"));
let snapshot_path = target_dir.join(format!("{version}-{status}.mmd"));

fs.write_file(snapshot_path, &graph_output)?;
fs::write(snapshot_path, &graph_output)?;
last_graph_output = Some(graph_output);

let dot_output = render_graphviz_graph(&parsed_parts);
let dot_output_path = test_dir
.join("generated")
.join(format!("{version}-{status}.dot"));
fs.write_file(dot_output_path, &dot_output)?;
let dot_output_path = target_dir.join(format!("{version}-{status}.dot"));
fs::write(dot_output_path, &dot_output)?;
}
};
}
Expand Down

0 comments on commit 1b12974

Please sign in to comment.