Skip to content

Commit

Permalink
Merge pull request #1599 from cachix/fix-wasm-test
Browse files Browse the repository at this point in the history
devenv-run-tests: switch directories in between tests
  • Loading branch information
domenkozar authored Nov 25, 2024
2 parents 6139463 + 5fbd554 commit a7125d2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
26 changes: 14 additions & 12 deletions devenv-run-tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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)
Expand All @@ -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");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/rust-wasm-cross/.test.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import("./app/pkg/app.js").then((app) => app.main());
import("./pkg/app.js").then((app) => app.main());
10 changes: 5 additions & 5 deletions examples/rust-wasm-cross/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a7125d2

Please sign in to comment.