summaryrefslogtreecommitdiff
path: root/rust/tests/binary_view.rs
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-06-27 10:28:23 -0400
committerMason Reed <mason@vector35.com>2025-07-02 01:56:54 -0400
commitec8dfdbb6f291d281c48139dd65e659fe1208bf3 (patch)
tree8ffd8e9ee7e0d7f7bb943a7f194bf7767ecf5ea8 /rust/tests/binary_view.rs
parent6662b774b37840380c2e2274a4ca01680b72ba90 (diff)
[Rust] Fixup some unit tests
Diffstat (limited to 'rust/tests/binary_view.rs')
-rw-r--r--rust/tests/binary_view.rs29
1 files changed, 15 insertions, 14 deletions
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::<PathBuf>().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<u64, FunctionSnapshot> = 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<u64, FunctionSnapshot> = 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);
}
}