Commit Graph
269 Commits
Author SHA1 Message Date
objz 6ac9f4e239 added: net::mojang wiremock tests via *_from URL variants
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.
2026-05-27 17:22:32 +02:00
objz 1f1a0ebb3d refactored: test style cleanup + mmc archive extract test
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.
2026-05-27 17:09:09 +02:00
objz 623acd9e2c added: tests for retry envelope, manager rename, mod precedence, time buckets
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.
2026-05-27 16:44:05 +02:00
objz 7a9dfa850d refactored: rework weak unit tests to catch real regressions
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.
2026-05-27 16:43:47 +02:00
objz d2e08d818b added: launch-pipeline integration tests via build_launch_invocation seam
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.
2026-05-26 21:38:17 +02:00
objz cc0dde106a refactored: move public-API filesystem tests to tests/
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).
2026-05-26 21:11:38 +02:00
objz c6fce8592a fixed: let CI network canaries actually red the build when they break 2026-05-26 21:00:06 +02:00
objz 2163fef175 added: INFO-level snapshot + popup_area unit tests; rename narrow_frame test 2026-05-26 21:00:06 +02:00
objz 05bea59ef1 refactored: narrow lib.rs visibility + drop speculative tests/common 2026-05-26 21:00:06 +02:00
objz 63fb96a0d2 added: run network canaries on master push only 2026-05-26 20:59:59 +02:00
objz c15cb9a378 added: ratatui snapshot tests for ErrorPopup (4 scenarios) 2026-05-26 20:59:59 +02:00
objz 961983d1fe removed: 6 useless tests (4 theatre + 2 wrapper redundancy) 2026-05-26 20:59:59 +02:00
objz aeeef26614 added: lib.rs split + tests/ scaffold for integration testing 2026-05-26 20:59:59 +02:00
objz efcef1cab4 Merge pull request #8 from objz/launch-args-rework
fix(launch): Forge 1.17+ on Java 17+ via launch-profile rework
2026-05-26 20:58:56 +02:00
objz f45351841c fixed: quick-play feature flags + missing version_type template
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.
2026-05-25 21:00:56 +02:00
objz d88ab085b5 fixed: forge/neoforge libraries from instance .minecraft/libraries not on classpath
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.
2026-05-25 20:58:05 +02:00
objz 363ada8211 refactored: review findings - style and abstraction cleanup
- 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.
2026-05-25 19:05:48 +02:00
objz 412e6ff91a fixed: review findings - robustness, dead code, missing tests
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.
2026-05-25 18:24:06 +02:00
objz 19887643bc fixed: critical review findings - extra_args double emission and library dedup
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.
2026-05-25 17:33:52 +02:00
objz a7b378b17d added: Fabric/Quilt raw-bytes profile storage + migration fix
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.
2026-05-25 16:56:13 +02:00
objz 8d2b5b9832 added: legacy Forge install_profile.json native pass-through
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.
2026-05-25 16:22:41 +02:00
objz 0d00678a7c added: modern Forge and NeoForge native pass-through (user-facing fix)
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.
2026-05-25 16:08:47 +02:00
objz 63014726e9 added: inheritsFrom resolution with merge_into and chain walker
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.
2026-05-25 15:23:09 +02:00
objz 2029005c78 added: vanilla launch flow uses LaunchProfile with render + raw-byte storage
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.
2026-05-25 14:51:34 +02:00
objz 22e4481a2b added: launch_profile foundation primitives (rules, templates, model)
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.
2026-05-25 14:02:18 +02:00
objz 50e31f38bb fix(config) default config now uses the rmcl name instead the old mcl 2026-05-20 16:00:22 +02:00
objz 2cc0173873 Merge pull request #7 from objz/hardcoded-min/max-mem
fix(tui): memory_min/max now hardcoded values
2026-05-19 19:58:14 +02:00
objz 681f7974d6 ci: run check, clippy, test, and build on linux, macos, and windows
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.
2026-05-19 19:56:13 +02:00
objz a54e53038a fix(tui): memory_min/max now uses the real values from the config.toml instead of hardcoded values. same for java_path 2026-05-19 19:33:54 +02:00
objz 17bb771020 doc: fixed naming 2026-05-13 21:57:38 +02:00
objz c3ea0bc592 ci(winget): set GH_REPO so gh release upload finds the repo without a checkout 2026-05-13 21:26:54 +02:00
objz f594d1ae49 docs: rename project references in README, changelog config, and issue templates v0.3.0 2026-05-13 21:06:34 +02:00
objz 2bc0728a48 ci: update release workflows for rmcl rename 2026-05-13 21:06:34 +02:00
objz bf65814b7d chore(chocolatey): rename package to rmcl 2026-05-13 21:06:34 +02:00
objz a407d460f7 chore(aur): rename PKGBUILDs to rmcl/rmcl-bin/rmcl-git with replaces= for upgrade 2026-05-13 21:06:34 +02:00
objz 35ecf2f810 chore(wix): rename MSI product from mcl-launcher to rmcl 2026-05-13 21:06:34 +02:00
objz ae2524f2ce feat!: rename project from mcl/mcl-launcher to rmcl
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.
2026-05-13 21:06:34 +02:00
objz 2b3aa4df32 feat(migrate): add legacy mcl→rmcl path migration module 2026-05-13 21:06:34 +02:00
objz d5cbc11c8a fix(tui): use open::that_detached to prevent freeze when opening directories 2026-05-02 21:42:43 +02:00
objz 2ea20b0a99 fix: renamed details.rs to settings.rs; the name was outdated as the label change to settings 2026-05-02 21:36:22 +02:00
objz d9004f3761 fixed readme 2026-05-02 18:52:30 +02:00
objz 1dcd625ea2 fix: chocolatey issue and readme install 2026-05-02 18:50:36 +02:00
objz f226358b1c ci: include winget manifest in releases 2026-04-27 14:52:01 +02:00
objz de6af2de18 ci: fixed aur checksums and chocolatey workflow v0.2.4 2026-04-27 13:17:41 +02:00
objz ff7bb55faa ci: fixed duplicate runs 2026-04-27 12:54:27 +02:00
objz 495a4b3fa1 ci: fixed chocolatey workflow and hombrew 2026-04-27 12:51:29 +02:00
objz 3d8b3deb74 ci: fixed aur checksums and workflows 2026-04-27 12:32:31 +02:00
objz ec378b0b59 fix: trigger release workflow via dispatch after creating tag
API-created tags don't emit push events, so the release workflow
never started. Now tag-release explicitly dispatches the release
workflow after creating the tag.
2026-04-26 22:10:44 +02:00
objz a0a03a8f8f fix: tag-release re-tags when existing tag points to wrong commit
Previously if a tag already existed (e.g. from a failed release),
tag-release would skip because the version matched the latest tag.
Now it detects stale tags pointing to the wrong SHA and re-creates them.
2026-04-26 22:09:01 +02:00
objz 2acbec94c9 ci: fixexed tag release failing 2026-04-26 22:06:43 +02:00