Merge pull request #283 from alexcrichton/windows-download

Add listing for precompiled Windows binaries
master
ashley williams 7 years ago committed by GitHub
commit 1f0f4403fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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> { pub fn download_prebuilt_wasm_bindgen(root_path: &Path, version: &str) -> Result<(), Error> {
let linux = cfg!(target_os = "linux"); let linux = cfg!(target_os = "linux");
let macos = cfg!(target_os = "macos"); let macos = cfg!(target_os = "macos");
let windows = cfg!(windows);
let x86_64 = cfg!(target_arch = "x86_64"); let x86_64 = cfg!(target_arch = "x86_64");
let target = if linux && x86_64 { let target = if linux && x86_64 {
"x86_64-unknown-linux-musl" "x86_64-unknown-linux-musl"
} else if macos && x86_64 { } else if macos && x86_64 {
"x86_64-apple-darwin" "x86_64-apple-darwin"
} else if windows && x86_64 {
"x86_64-pc-windows-msvc"
} else { } else {
return Err(Error::unsupported( return Err(Error::unsupported(
"there are no pre-built `wasm-bindgen` binaries for this target", "there are no pre-built `wasm-bindgen` binaries for this target",

@ -4,16 +4,25 @@ use wasm_pack::bindgen;
#[test] #[test]
#[cfg(any( #[cfg(any(
all(target_os = "linux", target_arch = "x86_64"), 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() { fn can_download_prebuilt_wasm_bindgen() {
use std::env;
let dir = tempfile::TempDir::new().unwrap(); let dir = tempfile::TempDir::new().unwrap();
bindgen::download_prebuilt_wasm_bindgen(dir.path(), "0.2.19").unwrap(); bindgen::download_prebuilt_wasm_bindgen(dir.path(), "0.2.21").unwrap();
assert!(dir.path().join("bin").join("wasm-bindgen").is_file()); assert!(
dir.path()
.join("bin")
.join("wasm-bindgen")
.with_extension(env::consts::EXE_EXTENSION)
.is_file()
);
assert!( assert!(
dir.path() dir.path()
.join("bin") .join("bin")
.join("wasm-bindgen-test-runner") .join("wasm-bindgen-test-runner")
.with_extension(env::consts::EXE_EXTENSION)
.is_file() .is_file()
); );
} }
@ -21,11 +30,12 @@ fn can_download_prebuilt_wasm_bindgen() {
#[test] #[test]
#[cfg(any( #[cfg(any(
all(target_os = "linux", target_arch = "x86_64"), 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() { fn downloading_prebuilt_wasm_bindgen_handles_http_errors() {
let dir = tempfile::TempDir::new().unwrap(); 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); let result = bindgen::download_prebuilt_wasm_bindgen(dir.path(), bad_version);
assert!(result.is_err()); assert!(result.is_err());
let error_msg = result.unwrap_err().to_string(); let error_msg = result.unwrap_err().to_string();

Loading…
Cancel
Save