Files
RedBear-OS/local/recipes/shells/brush/source/brush-shell/tests/version_tests.rs
T
vasilito 25fb843c40 brush: vendor the source tree (un-ignore) to complete the local fork
The prior commit switched the recipe to `[source] path = "source"`, but
.gitignore:77 still listed `local/recipes/shells/brush/source` (a leftover from
when brush was a transient upstream git fetch), so the vendored tree was not
tracked — a fresh clone would have no brush source and the build would fail.
Drop that ignore line and commit the vendored working tree (reubeno/brush @
897b373e, with the Redox port patches pre-applied). brush is now a durable
local fork like the other path=source recipes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-26 23:34:31 +09:00

49 lines
1.3 KiB
Rust

//! Integration tests for brush shell
//!
//! Most CLI tests have been moved to YAML format in tests/cases/brush/cli.yaml.
//! This file contains tests that require dynamic value comparison.
// For now, only compile this for Unix-like platforms (Linux, macOS).
#![cfg(unix)]
#![cfg(test)]
#![allow(clippy::panic_in_result_fn)]
use anyhow::Context;
#[test]
fn get_version_variables() -> anyhow::Result<()> {
let shell_path = assert_cmd::cargo::cargo_bin!("brush");
let brush_ver_str = get_variable(shell_path, /* shell_is_brush */ true, "BRUSH_VERSION")?;
let bash_ver_str = get_variable(shell_path, /* shell_is_brush */ false, "BASH_VERSION")?;
assert_eq!(brush_ver_str, env!("CARGO_PKG_VERSION"));
assert_ne!(
brush_ver_str, bash_ver_str,
"Should differ for scripting use-case"
);
Ok(())
}
fn get_variable(
shell_path: &std::path::Path,
shell_is_brush: bool,
var: &str,
) -> anyhow::Result<String> {
let mut cmd = std::process::Command::new(shell_path);
if shell_is_brush {
cmd.arg("--no-config");
}
let output = cmd
.arg("--norc")
.arg("--noprofile")
.arg("-c")
.arg(format!("echo -n ${{{var}}}"))
.output()
.with_context(|| format!("failed to retrieve {var}"))?
.stdout;
Ok(String::from_utf8(output)?)
}