Add listing for precompiled Windows binaries

They're fixed on wasm-bindgen's CI, so let's download/install them!
master
Alex Crichton 7 years ago
parent d0fc382c3c
commit 0381aa627a
  1. 3
      src/bindgen.rs
  2. 20
      tests/all/bindgen.rs

@ -99,12 +99,15 @@ fn curl(url: &str) -> Result<Vec<u8>, failure::Error> {
pub fn download_prebuilt_wasm_bindgen(root_path: &Path, version: &str) -> Result<(), Error> {
let linux = cfg!(target_os = "linux");
let macos = cfg!(target_os = "macos");
let windows = cfg!(windows);
let x86_64 = cfg!(target_arch = "x86_64");
let target = if linux && x86_64 {
"x86_64-unknown-linux-musl"
} else if macos && x86_64 {
"x86_64-apple-darwin"
} else if windows && x86_64 {
"x86_64-pc-windows-msvc"
} else {
return Err(Error::unsupported(
"there are no pre-built `wasm-bindgen` binaries for this target",

@ -4,16 +4,25 @@ use wasm_pack::bindgen;
#[test]
#[cfg(any(
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "macos", target_arch = "x86_64")
all(target_os = "macos", target_arch = "x86_64"),
all(windows, target_arch = "x86_64"),
))]
fn can_download_prebuilt_wasm_bindgen() {
use std::env;
let dir = tempfile::TempDir::new().unwrap();
bindgen::download_prebuilt_wasm_bindgen(dir.path(), "0.2.19").unwrap();
assert!(dir.path().join("bin").join("wasm-bindgen").is_file());
bindgen::download_prebuilt_wasm_bindgen(dir.path(), "0.2.21").unwrap();
assert!(
dir.path()
.join("bin")
.join("wasm-bindgen")
.with_extension(env::consts::EXE_EXTENSION)
.is_file()
);
assert!(
dir.path()
.join("bin")
.join("wasm-bindgen-test-runner")
.with_extension(env::consts::EXE_EXTENSION)
.is_file()
);
}
@ -21,11 +30,12 @@ fn can_download_prebuilt_wasm_bindgen() {
#[test]
#[cfg(any(
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "macos", target_arch = "x86_64")
all(target_os = "macos", target_arch = "x86_64"),
all(windows, target_arch = "x86_64"),
))]
fn downloading_prebuilt_wasm_bindgen_handles_http_errors() {
let dir = tempfile::TempDir::new().unwrap();
let bad_version = "0.2.19-some-trailing-version-stuff-that-does-not-exist";
let bad_version = "0.2.21-some-trailing-version-stuff-that-does-not-exist";
let result = bindgen::download_prebuilt_wasm_bindgen(dir.path(), bad_version);
assert!(result.is_err());
let error_msg = result.unwrap_err().to_string();

Loading…
Cancel
Save