()
| 460 | |
| 461 | #[test] |
| 462 | fn find_java_binary_picks_first_in_bin_directory() { |
| 463 | let root = create_test_dir("jre_find_java_binsearch"); |
| 464 | let java_name = if OS == "windows" { "java.exe" } else { "java" }; |
| 465 | |
| 466 | // Create two java binaries in different directories |
| 467 | let java_path1 = root.join("jdk-20").join("bin").join(java_name); |
| 468 | let java_path2 = root.join("jdk-21").join("bin").join(java_name); |
| 469 | |
| 470 | fs::create_dir_all(java_path1.parent().unwrap()).unwrap(); |
| 471 | fs::create_dir_all(java_path2.parent().unwrap()).unwrap(); |
| 472 | File::create(&java_path1).unwrap(); |
| 473 | File::create(&java_path2).unwrap(); |
| 474 | |
| 475 | let detected = find_java_binary(&root); |
| 476 | |
| 477 | // Should find at least one java binary |
| 478 | assert!(detected.is_some()); |
| 479 | let detected_path = detected.unwrap(); |
| 480 | assert!(detected_path.to_string_lossy().contains("bin")); |
| 481 | assert!(detected_path.file_name().unwrap() == java_name); |
| 482 | |
| 483 | fs::remove_dir_all(&root).unwrap(); |
| 484 | } |
| 485 | } |
nothing calls this directly
no test coverage detected