Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
mrchantey committed Jan 12, 2025
1 parent 71d1139 commit b10e3e8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"rust-analyzer.cargo.features": ["sweet/bevy"],
"rust-analyzer.cargo.target": "wasm32-unknown-unknown",
// "rust-analyzer.cargo.target": "wasm32-unknown-unknown",
"deno.enable": true,
"search.exclude": {
"**/node_modules": true,
Expand Down
17 changes: 13 additions & 4 deletions cli/src/test_runners/test_wasm.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use anyhow::Result;
use clap::Parser;
use forky::prelude::ReadFile;
use std::fs;
use std::path::PathBuf;
use std::process::Command;
Expand Down Expand Up @@ -73,8 +74,15 @@ impl TestWasm {
/// by running `deno --version`
fn init_deno(&self) -> Result<()> {
let deno_runner_path = deno_runner_path();
if let Ok(true) = fs::exists(&deno_runner_path) {
return Ok(());
let deno_str = include_str!("./deno.ts");

// ⚠️ we should check the hash here
if ReadFile::exists(&deno_runner_path) {
let runner_hash = ReadFile::hash_file(&deno_runner_path)?;
let deno_hash = ReadFile::hash_string(deno_str);
if runner_hash == deno_hash {
return Ok(());
}
};

let deno_installed =
Expand All @@ -85,8 +93,10 @@ impl TestWasm {
if !deno_installed {
anyhow::bail!(INSTALL_DENO);
}
println!("copying deno file to {}", deno_runner_path.display());

// wasm-bindgen will ensure parent dir exists
fs::write(deno_runner_path, include_str!("./deno.ts"))?;
fs::write(deno_runner_path, deno_str)?;
Ok(())
}

Expand Down Expand Up @@ -148,6 +158,5 @@ mod test {
fn works() {
expect(deno_runner_path().to_string_lossy())
.to_end_with("target/sweet/deno.ts");
expect(true).to_be_false();
}
}
Empty file added crates/sweet_rsx/src/lib.rs
Empty file.
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test-all *args:
cargo test --test hello_async -- {{args}}
cargo test --test hello_async --target wasm32-unknown-unknown -- {{args}}
cargo test --workspace -- {{args}}
cargo test --workspace --target wasm32-unknown-unknown -- {{args}}
cargo test --lib --target wasm32-unknown-unknown -- {{args}}

expand-wasm test *args:
just watch 'cargo expand --test {{test}} --target wasm32-unknown-unknown {{args}}'
Expand Down

0 comments on commit b10e3e8

Please sign in to comment.