From ca7f63c4505ec14adf0e8ae175e5225fadfa9b25 Mon Sep 17 00:00:00 2001 From: jdonszelmann Date: Tue, 4 Jun 2024 22:17:37 +0200 Subject: [PATCH] fix tests --- scopegraphs-render-docs/Cargo.toml | 1 + scopegraphs-render-docs/src/attrs.rs | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/scopegraphs-render-docs/Cargo.toml b/scopegraphs-render-docs/Cargo.toml index 2f2734f..17d3009 100644 --- a/scopegraphs-render-docs/Cargo.toml +++ b/scopegraphs-render-docs/Cargo.toml @@ -20,6 +20,7 @@ proc-macro-error = { version = "1", default-features = false } itertools = "0.10" syn = "2" include_dir = "0.7" +uuid = { version = "1.8.0", features = ["v4"] } [dev-dependencies] pretty_assertions = "1" diff --git a/scopegraphs-render-docs/src/attrs.rs b/scopegraphs-render-docs/src/attrs.rs index 49a27e7..8e6a867 100644 --- a/scopegraphs-render-docs/src/attrs.rs +++ b/scopegraphs-render-docs/src/attrs.rs @@ -13,6 +13,7 @@ use std::path::PathBuf; use std::process::{Command, Stdio}; use std::{fs, io}; use syn::{Attribute, Ident, MetaNameValue}; +use uuid::Uuid; // embedded JS code being inserted as html script elmenets static MERMAID_JS_DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR/doc/js/"); @@ -327,7 +328,7 @@ fn run_code(code: &str) -> Result, EvalError> { Ok(()) } - let code_hash = hash_str(code).to_string(); + let code_hash = Uuid::new_v4().to_string(); let out_dir = &temp_dir().join("render-docs").join(&code_hash); println!("testing in {out_dir:?}"); @@ -341,12 +342,14 @@ fn run_code(code: &str) -> Result, EvalError> { let _ = fs::remove_file(sg_target_dir.join("debug").join(".fingerprint")); let _ = fs::remove_file(sg_target_dir.join("debug").join("tmp")); let _ = fs::remove_file(sg_target_dir.join("debug").join("incremental")); + // let _ = fs::remove_file(sg_target_dir.join("debug").join("build")); } if sg_target_dir.join("release").exists() { let _ = fs::remove_file(sg_target_dir.join("release").join(".cargo-lock")); let _ = fs::remove_file(sg_target_dir.join("release").join(".fingerprint")); let _ = fs::remove_file(sg_target_dir.join("release").join("tmp")); let _ = fs::remove_file(sg_target_dir.join("release").join("incremental")); + // let _ = fs::remove_file(sg_target_dir.join("release").join("build")); } let cargo = PathBuf::from(std::env::var("CARGO").expect("$CARGO is set during compilation")); @@ -392,6 +395,7 @@ fn documented() {{}} let command = command .current_dir(out_dir) .env("CARGO_TARGET_DIR", sg_target_dir) + .env_remove("CARGO_MAKEFLAGS") .arg("test"); let output = if offline {