fix(core): 首轮编译/测试抓到的四个问题(BTreeMap、测试模块布局、display_loader_version、未用 import)
1. liteloader.rs 拆文件后漏了 `use std::collections::BTreeMap`(`loader_library` 里用)。 2. `tests/liteloader.rs` 是 **crate root**,`mod guards;` 会被找去 `tests/guards.rs`; 改成 `tests/liteloader/main.rs`(与 `tests/game/main.rs` 同形),target 名仍是 liteloader。 3. `display_loader_version` 去通配时丢了 NeoForge@1.20.1(forge 布局)去前缀的语义: 既有用例 `neoforge_1201_uses_forge_layout` 当场抓住(1.20.1-47.1.106 → 47.1.106)。 现在按「加载器 + 是否 forge 布局」显式决定,四家原有行为逐字不变。 4. `dto/instances.rs` 的 `pub use super::LaunchArgsView` 在非 test 构建里没人用(-D warnings 会红), 改由 `dto/instances/tests.rs` 直接 `use crate::dto::LaunchArgsView`。 顺带修两条**我自己写错的测试期望**(不是产品 bug): - 取消用例里那条 `resolve` 断言用错了父版本表(父版本在内存表里,当然解析成功); - 新式父链用例误以为 `minecraftArguments` 会是 None,实际会沿链继承祖父层那份 —— 断言改成「继承来的 legacy 串里不许出现 LiteLoaderTweaker」。
This commit is contained in:
1 parent
51ea32284d
commit
3114fa2d4f
8 files changed
+31
-25
No files matched your search
@@ -12,13 +12,10 @@ use unlucky_core::addon::loader::{
|
||||
};
|
||||
use unlucky_core::download::blocking::block_on;
|
||||
use unlucky_core::game::arguments::Environment;
|
||||
use unlucky_core::game::inherit::resolve;
|
||||
use unlucky_core::game::install::{execute_with_cancel, InstallErrorKind};
|
||||
use unlucky_core::game::layout::GameLayout;
|
||||
|
||||
use crate::support::{
|
||||
engine, liteloader_release, prefill, put_version, read_version, TempDir, VANILLA_1122,
|
||||
};
|
||||
use crate::support::{engine, liteloader_release, prefill, put_version, TempDir, VANILLA_1122};
|
||||
|
||||
/// 父版本不是原版、又没装在盘上 → **具名报错**,绝不默默改成叠原版。
|
||||
#[test]
|
||||
@@ -145,15 +142,6 @@ fn cancel_leaves_no_manifest() {
|
||||
!layout.version_json(&release.version_id).exists(),
|
||||
"取消之后不许留下版本清单"
|
||||
);
|
||||
|
||||
// 继承链在缺清单时也应明确报「父版本缺失」,而不是静默降级成原版。
|
||||
let mut source = std::collections::BTreeMap::new();
|
||||
source.insert("1.12.2".to_string(), read_version(&layout, "1.12.2"));
|
||||
let error = resolve(&source, &release.version_json).expect_err("父版本缺失");
|
||||
assert!(matches!(
|
||||
error,
|
||||
unlucky_core::game::GameError::MissingParent { .. }
|
||||
));
|
||||
}
|
||||
|
||||
/// 同一个 loader 版本 id 被两条父链请求:**具名报错**,且盘上那份清单一个字节都不动。
|
||||
|
||||
@@ -219,8 +219,16 @@ fn new_style_parent_args_are_appended_not_replaced() {
|
||||
);
|
||||
let resolved = resolve(&source, &source[&release.version_id]).expect("三层继承应可解析");
|
||||
|
||||
// 父层用的是新式参数:子层没有把 legacy 串写进来,继承后仍然没有。
|
||||
assert!(resolved.minecraft_arguments.is_none());
|
||||
// 子层没写 legacy 串:继承结果里的 `minecraftArguments` 只能是祖父层(原版)那一份,
|
||||
// 里面绝不能出现 LiteLoader 的 tweakClass(写了就说明我们用了覆盖语义)。
|
||||
let legacy = resolved
|
||||
.minecraft_arguments
|
||||
.as_deref()
|
||||
.expect("原版那份 legacy 串应沿链继承下来");
|
||||
assert!(
|
||||
!legacy.contains("LiteLoaderTweaker"),
|
||||
"loader 层不许往 minecraftArguments 里写:{legacy}"
|
||||
);
|
||||
let game = resolved
|
||||
.arguments
|
||||
.as_ref()
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
//! LiteLoader 安装链路的集成测试(`tests/liteloader*` 这个 test target 的入口)。
|
||||
//!
|
||||
//! 判据链:**真实元数据夹具 → 解析 → 合成清单 → 计划 → 落盘 → 继承解析 → 启动参数顺序**。
|
||||
//! 全程不联网:LiteLoader 的库没有 sha1/size,`execute` 的跳过判据是「存在即信」,
|
||||
//! 所以先把每个待下文件按计划里的落点写一份占位字节,执行期就只做「跳过 + 写版本 JSON」。
|
||||
//!
|
||||
//! 夹具来源(可追溯):
|
||||
//! - `fixtures/liteloader-versions.json` = 2026-11 从 `https://dl.liteloader.com/versions/versions.json`
|
||||
//! 真取的响应(200 / 49129 字节 / 16 个原版版本)裁剪到两个原版版本,**字段名与嵌套结构原样**;
|
||||
//! - `metadata.xml` = 同一次探测里 `repo.mumfrey.com/…/liteloader/1.12.2-SNAPSHOT/maven-metadata.xml`
|
||||
//! 的原样响应(200 / 358 字节);
|
||||
//! - 原版 / Forge 1.12.2 的版本 JSON 是按官方清单形状写的最小夹具(Forge 那侧的
|
||||
//! `minecraftArguments` 与 `crates/core/src/addon/loader/tests/forge.rs` 的实测夹具一致)。
|
||||
//!
|
||||
//! 未覆盖(如实留档):真实下载(走 `core::download` 引擎的镜像/退避,已有 M13 的单测覆盖)、
|
||||
//! 真实 MC 启动、`dl.liteloader.com` / `repo.mumfrey.com` 的持续可用性。
|
||||
|
||||
mod guards;
|
||||
mod install;
|
||||
mod support;
|
||||
Reference in new issue
Block a user