mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-23 18:21:13 +08:00
feat: --version 嵌入构建期 git 哈希并新增新鲜度检查脚本
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
//! 构建脚本:取构建期 git 短哈希注入二进制(`GIT_COMMIT` 环境变量)。
|
||||
//!
|
||||
//! 哈希供 `--version` 自报,作为二进制新鲜度自证锚点(与 `git rev-parse --short HEAD`
|
||||
//! 对照即可判定二进制是否落后于 HEAD)。无 git 环境(CI、解压源码)哈希缺省
|
||||
//! `unknown`,构建不失败。
|
||||
|
||||
fn main() {
|
||||
// 构建脚本或源码变化时重跑,保持哈希与源码同步。
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
println!("cargo:rerun-if-changed=src");
|
||||
println!("cargo:rerun-if-changed=Cargo.toml");
|
||||
|
||||
// git 缺失或无提交时容缺,哈希缺省 "unknown"。
|
||||
let hash = std::process::Command::new("git")
|
||||
.args(["rev-parse", "--short", "HEAD"])
|
||||
.output()
|
||||
.ok()
|
||||
.filter(|o| o.status.success())
|
||||
.map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string())
|
||||
.filter(|h| !h.is_empty())
|
||||
.unwrap_or_else(|| "unknown".to_string());
|
||||
|
||||
println!("cargo:rustc-env=GIT_COMMIT={hash}");
|
||||
}
|
||||
@@ -80,12 +80,13 @@ impl RunConfig {
|
||||
|
||||
/// 打印用法说明。
|
||||
pub(crate) fn usage() -> String {
|
||||
"usage: test262-runner [--no-skip] [--no-regalloc] [--verbose] [--supervise] [--leak-check] [--leak-check-interval=N] [test262-root] [path-filter]\n\
|
||||
"usage: test262-runner [--no-skip] [--no-regalloc] [--verbose] [--supervise] [--leak-check] [--leak-check-interval=N] [--version] [test262-root] [path-filter]\n\
|
||||
\n\
|
||||
--no-skip Run capability-excluded tests and count unsupported compile/runtime results as failures.\n\
|
||||
--no-regalloc Disable the liveness/precise-DCE/RegAlloc compiler chain (vregs stay as physical numbers).\n\
|
||||
--verbose Print one PASS/FAIL/SKIP line per test (for on/off result-set comparison).\n\
|
||||
--no-fail-list Do not print the per-path FAIL list at the end of the run.\n\
|
||||
--version Print the binary version with the build-time git short hash (freshness self-check), then exit.\n\
|
||||
--supervise Run the suite as single-worker child-process windows with a hard per-test timeout and\n\
|
||||
\x20 automatic resume past any hanging/crashing test. A hang or crash is reported by path.\n\
|
||||
\x20 Combines with [path-filter]: the filter is applied per-test inside each child window.\n\
|
||||
|
||||
@@ -74,6 +74,11 @@ fn run_tests() -> bool {
|
||||
println!("{}", RunConfig::usage());
|
||||
return true;
|
||||
}
|
||||
// 版本自报走 stdout 并成功退出;哈希由构建期注入,无 git 环境缺省 "unknown"。
|
||||
if args.iter().any(|a| a == "--version") {
|
||||
println!("test262-runner {} ({})", env!("CARGO_PKG_VERSION"), env!("GIT_COMMIT"));
|
||||
return true;
|
||||
}
|
||||
let config = match RunConfig::parse(&args) {
|
||||
Ok(config) => config,
|
||||
Err(msg) => {
|
||||
|
||||
Reference in New Issue
Block a user