Picks up the remaining test-only suggestions from the style audit. No
production code change.
- launch_profile/templates.rs: introduces a Fixture struct that owns
the four PathBuf inputs (lib/nat/game/assets) and exposes a ctx()
method. Eight tests that each rebuilt the same context inline now
collapse into one rstest with eight cases plus two standalone
tests for the recursive-substitution and Windows-backslash edge
cases. Net code: ~120 lines saved.
- launch_profile/render.rs: same pattern. Fixture::new() owns the
paths plus a FeatureSet; ctx() and rule_ctx() expose what every
test needs. Six tests stop redeclaring four PathBufs + a five-line
RuleContext literal apiece.
- instance/launch/mod.rs: three installer_version_dir_name tests
(Forge / NeoForge / non-installer loaders) become one rstest with
five cases (one per ModLoader variant). A regression that
misorders the match arms would now fail a specific case, not just
the catch-all "non-installer" test.
- instance/content/resource_packs.rs: ten extract_description_*
tests become one rstest with ten cases. Each case still hits a
distinct match arm (string, object{text}, object{no text}, array
variants, null, number, bool); the rstest is cosmetic, not a
consolidation that loses coverage.
Net effect: same coverage, ~250 lines less repetitive test setup,
clearer intent. Test count rises by 2 because rstest expands cases
into separate test functions.
Audit found 9 confirmed-weak unit tests plus several newly-found ones that
asserted things equivalent to themselves, returned vacuous truth, or had
assertions guarded behind conditionals that silently swallowed failure.
Changes by file:
- auth/accounts.rs: create_offline_account_fields now pins the uuid to
offline_uuid("TestPlayer") instead of !is_empty(); mutating the uuid
derivation would fail this now.
- cli/mod.rs: parses_instance_list_subcommand drills into the list
subcommand under instance rather than only verifying the instance
group exists.
- config/theme.rs: border_style_roundtrip is now an rstest covering all
four BorderStyle variants; mutating any non-Double arm is caught.
- instance/desktop.rs: removed desktop_path_returns_some (assertion was
gated behind if let Some so could pass when the function returned
None); build_content_linux* already covers the real behaviour.
- instance/launch/mod.rs: removed five predicate-only tests that
asserted serde defaulting on LaunchProfile rather than invoking the
migration predicate. Added two tests that actually call
migrate_legacy_meta_if_needed (rstest over modern/legacy arg shapes)
and migrate_legacy_loader_profile_if_needed (modern-with-inheritsFrom
early-return). Renamed build_game_args_renders_upstream_arguments,
dropping the misleading "and appends loader args" clause that the
test never covered.
- instance/loader/mod.rs: removed test_vanilla_install_noop (no
assertion at all) and test_vanilla_get_versions (asserted a hardcoded
Ok(vec!["vanilla"]) return). Replaced test_vanilla_factory with an
rstest covering all five ModLoader variants; a misordered match arm
in get_installer is caught.
- migrate.rs: removed cleanup_instance_leftovers_handles_missing_dir
(had no assertions and was redundant with
cleanup_instance_leftovers_removes_shim_and_log4j).
- net/mod.rs: removed detect_java_falls_back_to_java which asserted
!is_empty() against a function whose worst-case fallback is the
literal string "java"; structurally uncatchable.
- tui/error_buffer.rs: peek_all_returns_newest_first and
auto_assigned_ids_are_unique now tag their pushed events with a
unique substring and filter peek_all_errors to just those, so the
assertions actually fire instead of being silently skipped via
if all.len() >= 2 when shared static state interfered.
Total: net zero change in test count (deletions and parameterised
replacements roughly balance), but mutation coverage of the surviving
suite is materially stronger.
Phase D of the test overhaul. Extracts a build_launch_invocation seam
from launch() so the full launch pipeline (profile loading, inheritsFrom
resolution, classpath assembly, template rendering) can be exercised
without spawning a real java process or hitting the auth servers.
The seam takes resolved auth credentials (LaunchAuth) and returns a
LaunchInvocation struct with the final java path, jvm args, classpath,
main class, extra args, game args, and working dir. launch() shrinks to
a thin wrapper that resolves auth from the account store, calls the
seam, and spawns the process.
tests/launch_pipeline.rs adds 14 integration tests covering: vanilla
modern args; vanilla legacy minecraftArguments; Forge with --add-opens;
Forge local-libs preference; Fabric implicit inheritsFrom resolution;
NeoForge inheritsFrom; auth credential substitution into game args;
version_type substitution; platform classpath separator; rule-disallowed
library exclusion; Xms/Xmx from config; default memory fallback; missing
meta.json error; missing loader profile error.
two related bugs surfaced by manual testing on 1.20.6 vanilla and fabric:
1. FeatureSet missing has_quick_plays_support / is_quick_play_singleplayer /
is_quick_play_multiplayer / is_quick_play_realms. mojang's profiles gate
the quick-play arguments behind these features. serde silently dropped
the unknown fields during deserialization, leaving an empty FeatureSet
that matched any context, so the conditional arguments emitted raw
${quickPlay*} placeholders to the JVM that template substitution then
warned about. add the fields explicitly and extend features_match to
reject any required feature the context doesn't set.
2. TemplateContext missing version_type. ${version_type} is an
unconditional template in modern vanilla's arguments.game (renders the
profile's "type" field, e.g. "release"). without it, the substitution
emitted a literal ${version_type} to minecraft and warned. add the
field, plumb the merged profile's type_ value through, default to
"release" when absent.
modern forge's installer places some libraries (notably the bootstrap
library that defines ForgeBootstrap / BootstrapLauncher) into the
instance's .minecraft/libraries/ rather than the shared meta cache. the
unified classpath loop introduced in the rework checked downloads.artifact
first and pushed meta_dir/libraries/<path> without ever consulting the
local installer dir for libraries that had downloads.artifact set.
resolve a single relative path per library (downloads.artifact.path if
present, else maven_coord_to_path(name)), then for has_local_libs check
the local installer dir first regardless of which path source we used.
fixes ClassNotFoundException at launch on forge 1.20.6 and likely
similar versions.
- drop stale phase planning comments from launch_profile module headers.
- simplify merge_libraries to HashSet<&str> (no string clones).
- rewrite coord_key with match_indices (clearer intent).
- read /proc/sys/kernel/osrelease on linux for mojang_os_version
instead of shelling out to uname; return empty elsewhere.
- add comment explaining why is_retryable excludes Parse.
- shorten the launch_profile::... paths in launch/mod.rs with top-level
use statements.
- derive Default on LaunchProfile + nested types so test fixtures use
..Default::default() instead of listing every None field.
- inline account_can_launch at its single call site, delete the helper
and three tests that exercised trivially-correct one-line logic.
- extract get_json_with_raw on HttpClient and save_profile_bytes in
instance::loader; collapses three near-identical fetch_X_profile_with_raw
helpers and three near-identical 'create dir + write bytes' blocks.
several smaller fixes from the code review:
- add os_version to RuleContext + OsCondition for mojang rules that
constrain natives selection by host version (rare, but in the spec).
- factor mojang_os_name/arch/version into a shared launch_profile::system
module instead of duplicating between net/mojang.rs and launch/mod.rs.
- get_json and get_bytes now retry transient failures (5xx, connect,
body decode) via a shared get_with_retry envelope; previously only
download_file had retry logic.
- migrate_legacy_meta_if_needed falls back to the stale cached profile
with a warn log on network failure instead of erroring out (offline
launches now work).
- tightened legacy-loader detection by requiring the unique-to-rmcl
gameArguments field; clearer error when loader_version is absent.
- forge legacy versionInfo write uses compact serialization (no
pretty-print key reorder).
- deleted dead fetch_version_meta and save_profile_json.
- documented quick-play templates omission in templates::lookup.
- added end-to-end test that loads a vanilla profile from disk, loads a
loader profile with inheritsFrom, resolves, renders, and snapshots.
extra_args from the patches module was being passed to build_game_args
(which appended it to game_args) AND emitted again via cmd.args before
game_args - a regression that doubled legacy Forge + lwjgl3ify shim
args. extra_args is now passed only once. also, merge_into now dedups
libraries by group:artifact, preferring the child's entry - without
this, Forge/NeoForge library overrides of vanilla (e.g. log4j) would
silently lose to vanilla because the JVM picks the first classpath
match.
stop re-serializing FabricProfile/QuiltProfile through narrow structs;
new fetch_X_profile_with_raw helpers return both the parsed shape (for
library downloads) and the upstream bytes (written byte-for-byte to the
loader-profiles cache). also fixes a latent issue surfaced by the
change: the legacy-loader migration predicate now skips Fabric and Quilt
explicitly since their upstream shape matches the predicate but they
have no installer JSON to recover from.
stop stripping the installer's version JSON in save_installer_profile -
copy it byte-for-byte so the upstream arguments.jvm (with the
--add-opens flags forge 1.17+ needs on java 17+) reaches launch time.
launch loads the loader profile as LaunchProfile, sets an implicit
inheritsFrom = game_version when absent, resolves through vanilla, then
renders args. classpath assembly unifies into one loop handling both
vanilla-style and loader-style libraries. lazy migration of pre-rework
loader-profiles from the installer's version JSON when still on disk.
fixes the reported Forge 1.17+ on java 17+ IllegalAccessError.
vanilla launches now read upstream mojang JSON via the new LaunchProfile
path, render game/JVM args through launch_profile::render with template
substitution, and store the cached meta.json byte-for-byte instead of
re-serializing through a narrow struct. legacy stripped meta.json files
are re-fetched on first launch. adds HttpClient::get_bytes and
fetch_version_meta_with_raw; collapses the two library-rule evaluators
into one shared launch_profile::rules::evaluate.