tinymist/tests/e2e/artifact.rs
Myriad-Dreamin cf20c66b26
Some checks are pending
tinymist::ci / Duplicate Actions Detection (push) Waiting to run
tinymist::ci / Check Clippy, Formatting, Completion, Documentation, and Tests (Linux) (push) Waiting to run
tinymist::ci / Check Minimum Rust version and Tests (Windows) (push) Waiting to run
tinymist::ci / prepare-build (push) Waiting to run
tinymist::ci / announce (push) Blocked by required conditions
tinymist::ci / build (push) Blocked by required conditions
tinymist::gh_pages / build-gh-pages (push) Waiting to run
test: ensure compile output works correctly (#1942)
Validate fix and prevent regression of
https://github.com/Myriad-Dreamin/tinymist/pull/1941
2025-07-30 23:25:59 +08:00

42 lines
1.3 KiB
Rust

use std::{io, path::PathBuf, sync::LazyLock};
use tinymist_std::path::PathClean;
fn find_git_root() -> io::Result<PathBuf> {
while !PathBuf::from(".git").exists() {
if std::env::set_current_dir("..").is_err() {
return Err(io::Error::new(
io::ErrorKind::NotFound,
"Git root not found",
));
}
}
std::env::current_dir()
}
pub static GIT_ROOT: LazyLock<PathBuf> =
LazyLock::new(|| find_git_root().expect("Failed to find git root").clean());
/// The CLI is the executable that already put inside of the VSCode extension's
/// `out` directory. This is intented, to ensure that we are testing the CLI to
/// publish in future.
pub static CLI: LazyLock<PathBuf> = LazyLock::new(|| {
let cli = if cfg!(windows) {
GIT_ROOT.join("editors/vscode/out/tinymist.exe")
} else {
GIT_ROOT.join("editors/vscode/out/tinymist")
};
if !cli.exists() {
panic!("tinymist binary for e2e tests doesn't exist. Please ensure that tinymist binary to publish is ready on {cli:?}. Running scripts/e2e.{{sh/ps1}} should also help this.");
}
cli
});
pub fn cli() -> std::process::Command {
let mut cmd = std::process::Command::new(&*CLI);
cmd.current_dir(&*GIT_ROOT);
cmd
}