Closes the seven remaining tractable coverage gaps the final review
flagged. All tests-only or tiny *_from variants matching the existing
pattern. 18 new tests.
- src/instance/launch/patches.rs: seven inline tests for the lwjgl3ify
patch helpers that were entirely untested before. strip_replaced_libs
has happy + no-op cases. parse_add_opens covers the basic Add-Opens
extraction, the MANIFEST.MF continuation-line case (the tricky one:
jar manifests wrap lines with a trailing space + leading-space marker
that gets stripped on join), missing manifest, and missing file.
add_lwjgl3 verifies that only jars that actually exist in lib_dir
end up on the classpath.
- src/net/forge.rs: three inline tests for has_legacy_install_profile.
Builds synthetic forge installer zips in a tempdir with and without
the versionInfo key in install_profile.json; covers the missing-jar
branch with a path that doesn't exist.
- src/net/modrinth.rs: five-case rstest for url_encode covering the
unreserved set, space, RFC 3986 reserved characters, multi-byte UTF-8
(the encoder operates per-byte so emoji exercises the multi-byte
path), and empty input.
- src/net/fabric.rs / src/net/quilt.rs: added fetch_*_profile_from and
fetch_*_profile_with_raw_from variants mirroring the existing pattern.
Existing fetch_*_profile and *_with_raw delegate to them with the
upstream constants.
- tests/net_loaders.rs: two new wiremock tests (fabric_fetch_profile
parses libraries, quilt_fetch_profile parses libraries) using the
new _from variants.
- src/tui/widgets/popups/import_modpack/render.rs: extra snapshot for
the Confirm step when loader_version is None (vanilla pack or old
mmc pack). The previous Confirm snapshot covered Some(_) only.
Production touches stay minimal: the four new pub fn delegators in
fabric.rs and quilt.rs, all behaviour-preserving.
Same pattern as fetch_version_manifest_from from the earlier batch:
each fetcher gets a sibling that takes the URL as a parameter; the
existing function delegates to it with the upstream constant.
Production callers are unchanged.
- src/net/forge.rs: fetch_forge_versions_from(client, promotions_url,
game_version) and fetch_forge_game_versions_from(client,
promotions_url).
- src/net/fabric.rs: fetch_fabric_game_versions_from(client, base) and
fetch_fabric_versions_from(client, base, game_version). The fabric
API is hierarchical so the helpers take the meta base URL and append
the rest internally, matching the existing layout.
- src/net/quilt.rs: same pair as fabric.
- src/net/neoforge.rs: fetch_neoforge_versions_from(client, api_url,
game_version).
- src/net/mojang.rs: download_assets_from(client, meta, meta_dir,
assets_base) so tests can route per-asset CDN downloads through a
wiremock server. download_assets delegates to it with
ASSETS_BASE_URL.
tests/net_loaders.rs adds eight wiremock tests covering each new
fetcher and a happy + error case for neoforge's invalid-game-version
branch. tests/net_mojang.rs gains download_assets_from_writes_index_and_assets
which now exercises the full per-asset download path against synthetic
hashes.
Production touches are minimal (one new pub fn delegating to the
existing one for each fetcher). Behaviour of existing callers is
unchanged.
Closes the "zero production touches" subset of the deferred coverage
items the audit had flagged.
- src/tui/widgets/popups/new_instance/render.rs: three new snapshots
for the Version, LoaderVersion, and Confirm steps. Each pre-populates
WIZARD_STATE so ensure_versions_loaded and ensure_loader_versions_loaded
short-circuit on LoadState::Loaded and never spawn a network task. The
TEST_SERIAL mutex established in the earlier batch serialises against
the existing Name/Loader snapshots.
- src/tui/widgets/popups/import_modpack/render.rs: two new snapshots
for the Version step (synthetic VersionInfo entries) and the Confirm
step (synthetic ImportSummary). Same serialisation pattern.
- tests/net_mojang.rs: three new wiremock tests.
download_libraries_writes_artifact_to_meta_dir constructs a synthetic
VersionMeta whose single library points at the wiremock server, then
asserts the bytes land at meta_dir/libraries/<artifact.path>.
download_libraries_skips_when_destination_exists verifies the cache
hit path via wiremock's expect(0).
download_assets_writes_index_when_objects_is_empty exercises the
index fetch+write code path with an empty objects map so the per-asset
download loop never fires.
Zero production touches. download_libraries already takes a
VersionMeta whose libraries carry their own URLs; download_assets'
index fetch reads from meta.asset_index.url (also configurable
per-call), so the empty-objects path doesn't need ASSETS_BASE_URL
overridable. Full per-asset coverage lands in a separate commit.
Final-review pass flagged three items. All addressed:
- src/instance/loader/mod.rs: rename and rewrite the two profile-shape
tests so the test name matches what the body does.
legacy_forge_version_info_round_trips_through_save_profile_json was
misleading; the body never called save_installer_profile, it only
wrote bytes to disk and read them back. Renamed to
legacy_forge_version_info_deserialises_as_launch_profile and dropped
the filesystem dance - the test was only ever verifying serde shape
on the literal byte string.
raw_fabric_profile_bytes_parse_as_launch_profile got the same
treatment for consistency: dropped the TempDir + write + read round
trip since the test only checks deserialisation.
- src/tui/error_buffer.rs: removed has_errors_after_push. The test
read global state populated by other tests in the same module, so
it would still pass if push_error were a no-op. The push semantics
are properly covered by peek_all_returns_newest_first and
overflow_drops_oldest, both of which use unique tagged messages to
isolate from cross-test interference.
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.
Phase E added snapshots for the ErrorPopup; this extends the same
pattern to the three other high-value widgets the audit flagged.
- src/tui/widgets/instances.rs: two snapshots covering the instance
list with three synthetic instances (verifies layout, "Never played"
rendering, scrollbar gutter) and the empty list. State is passed in
via the existing State::with_instances constructor; no global state
involved.
- src/tui/widgets/popups/new_instance/render.rs: two snapshots covering
the Name step (default) and Loader step (hardcoded loader list, no
network). WIZARD_STATE is global, so the tests reset it under its
mutex and serialise via a per-module TEST_SERIAL mutex to prevent
cross-test races. The Version and LoaderVersion steps are skipped
here because their render path calls ensure_versions_loaded which
tokio::spawns a network task; covering them would need a fully
pre-populated state and is deferred.
- src/tui/widgets/popups/import_modpack/render.rs: two snapshots
covering the Input step (default) and the Fetching step (just a
spinner + label, no network triggered by render). Same global-state
serialisation pattern as new_instance.
Snapshots live next to each widget under snapshots/ as plain text and
are committed to git.
The existing fetch_version_manifest hard-codes the Mojang URL, so tests
either had to hit the live endpoint (the #[ignore] live-API test) or
not run at all. Adds fetch_version_manifest_from(client, url) that lets
callers pick the URL; fetch_version_manifest stays compatible by
delegating with the upstream constant. fetch_version_meta_with_raw
already takes the URL via VersionEntry, no change needed.
tests/net_mojang.rs adds three wiremock tests:
- fetch_version_manifest_parses_synthetic_response verifies the
VersionManifest deserialiser against a synthetic upstream-shaped
payload (latest + versions list).
- fetch_version_meta_returns_struct_and_raw_bytes verifies both the
parsed VersionMeta and the raw byte capture path used by the install
flow to write upstream JSON byte-for-byte.
- fetch_version_manifest_retries_5xx_and_succeeds confirms the retry
envelope integrates correctly with VersionManifest deserialisation
on top of the retry-only tests in tests/net_retry.rs.
These don't replace the #[ignore = "hits live Mojang API"] canary
which still runs on master push to detect upstream schema drift.
Picks up the style audit's findings without touching production
behaviour (except for two em-dash characters in non-test code that
violated the no-em-dash rule).
- cli/import.rs, instance/import/mmc.rs: replace the two em-dashes
that leaked into source (one in a user-facing format string, one
in a code comment) with hyphen / colon.
- instance/manager.rs: rewrite test_manager to return TempDir instead
of a hand-rolled tempdir path with manual cleanup. Drop the
trailing std::fs::remove_dir_all from every test. Rename test_*
functions to describe the scenario per CONTRIBUTING (delete_missing_
instance_returns_not_found, save_then_load_all_round_trips_config,
load_one_missing_returns_not_found, etc.).
- migrate.rs: replace unique_tmp + atomic counter with
tempfile::tempdir() across all seven tests; ~10 lines of plumbing
gone, automatic cleanup via Drop.
- auth/accounts.rs: drop the dummy_account wrapper that just forwarded
to create_offline_account; inline the real call at the eight use
sites.
- instance/models.rs: rename test_instance_config_roundtrip to
instance_config_roundtrips_through_json.
- instance/content/mods.rs: drop the "what" comments above straight
forward asserts; keep the one "why" comment that explains an
empty-name + present-logo coverage gap. Trim the obvious "helper to
create a jar (zip) file" comment above make_jar.
- tests/smoke.rs: //! to // for the file header; project convention is
// for files (//! is for crate-level rustdoc, which doesn't render
for integration test crates).
Adds one new test:
- instance/import/mmc.rs: extract_mmc_archive_copies_minecraft_subtree
builds an in-memory zip with a Pack/ prefix, a Pack/mmc-pack.json
sibling, and Pack/.minecraft/{options.txt, mods/test-mod.jar},
then asserts only the .minecraft/ subtree lands in the destination
with relative paths preserved. Closes the mmc extract coverage gap
the audit flagged.
Audit identified six high-priority coverage gaps. This commit closes
them with 30 net new passing tests.
- tests/net_retry.rs (new): 5 wiremock-based tests for the retry
envelope in net/mod.rs. Covers get_json + download_file across:
5xx retry-then-succeed, 4xx fail-fast (asserted via wiremock
expect(1) so any retry attempt fails the test), and exhaust at
MAX_RETRIES = 3 (asserted via expect(4)). The exhaust test takes
~3.5s of wall time because the production code sleeps 500 + 1000 +
2000 ms between attempts; this is unavoidable without making the
delays configurable.
- tests/launch_pipeline.rs: 3 new error-path tests against
build_launch_invocation. merged_profile_missing_main_class_fails
surfaces the LaunchError::Parse branch when meta.json deserialises
cleanly but lacks mainClass. legacy_loader_profile_missing_loader_version_errors
and legacy_loader_profile_missing_installer_json_errors exercise the
two Parse branches inside migrate_legacy_loader_profile_if_needed.
- instance/manager.rs: 6 tests for rename (happy path, noop on same
name, empty target rejected, missing source, target collision) and
touch_last_played (sets the field to a stamp within 5 seconds of
now). The InstanceManager rename surface had no coverage before;
mutating the validation order or the std::fs::rename target would
not have failed any existing test.
- instance/content/mods.rs: 4 new precedence-chain tests. The reader
chain is fabric > quilt > forge-toml (which itself tries
neoforge.mods.toml before mods.toml) > mcmod.info. Only the
fabric-over-forge precedence had a test before. Adds quilt > forge,
forge_toml > mcmod_info, neoforge.mods.toml > mods.toml, and a test
that a mods.toml carrying only logoFile (no [[mods]] array) still
resolves the icon.
- tui/widgets/instances.rs: 12 new tests for format_last_played. One
case for the None input (returns "Never played"), then an rstest
covering each bucket boundary in the match (0/59 just-now,
60/3599 minutes, 3600/86399 hours, 86400/2591999 days,
2592000/31535999 months, >=31536000 over-a-year). A mutation that
bumps any boundary by one second, or swaps a unit suffix, fails at
least one case.
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.
Per Phase C of the test overhaul: tests that touch the filesystem and
exercise the public API surface (scan_screenshots, scan_shaders,
scan_worlds, scan_resource_packs, log_files) move from inline mod tests
into tests/. They now consume rmcl as an external crate, mirroring how
real callers would.
AccountStore::store_save_and_reload stays inline because the helper it
needs (constructing AccountStore directly with a tempdir path) requires
reaching into a private field; exposing that just for tests would leak
implementation detail. The other accounts tests are in-memory and stay
inline regardless.
The extract_description_* tests in resource_packs stay inline since
they are pure logic on serde_json::Value (no filesystem).
image is added to dev-dependencies so integration tests can fabricate
1x1 PNG fixtures (already a regular dep of the lib).
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.
install_forge_from_profile now writes the upstream versionInfo as compact
JSON (no key reordering, no field stripping) instead of building a custom
{mainClass, libraries, gameArguments} shape. legacy 1.7.10-era Forge
profiles ride the same LaunchProfile + resolve + render pipeline as
modern Forge. drops the no-longer-needed extract_extra_game_args helper.
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.
new launch_profile::resolve module walks a profile's inheritsFrom chain,
loading parents from meta_dir/versions/<id>/meta.json and merging them
into a single flat LaunchProfile per mojang's documented semantics. pure
merge_into handles field-level merging; async resolve walks the chain
with HashSet-based cycle detection and an 8-level depth cap.
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.
introduce the launch_profile module with the core types and pure functions
needed to parse, evaluate, and substitute against mojang-format version
JSON: Rule/OsCondition/FeatureSet with a single rule evaluator,
TemplateContext + substitute() for ${var} expansion, and the
LaunchProfile schema mirroring mojang's on-disk shape. no consumers yet.
Expands the PR verification workflow into a cross-platform matrix so we
catch platform-specific breakage before merge. Adds concurrency to cancel
superseded PR runs.
Renames Cargo package, binary, internal path identifiers, java shim,
user-agent, log filename, desktop shortcut Exec lines, and CLI program
name. Wires src/migrate.rs into main() so existing users have their
on-disk data (~/.config/mcl/, ~/.local/share/mcl/, ~/.cache/mcl/) moved
to the new locations on first launch.
BREAKING CHANGE: binary is now named rmcl. Old paths are auto-migrated.