Skip to content

Refactor minui and minarch and add tests#64

Merged
nchapman merged 15 commits into
developfrom
feature/moar-tests
Dec 9, 2025
Merged

Refactor minui and minarch and add tests#64
nchapman merged 15 commits into
developfrom
feature/moar-tests

Conversation

@nchapman
Copy link
Copy Markdown
Collaborator

@nchapman nchapman commented Dec 9, 2025

Major refactor. Make sure we didn't lose any functionality! 1398 tests!

  Extract testable business logic into standalone modules:
  - minarch_utils.c (41 tests) - core name extraction, CPU frequency
  - effect_system.c (43 tests) - visual effect state management
  - platform_variant.c (14 tests) - platform detection
  - minarch_config.c (19 tests) - config path generation
  - minarch_options.c (36 tests) - option list management
  - minui_entry.c (25 tests) - Entry type, sorting, IntArray
  - directory_index.c (38 tests) - alias, filtering, duplicate detection
…tion, launcher commands

Extracts testable logic from minarch.c and minui.c into focused modules with 77 new tests:
- minarch_zip: ZIP copy/inflate extraction (13 tests)
- minarch_memory: SRAM/RTC persistence with injectable callbacks (16 tests)
- minarch_state: Save state read/write/auto-resume (16 tests)
- minui_launcher: Shell command construction and quote escaping (32 tests)

Also adds libretro_mocks infrastructure for testing core-dependent code.

Total tests: 784 (up from 707)
…sistence, root directory

- minarch_cpu.c: 42 tests for CPU frequency scaling algorithm
- minarch_input.c: 24 tests for button mapping and input queries
- minui_state.c: 27 tests for path decomposition and resume paths
- minui_root.c: 28 tests for alias parsing and entry deduplication

Total: 905 tests (121 new), exceeding 700-test target by 29%.
minarch:
- Rename ButtonMapping fields for clarity (retro→retro_id, local→local_id,
mod→modifier, default_→default_id)
- Use MinArchButtonMapping typedef from minarch_input.h
- Replace button lookup loops with MinArchInput_findMappingByName()
- Add minarch_input.c to build

minui:
- Remove duplicate functions now in directory_index.c (getIndexChar,
getUniqueName, alias application, hidden entry filtering)
- Add minui_entry.c, minui_launcher.c, directory_index.c to build
- Move minarch_*.c modules from common/ to minarch/
- Move minui_*.c modules from common/ to minui/
- Move collection_parser, directory_index, recent_file to minui/
- Rename and integrate m3u_parser → minui_m3u.c
- Rename and integrate map_parser → minui_map.c (add Map_load())
- Rename str_compare → minui_str_compare.c
- Replace inline M3U/map.txt parsing in minui.c with module calls
- Fix unsigned int types in AutoCPUConfig
Copilot AI review requested due to automatic review settings December 9, 2025 06:11
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the minarch and minui codebases by extracting functionality into separate, testable modules. The refactor adds 1398 tests while maintaining backward compatibility.

Key changes:

  • Extracted minarch modules (input, game, env, CPU, core, context, config, paths, ZIP, memory, state)
  • Created new minui modules (entry, directory, navigation, launcher, state, context, thumbnail, utils)
  • Reorganized header includes and file locations
  • Added comprehensive unit test coverage

Reviewed changes

Copilot reviewed 80 out of 138 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
workspace/all/minarch/minarch_internal.h New internal header defining Core, Game, and Config structures
workspace/all/minarch/minarch_input.h/c Input handling utilities extracted from minarch.c
workspace/all/minarch/minarch_game.h/c Game file loading utilities (ZIP, M3U detection)
workspace/all/minarch/minarch_env.h/c Environment callback handlers for libretro
workspace/all/minarch/minarch_cpu.h/c Auto CPU scaling utilities
workspace/all/minarch/minarch_core.h/c Core AV info processing utilities
workspace/all/minarch/minarch_context.h/c Centralized state management
workspace/all/minarch/minarch_config.h/c Configuration option utilities
workspace/all/minarch/makefile Updated build configuration with new source files
workspace/all/common/map_parser.c Deleted - functionality moved elsewhere
workspace/all/common/defines.h Added BTN_SLEEP/BTN_WAKE fallback definitions
workspace/all/common/api.h/c Changed GFX_blitMessage parameter to const char*
tests/unit/all/common/test_*.c New and updated test files with corrected includes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread workspace/all/minarch/minarch_env.c
Comment thread tests/unit/all/common/test_ui_layout.c
Integrates the thumbnail cache refactor from develop which fixes a
dangling pointer bug by tracking the currently displayed item inside
the cache and auto-invalidating when evicted.

Changes:
- Add displayed_index/displayed_valid fields to MinUIThumbnailCache
- Add MinUIThumbnail_cacheSetDisplayed/ClearDisplayed/IsDisplayedValid/GetDisplayedData
- Auto-invalidate displayed item on eviction
- Rename all Thumb* to MinUIThumbnail_* for naming consistency
- Add 17 new tests for displayed tracking (89 total)
@nchapman nchapman merged commit 383a99b into develop Dec 9, 2025
4 checks passed
@nchapman nchapman deleted the feature/moar-tests branch December 9, 2025 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants