mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 04:55:42 +09:00
fix(tools): stop the wasm clang test depending on an executable tempfile (#2009)
This commit is contained in:
1 parent
9940273cd9
commit
5ec02c3089
1 file changed
+14
-22
+14
-22
@@ -78,13 +78,20 @@ fn wasm_clang_candidates() -> Vec<PathBuf> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn discover_wasm_clang_from(candidates: Vec<PathBuf>) -> Result<PathBuf> {
|
fn discover_wasm_clang_from(candidates: Vec<PathBuf>) -> Result<PathBuf> {
|
||||||
|
discover_wasm_clang_with(candidates, clang_targets_wasm32)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn discover_wasm_clang_with(
|
||||||
|
candidates: Vec<PathBuf>,
|
||||||
|
targets_wasm32: impl Fn(&Path) -> bool,
|
||||||
|
) -> Result<PathBuf> {
|
||||||
let mut seen: Vec<PathBuf> = Vec::new();
|
let mut seen: Vec<PathBuf> = Vec::new();
|
||||||
for candidate in candidates {
|
for candidate in candidates {
|
||||||
if seen.contains(&candidate) {
|
if seen.contains(&candidate) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
seen.push(candidate.clone());
|
seen.push(candidate.clone());
|
||||||
if clang_targets_wasm32(&candidate) {
|
if targets_wasm32(&candidate) {
|
||||||
return Ok(candidate);
|
return Ok(candidate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -495,19 +502,13 @@ export const MARKDOWN_PARSER_WASM_BASE64 =\n\
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn wasm_clang_discovery_prefers_a_wasm32_capable_candidate_over_an_earlier_one() {
|
fn wasm_clang_discovery_prefers_a_wasm32_capable_candidate_over_an_earlier_one() {
|
||||||
let temp = TempDir::new().expect("temp dir");
|
let capable = PathBuf::from("/opt/llvm/bin/clang");
|
||||||
let clang = temp.path().join("clang");
|
let found = discover_wasm_clang_with(
|
||||||
fs::write(
|
vec![PathBuf::from("/nonexistent/clang"), capable.clone()],
|
||||||
&clang,
|
|candidate| candidate == capable,
|
||||||
"#!/bin/sh\nif [ \"$1\" = \"--print-targets\" ]; then echo ' wasm32 - WebAssembly 32-bit'; fi\n",
|
|
||||||
)
|
)
|
||||||
.expect("write fake clang");
|
.expect("the capable candidate advertises wasm32");
|
||||||
make_executable(&clang);
|
assert_eq!(found, capable);
|
||||||
|
|
||||||
let found =
|
|
||||||
discover_wasm_clang_from(vec![PathBuf::from("/nonexistent/clang"), clang.clone()])
|
|
||||||
.expect("the fake clang advertises wasm32");
|
|
||||||
assert_eq!(found, clang);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -521,15 +522,6 @@ export const MARKDOWN_PARSER_WASM_BASE64 =\n\
|
|||||||
assert_eq!(discover_wasm_ar(&clang), Some(archiver));
|
assert_eq!(discover_wasm_ar(&clang), Some(archiver));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
|
||||||
fn make_executable(path: &Path) {
|
|
||||||
use std::os::unix::fs::PermissionsExt;
|
|
||||||
fs::set_permissions(path, fs::Permissions::from_mode(0o755)).expect("chmod");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(unix))]
|
|
||||||
fn make_executable(_path: &Path) {}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn libfluxcore_bindgen_dts_reset_hook_is_inserted() {
|
fn libfluxcore_bindgen_dts_reset_hook_is_inserted() {
|
||||||
let content = "export function is_animated_image(input: Uint8Array): boolean;\nexport type InitInput = RequestInfo;";
|
let content = "export function is_animated_image(input: Uint8Array): boolean;\nexport type InitInput = RequestInfo;";
|
||||||
|
|||||||
Reference in new issue
Block a user