From c9d3e173fc1a58e6b3d7e9214077e44200b6e969 Mon Sep 17 00:00:00 2001 From: Sander Date: Wed, 20 Nov 2024 02:52:23 +0400 Subject: [PATCH 1/2] devenv-run-tests: switch directories between tests --- devenv-run-tests/src/main.rs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/devenv-run-tests/src/main.rs b/devenv-run-tests/src/main.rs index cac4fa523..0c3bfb196 100644 --- a/devenv-run-tests/src/main.rs +++ b/devenv-run-tests/src/main.rs @@ -2,8 +2,8 @@ use clap::Parser; use devenv::log::Level; use devenv::log::Logger; use devenv::{Devenv, DevenvOptions}; -use std::fs; use std::path::PathBuf; +use std::{env, fs}; #[derive(Parser, Debug)] #[clap(author, version, about, long_about = None)] @@ -97,27 +97,26 @@ async fn run_tests_in_directory( }; let mut devenv = Devenv::new(options).await; - // A script to patch files in the working directory before the shell. - let patch_script = ".patch.sh"; - let patch_script_path = path.join(patch_script); + println!(" Running {}", dir_name); - // A script to run inside the shell before the test. - let setup_script = ".setup.sh"; - let setup_script_path = path.join(setup_script); + env::set_current_dir(path).expect("failed to set current dir"); - println!(" Running {}", dir_name); + // A script to patch files in the working directory before the shell. + let patch_script = ".patch.sh"; // Run .patch.sh if it exists - if patch_script_path.exists() { + if PathBuf::from(patch_script).exists() { println!(" Running {patch_script}"); let _ = std::process::Command::new("bash") - .arg("./.patch.sh") - .current_dir(path) + .arg(patch_script) .status()?; } + // A script to run inside the shell before the test. + let setup_script = ".setup.sh"; + // Run .setup.sh if it exists - if setup_script_path.exists() { + if PathBuf::from(setup_script).exists() { println!(" Running {setup_script}"); devenv .shell(&Some(format!("./{setup_script}")), &[], false) @@ -131,6 +130,9 @@ async fn run_tests_in_directory( passed: status.is_ok(), }; test_results.push(result); + + // Restore the current directory + env::set_current_dir(&cwd).expect("failed to set current dir"); } } } From 5fbd554958791d0d8948b4efaa3d7af822c8bbe3 Mon Sep 17 00:00:00 2001 From: Sander Date: Wed, 20 Nov 2024 02:52:48 +0400 Subject: [PATCH 2/2] examples: fix the rust wasm test --- examples/rust-wasm-cross/.test.js | 2 +- examples/rust-wasm-cross/Cargo.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/rust-wasm-cross/.test.js b/examples/rust-wasm-cross/.test.js index 1d5c2f1ea..4ce786322 100644 --- a/examples/rust-wasm-cross/.test.js +++ b/examples/rust-wasm-cross/.test.js @@ -1 +1 @@ -import("./app/pkg/app.js").then((app) => app.main()); +import("./pkg/app.js").then((app) => app.main()); diff --git a/examples/rust-wasm-cross/Cargo.lock b/examples/rust-wasm-cross/Cargo.lock index 6cb985a42..104d077d7 100644 --- a/examples/rust-wasm-cross/Cargo.lock +++ b/examples/rust-wasm-cross/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 4 +version = 3 [[package]] name = "app" @@ -35,9 +35,9 @@ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "proc-macro2" -version = "1.0.88" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] @@ -53,9 +53,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.79" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote",