Skip to content

Commit 9af3cc5

Browse files
committed
Fix pathing for windows by cfg-gating test
1 parent 0f3ee87 commit 9af3cc5

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

tests/[funky-javahome]/nested/more*nested/libjvm.dll

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/[funky-javahome]/nested/more*nested/libjvm.so

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/ensure-escaped.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
use java_locator::locate_jvm_dyn_library;
22

3+
// Windows does not support `[`, `]`, or `*` in paths so this test does not apply
4+
#[cfg(not(target_os = "windows"))]
35
#[test]
46
fn test_javahome_can_be_escaped() {
5-
println!("{:?}", std::env::current_dir());
6-
std::env::set_var("JAVA_HOME", "tests/[funky-javahome]/nested");
7+
use std::env::temp_dir;
8+
9+
let test_path = temp_dir()
10+
.join("[funky-javahome]")
11+
.join("nested")
12+
.join("*dir*");
13+
14+
std::fs::create_dir_all(&test_path).expect("failed to create directory");
15+
std::fs::write(test_path.join("libjvm.so"), "stub-file").unwrap();
16+
std::env::set_var(
17+
"JAVA_HOME",
18+
test_path.to_str().expect("no invalid characters"),
19+
);
720
assert_eq!(
821
locate_jvm_dyn_library().expect("failed to located jvm library"),
9-
"tests/[funky-javahome]/nested/more*nested"
22+
format!(
23+
"{}",
24+
temp_dir().join("[funky-javahome]/nested/*dir*").display()
25+
)
1026
);
1127
}

0 commit comments

Comments
 (0)