Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devenv-run-tests: switch directories in between tests #1599

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading