Files
SCOPENET-MC/crates/core/tests/online.rs
T
Claude 5dc8a4f2f1 Add Docker image, Compose, CI/CD workflows and docs
- Multi-arch (amd64/arm64) panel image: static musl binary on scratch,
  cross-compiled with cargo-zigbuild (no QEMU), non-root, healthcheck
- docker-compose.yml + .env.example for one-command deployment
- CI: fmt, clippy, tests, web type-checks, Windows launcher build,
  real-network installs of vanilla/Fabric/Quilt/Forge/NeoForge,
  Docker build
- Release: Windows NSIS installer with baked-in panel URL, GHCR image
  push and GitHub release (tag push or manual dispatch)
- README, admin guide, Microsoft auth setup, architecture, development
- rustfmt config and formatting pass

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011ARcGWxLx21FwXJ3yfGriS
2026-09-28 05:19:36 +00:00

97 lines
3.1 KiB
Rust

//! Real-network installs against Mojang / Fabric / Forge / NeoForge.
//! Ignored by default; CI runs them with `cargo test -p scopenet-core --test online -- --ignored`.
use scopenet_core::install::{install, InstallSpec};
use scopenet_core::launch::{self, Auth, GcPreset, LaunchOptions};
use scopenet_core::{progress, Layout};
use scopenet_shared::Loader;
async fn run(mc: &str, loader: Loader) {
let root =
std::env::var("SCOPENET_TEST_ROOT").map(std::path::PathBuf::from).unwrap_or_else(|_| std::env::temp_dir().join("scopenet-online"));
let layout = Layout::new(&root);
let client = scopenet_core::http::client();
let game_dir = layout.instance_dir(&format!("{mc}-{}", loader.as_str()));
let spec = InstallSpec {
mc_version: mc.into(),
loader,
loader_version: None,
java_override: None,
game_dir: game_dir.clone(),
concurrency: 16,
deep_verify: false,
};
let installed = install(&client, &layout, &spec, &progress::noop()).await.unwrap_or_else(|e| panic!("{mc} {loader:?}: {e:#}"));
for path in installed.classpath(&layout) {
assert!(path.exists(), "missing classpath entry {}", path.display());
}
assert!(installed.java.exists(), "java missing at {}", installed.java.display());
let opts = LaunchOptions {
auth: Auth {
username: "CiBot".into(),
uuid: scopenet_shared::offline_uuid("CiBot"),
access_token: "0".into(),
user_type: "legacy".into(),
xuid: None,
},
game_dir,
memory_min_mb: 512,
memory_max_mb: 2048,
gc: GcPreset::G1,
extra_jvm_args: vec![],
resolution: None,
fullscreen: false,
join_server: Some(("example.org".into(), 25565)),
version_label: "ci".into(),
launcher_name: "scopenet".into(),
launcher_version: "ci".into(),
};
let cmd = launch::build(&installed, &layout, &opts);
let joined = cmd.args.join(" ");
assert!(!joined.contains("${"), "unsubstituted placeholder in: {joined}");
// The downloaded runtime must actually run.
let out = std::process::Command::new(scopenet_core::java::sibling_exe(&installed.java, false)).arg("-version").output().unwrap();
assert!(out.status.success());
println!("{mc} {loader:?}: OK ({} classpath entries, java {})", installed.classpath(&layout).len(), installed.java_major);
}
#[tokio::test]
#[ignore]
async fn vanilla_latest_release() {
let m = scopenet_core::meta::mojang_manifest(&scopenet_core::http::client()).await.unwrap();
run(&m.latest.release, Loader::Vanilla).await;
}
#[tokio::test]
#[ignore]
async fn vanilla_legacy_1_8_9() {
run("1.8.9", Loader::Vanilla).await;
}
#[tokio::test]
#[ignore]
async fn fabric_1_21_1() {
run("1.21.1", Loader::Fabric).await;
}
#[tokio::test]
#[ignore]
async fn quilt_1_20_1() {
run("1.20.1", Loader::Quilt).await;
}
#[tokio::test]
#[ignore]
async fn forge_1_20_1() {
run("1.20.1", Loader::Forge).await;
}
#[tokio::test]
#[ignore]
async fn neoforge_1_21_1() {
run("1.21.1", Loader::NeoForge).await;
}