mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-23 18:21:13 +08:00
fix: test 未实现子命令退出码由 0 改为 2 以区分成功与运行失败
This commit is contained in:
@@ -470,5 +470,6 @@ fn not_implemented(command: &str) -> ExitCode {
|
|||||||
use ansi_term::Colour::Yellow;
|
use ansi_term::Colour::Yellow;
|
||||||
kernel_info!("command not yet implemented: {}", command);
|
kernel_info!("command not yet implemented: {}", command);
|
||||||
eprintln!("{}", Yellow.paint(format!("'{command}' is not yet implemented")));
|
eprintln!("{}", Yellow.paint(format!("'{command}' is not yet implemented")));
|
||||||
ExitCode::SUCCESS
|
// 2 = 未实现,与 0=成功、1=运行失败区分,供脚本与 CI 识别。
|
||||||
|
ExitCode::from(2)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,22 @@ fn eval_array_output() {
|
|||||||
assert!(stdout.trim() == "[1, 2, 3]", "eval 数组应打印元素区内容: {stdout}");
|
assert!(stdout.trim() == "[1, 2, 3]", "eval 数组应打印元素区内容: {stdout}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_stub_exit_code() {
|
||||||
|
let output = Command::new(env!("CARGO_BIN_EXE_oxide"))
|
||||||
|
.args(["test"])
|
||||||
|
.output()
|
||||||
|
.expect("failed to run oxide test");
|
||||||
|
|
||||||
|
// 未实现子命令固定退出码 2,区别于 0=成功 / 1=运行失败。
|
||||||
|
assert_eq!(output.status.code(), Some(2), "test stub should exit 2");
|
||||||
|
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||||
|
assert!(
|
||||||
|
stderr.contains("not yet implemented"),
|
||||||
|
"test stub should print not-implemented notice: {stderr}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn bench_help() {
|
fn bench_help() {
|
||||||
let output = Command::new(env!("CARGO_BIN_EXE_oxide"))
|
let output = Command::new(env!("CARGO_BIN_EXE_oxide"))
|
||||||
|
|||||||
Reference in New Issue
Block a user