Unlucky Launcher v0.2.0
CI / runtime smoke (macos arm64, probe) (push) Skipped
CI / fmt (rustfmt --check) (push) Canceled after 0s
CI / clippy (ubuntu-latest) (push) Canceled after 0s
CI / clippy (windows-latest) (push) Canceled after 0s
CI / test (ubuntu-latest) (push) Canceled after 0s
CI / test (windows-latest) (push) Canceled after 0s
CI / build release (ubuntu-latest) (push) Canceled after 0s
CI / build release (windows-latest) (push) Canceled after 0s
CI / runtime smoke (ubuntu x64, xvfb) (push) Canceled after 0s
Guards / core 零 UI 守门 (push) Canceled after 0s
Guards / presenter 零 UI 守门 (push) Canceled after 0s
Guards / design 零第三方依赖守门 (push) Canceled after 0s
Guards / unsafe 落点守门(集合必须恰好一个文件) (push) Canceled after 0s
Guards / 文件行数 ≤400 守门 (push) Canceled after 0s
Guards / 依赖许可与来源(cargo-deny) (push) Canceled after 0s

首个 iced + Material 3 Expressive 版本的源码快照。
完整历史与日常提交在 dev 分支;main 只放阶段性快照。
This commit is contained in:
AskaEth committed 2026-11-05 14:22:11 +08:00
commit 8a8e5ca0c0
1079 files changed
+208035

No files matched your search

+66
View File
@@ -0,0 +1,66 @@
//! 测试公用件:fixture 解析、内存父版本表、临时目录守卫。
use std::collections::BTreeMap;
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicU64, Ordering};
use std::time::{SystemTime, UNIX_EPOCH};
use unlucky_core::game::manifest::VersionJson;
/// 解析 fixture JSON(fixture 是测试常量,解析失败即 panic)。
pub fn parse(json: &str) -> VersionJson {
VersionJson::from_json_str(json).expect("fixture 必须可解析")
}
/// 用 `(id, json)` 对建内存父版本表,喂给 `inherit::resolve`。
pub fn source(pairs: &[(&str, &str)]) -> BTreeMap<String, VersionJson> {
pairs
.iter()
.map(|(id, json)| ((*id).to_owned(), parse(json)))
.collect()
}
/// 唯一临时目录守卫:`drop` 时递归删除。
pub struct TempDir {
path: PathBuf,
}
impl TempDir {
/// 建一个唯一临时目录。
pub fn new(tag: &str) -> Self {
static COUNTER: AtomicU64 = AtomicU64::new(0);
let nanos = SystemTime::now()
.duration_since(UNIX_EPOCH)
.map_or(0, |d| d.as_nanos());
let seq = COUNTER.fetch_add(1, Ordering::Relaxed);
let path = std::env::temp_dir().join(format!(
"ull-game-{tag}-{}-{nanos}-{seq}",
std::process::id()
));
std::fs::create_dir_all(&path).expect("临时目录应可创建");
Self { path }
}
/// 目录路径。
pub fn path(&self) -> &Path {
&self.path
}
}
impl Drop for TempDir {
fn drop(&mut self) {
let _ = std::fs::remove_dir_all(&self.path);
}
}
/// 建一个游戏根布局(纯路径计算,不建目录)。
pub fn layout(root: &Path) -> unlucky_core::game::GameLayout {
unlucky_core::game::GameLayout::new(root)
}
/// 造 `dir/<name>` 并写一个文件进去(模拟玩家内容:`mods`/`saves`/`config` 的条目)。
pub fn seed(dir: &Path, name: &str) {
let target = dir.join(name);
std::fs::create_dir_all(&target).expect("建目录");
std::fs::write(target.join("entry.txt"), b"x").expect("写文件");
}