From ec8dfdbb6f291d281c48139dd65e659fe1208bf3 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Fri, 27 Jun 2025 10:28:23 -0400 Subject: [Rust] Fixup some unit tests --- rust/tests/binary_view.rs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'rust/tests/binary_view.rs') diff --git a/rust/tests/binary_view.rs b/rust/tests/binary_view.rs index 1b4f1c40..a71a0fd1 100644 --- a/rust/tests/binary_view.rs +++ b/rust/tests/binary_view.rs @@ -99,6 +99,10 @@ fn test_binary_view_strings() { assert_eq!(str_15dc.length, 33); } +// These are the target files present in OUT_DIR +// Add the files to fixtures/bin +static TARGET_FILES: [&str; 2] = ["atox.obj", "atof.obj"]; + // This is what we store to check if a function matches the expected function. // See `test_deterministic_functions` for details. #[derive(Debug, PartialEq)] @@ -120,19 +124,16 @@ impl From<&Function> for FunctionSnapshot { fn test_deterministic_functions() { let session = Session::new().expect("Failed to initialize session"); let out_dir = env!("OUT_DIR").parse::().unwrap(); - for entry in std::fs::read_dir(out_dir).expect("Failed to read OUT_DIR") { - let entry = entry.expect("Failed to read directory entry"); - let path = entry.path(); - if path.is_file() { - let view = session.load(&path).expect("Failed to load view"); - assert_eq!(view.analysis_progress().state, AnalysisState::IdleState); - let functions: BTreeMap = view - .functions() - .iter() - .map(|f| (f.start(), FunctionSnapshot::from(f.as_ref()))) - .collect(); - let snapshot_name = path.file_stem().unwrap().to_str().unwrap(); - insta::assert_debug_snapshot!(snapshot_name, functions); - } + for file_name in TARGET_FILES { + let path = out_dir.join(file_name); + let view = session.load(&path).expect("Failed to load view"); + assert_eq!(view.analysis_progress().state, AnalysisState::IdleState); + let functions: BTreeMap = view + .functions() + .iter() + .map(|f| (f.start(), FunctionSnapshot::from(f.as_ref()))) + .collect(); + let snapshot_name = path.file_stem().unwrap().to_str().unwrap(); + insta::assert_debug_snapshot!(snapshot_name, functions); } } -- cgit v1.3.1