Refactor minui and minarch and add tests#64
Merged
Conversation
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
There was a problem hiding this comment.
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.
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Major refactor. Make sure we didn't lose any functionality! 1398 tests!