Skip to content

Commit 4e89e81

Browse files
committed
[Rust] Fixup some unit tests
1 parent 2403e72 commit 4e89e81

File tree

5 files changed

+2475
-1695
lines changed

5 files changed

+2475
-1695
lines changed

rust/tests/binary_view.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ fn test_binary_view_strings() {
9999
assert_eq!(str_15dc.length, 33);
100100
}
101101

102+
// These are the target files present in OUT_DIR
103+
// Add the files to fixtures/bin
104+
static TARGET_FILES: [&str; 2] = ["atox.obj", "atof.obj"];
105+
102106
// This is what we store to check if a function matches the expected function.
103107
// See `test_deterministic_functions` for details.
104108
#[derive(Debug, PartialEq)]
@@ -120,19 +124,16 @@ impl From<&Function> for FunctionSnapshot {
120124
fn test_deterministic_functions() {
121125
let session = Session::new().expect("Failed to initialize session");
122126
let out_dir = env!("OUT_DIR").parse::<PathBuf>().unwrap();
123-
for entry in std::fs::read_dir(out_dir).expect("Failed to read OUT_DIR") {
124-
let entry = entry.expect("Failed to read directory entry");
125-
let path = entry.path();
126-
if path.is_file() {
127-
let view = session.load(&path).expect("Failed to load view");
128-
assert_eq!(view.analysis_progress().state, AnalysisState::IdleState);
129-
let functions: BTreeMap<u64, FunctionSnapshot> = view
130-
.functions()
131-
.iter()
132-
.map(|f| (f.start(), FunctionSnapshot::from(f.as_ref())))
133-
.collect();
134-
let snapshot_name = path.file_stem().unwrap().to_str().unwrap();
135-
insta::assert_debug_snapshot!(snapshot_name, functions);
136-
}
127+
for file_name in TARGET_FILES {
128+
let path = out_dir.join(file_name);
129+
let view = session.load(&path).expect("Failed to load view");
130+
assert_eq!(view.analysis_progress().state, AnalysisState::IdleState);
131+
let functions: BTreeMap<u64, FunctionSnapshot> = view
132+
.functions()
133+
.iter()
134+
.map(|f| (f.start(), FunctionSnapshot::from(f.as_ref())))
135+
.collect();
136+
let snapshot_name = path.file_stem().unwrap().to_str().unwrap();
137+
insta::assert_debug_snapshot!(snapshot_name, functions);
137138
}
138139
}

rust/tests/initialization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn test_license_validation() {
1414
// Release the floating license if we already have one, otherwise the failure will succeed.
1515
release_license(true);
1616
// Make sure we properly report invalid license.
17-
let options = InitializationOptions::default()
17+
let options = InitializationOptions::new()
1818
.with_license_checkout(false)
1919
.with_license("blah blag");
2020
match init_with_opts(options) {

0 commit comments

Comments
 (0)