Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
1345efc
Pokemon Navigation: one movement mechanics table per game
dayfine Nov 12, 2026
d1359c7
Pokemon Navigation: MoveMechanics tests from a table of cases
dayfine Nov 12, 2026
dbe09a7
Pokemon Navigation: connected maps, one world type for BDSP and FRLG
dayfine Nov 12, 2026
b64cd70
Pokemon Navigation: connected maps tests take an expectation struct; …
dayfine Nov 12, 2026
a0991bc
Pokemon Navigation: ConnectedMaps::size()
dayfine Nov 12, 2026
8958cda
Command-line test runner: filter tests by name substring (#1895)
pa-devbot Nov 12, 2026
213e996
Home simplify exit menu (#1873)
Dalton-V Nov 12, 2026
5220644
Home - StorageView (#1900)
Dalton-V Nov 12, 2026
d914382
Home - Box number reader (#1901)
Dalton-V Nov 12, 2026
a17a983
Merge origin/nav/grid-story-steps into nav/move-mechanics
dayfine Nov 12, 2026
e5e09c2
Merge origin/nav/grid-story-steps into nav/connected-maps
dayfine Nov 12, 2026
182ec55
AutoStory: share screen_observation(), describe(ScreenEvents), same_s…
dayfine Nov 12, 2026
a8d5467
AutoStory: forward-declare Pokemon::ScreenEvents in Pokemon_StoryBack…
dayfine Nov 12, 2026
e0c9142
AutoStory: move screen_observation() into Pokemon_ScreenObservation.h
dayfine Nov 12, 2026
f8a22bc
Merge remote-tracking branch 'origin/autostory/engine' into nav/grid-nav
dayfine Nov 12, 2026
e8d9664
Merge remote-tracking branch 'origin/nav/grid-nav' into nav/grid-scre…
dayfine Nov 12, 2026
b59ef84
Merge remote-tracking branch 'origin/nav/grid-screen-state' into nav/…
dayfine Nov 12, 2026
8af084a
AutoStory: name the codec test's temporaries (GCC dangling-pointer)
dayfine Nov 11, 2026
2217fda
Merge branch 'nav/grid-screen-state' into nav/grid-story-steps
dayfine Nov 12, 2026
da24bcd
Merge branch 'autostory/engine' into nav/grid-nav
dayfine Nov 12, 2026
a4d67ed
Merge branch 'nav/grid-nav' into nav/grid-screen-state
dayfine Nov 12, 2026
dfe064a
Merge branch 'nav/grid-story-steps' into nav/move-mechanics
dayfine Nov 12, 2026
78abee2
Pokemon Navigation: step taps per gait; default member values; failur…
dayfine Nov 12, 2026
d0c817b
Pokemon Navigation: order TilePos (#408 review)
dayfine Nov 12, 2026
41905b9
Merge branch 'nav/shared' into nav/story-engine
dayfine Nov 12, 2026
6082102
Merge branch 'nav/story-engine' into nav/screen-state
dayfine Nov 12, 2026
15c68cf
Merge branch 'nav/grid-screen-state' into nav/grid-story-steps
dayfine Nov 12, 2026
253928c
Merge branch 'nav/screen-state' into autostory/engine
dayfine Nov 12, 2026
f90c571
Merge branch 'autostory/engine' into nav/grid-nav
dayfine Nov 12, 2026
27734cf
Merge branch 'nav/grid-nav' into nav/grid-screen-state
dayfine Nov 12, 2026
91ea114
Merge branch 'nav/grid-story-steps' into nav/connected-maps
dayfine Nov 12, 2026
7f63e8b
Merge branch 'nav/grid-story-steps' into nav/move-mechanics
dayfine Nov 12, 2026
371bd8d
Pokemon Navigation: ConnectedMaps refuses temporaries, checks map ind…
dayfine Nov 12, 2026
213ceb7
Pokemon Navigation: stale-place cases carry their expectation (code h…
dayfine Nov 12, 2026
208f732
Pokemon Navigation: golden files for the overworld simulations
dayfine Nov 12, 2026
db23c63
Pokemon Navigation: sim golden tests as input and expectation cases
dayfine Nov 12, 2026
ab559c9
Pokemon Navigation: shared fault classes and per-class fault counters…
dayfine Nov 12, 2026
0ac724b
Merge #402 nav/move-mechanics into nav/grid-story-steps
dayfine Nov 12, 2026
29841ed
Merge origin/nav/grid-story-steps into nav/connected-maps
dayfine Nov 12, 2026
8be521c
Merge #408 nav/connected-maps into nav/grid-story-steps
dayfine Nov 12, 2026
956e676
Merge upstream/main into main
dayfine Nov 12, 2026
5a0b9d4
Merge origin/main into autostory/r3-shared-stats
dayfine Nov 12, 2026
7784c03
Merge origin/autostory/r3-shared-stats into nav/shared
dayfine Nov 12, 2026
d898f8f
Merge origin/nav/shared into nav/story-engine
dayfine Nov 12, 2026
4fd9aca
Merge origin/nav/story-engine into nav/screen-state
dayfine Nov 12, 2026
81efa4b
Merge origin/nav/screen-state into autostory/engine
dayfine Nov 12, 2026
a3f3bc1
Merge origin/autostory/engine into nav/grid-nav
dayfine Nov 12, 2026
a1b9ccc
Merge origin/nav/grid-nav into nav/grid-screen-state
dayfine Nov 12, 2026
b6995fb
Merge origin/nav/grid-screen-state into nav/grid-story-steps
dayfine Nov 12, 2026
473dcb6
Merge origin/nav/grid-story-steps into nav/sim-goldens
dayfine Nov 12, 2026
ef68008
Merge origin/nav/sim-goldens into nav/sim-faults
dayfine Nov 12, 2026
625bc00
runtime-map-tests: link Pokemon_Direction.cpp (MapData uses direction…
dayfine Nov 12, 2026
a1d548c
Merge origin/nav/grid-nav into nav/grid-screen-state (runtime-map-tes…
dayfine Nov 12, 2026
54100ca
Merge origin/nav/grid-screen-state into nav/grid-story-steps (runtime…
dayfine Nov 12, 2026
90ad763
Merge origin/nav/grid-story-steps into nav/sim-goldens (runtime-map-t…
dayfine Nov 12, 2026
e3bea0d
Merge origin/nav/sim-goldens into nav/sim-faults (runtime-map-tests l…
dayfine Nov 12, 2026
f10f18f
StoryRun tests: one case struct per UnitTest (code-health test-case r…
dayfine Nov 12, 2026
f1e4502
Merge branch 'nav/grid-story-steps' into nav/sim-goldens
dayfine Nov 12, 2026
6abccc2
Merge branch 'nav/sim-goldens' into nav/sim-faults
dayfine Nov 12, 2026
ea9b142
Tests: nest Input and Expectation inside each native test case struct
dayfine Nov 12, 2026
e0fd679
Merge branch 'nav/grid-nav' into nav/grid-screen-state
dayfine Nov 12, 2026
3be04b2
Tests: nest Input and Expectation inside each native test case struct
dayfine Nov 12, 2026
9a43acd
Merge branch 'nav/grid-screen-state' into nav/grid-story-steps
dayfine Nov 12, 2026
3c4d867
Tests: nest Input and Expectation inside each native test case struct
dayfine Nov 12, 2026
21b5c2e
Merge branch 'nav/grid-story-steps' into nav/sim-goldens
dayfine Nov 12, 2026
b3990fd
Tests: nest Input and Expectation inside each native test case struct
dayfine Nov 12, 2026
6fd20a8
Merge branch 'nav/sim-goldens' into nav/sim-faults
dayfine Nov 12, 2026
373d5bc
Tests: nest Input and Expectation inside each native test case struct
dayfine Nov 12, 2026
b681c75
StoryRun tests: use ReloadCase::Expectation in the reload test
dayfine Nov 12, 2026
2fba611
Merge branch 'nav/grid-story-steps' into nav/sim-goldens
dayfine Nov 12, 2026
6d55195
Merge branch 'nav/sim-goldens' into nav/sim-faults
dayfine Nov 12, 2026
91d6235
Review fixes: comment content, designated initializers, include place…
dayfine Nov 12, 2026
3361d0b
Merge nav/grid-nav into nav/grid-screen-state
dayfine Nov 12, 2026
2c1815b
Review fixes: comment content, optional instead of a max() sentinel, …
dayfine Nov 12, 2026
f89bc00
TestExpect.h: namespace-close comments
dayfine Nov 12, 2026
cea7989
Merge nav/grid-screen-state into nav/grid-story-steps
dayfine Nov 12, 2026
8eb6f34
StoryActions: tests for a handler that throws and the HOME menu after…
dayfine Nov 12, 2026
27f8186
Review fixes: a throwing interrupt handler fails the step, HOME after…
dayfine Nov 12, 2026
b55d780
Merge nav/grid-story-steps into nav/sim-goldens
dayfine Nov 12, 2026
047fd8a
Review fixes: first_golden_difference returns an optional, with_crlf …
dayfine Nov 12, 2026
5939c68
Merge nav/sim-goldens into nav/sim-faults
dayfine Nov 12, 2026
801c8bf
Review fixes: fault_classes() checked against the enum, plain separat…
dayfine Nov 12, 2026
c2101fe
runtime-map tests: README passes the pinned publisher revision
dayfine Nov 12, 2026
ae1941b
Merge nav/grid-nav into nav/grid-screen-state
dayfine Nov 12, 2026
8e67a91
Merge nav/grid-screen-state into nav/grid-story-steps
dayfine Nov 12, 2026
9d73176
Merge nav/grid-story-steps into nav/sim-goldens
dayfine Nov 12, 2026
c55e280
Merge nav/sim-goldens into nav/sim-faults
dayfine Nov 12, 2026
cb5d054
Navigation: gates, switches and one-way warps; gated planner; gate st…
dayfine Nov 12, 2026
ac601a8
Gates: split MapGates and GatedTypes headers, document, bundle planne…
dayfine Nov 12, 2026
b08ee1a
Merge nav/gates into frlg/gates
dayfine Nov 12, 2026
d11b360
Merge nav/gates: keep the FRLG stack's PokemonFRLG_Navigation and EggRng
dayfine Nov 12, 2026
5f81d2a
FRLG: gate-aware step model, OPEN_GATE/PRESS_SWITCH route steps in th…
dayfine Nov 13, 2026
d528016
FRLG story: gate state and run flags carried through steps; walks pla…
dayfine Nov 13, 2026
521cfcf
FRLG gates: code-health splits (walk hold helpers, gates in SimState,…
dayfine Nov 13, 2026
bc6a558
FRLG gates: row sims, replay and gated plans honor gates
dayfine Nov 13, 2026
5178e3f
FRLG gates: row sim reads the sim's maps for wall checks; has_gates -…
dayfine Nov 13, 2026
b887582
FRLG gates: sim keeps gate maps and Card Key in SimState; one walked_…
dayfine Nov 13, 2026
85d2ec2
FRLG maps: pin PokemonSimulation 4b886bb (Silph card-key doors, Mansi…
dayfine Nov 13, 2026
fb8795f
FRLG gates: real maps in the gate tests, Mansion 13.01-13.04 planned …
dayfine Nov 13, 2026
13f7f7b
FRLG gates: code-health fixes (walk state accessor, string_view scene…
dayfine Nov 13, 2026
e22c2fd
FRLG gates: register the gate-map tests with the FRLG suites (file_li…
dayfine Nov 13, 2026
bdf5fed
FRLG gates: replay a recorded route through a Silph card-key door and…
dayfine Nov 13, 2026
569471c
FRLG gates: wrap the replay scenario in a JsonValue
dayfine Nov 13, 2026
4d3c3ea
FRLG gates: a route run without maps keeps none through its gates (th…
dayfine Nov 13, 2026
b4d6bff
FRLG gates: split the replay test's fixture builders (code health)
dayfine Nov 13, 2026
3134bd9
Merge frlg/stage14a-blaine (12.02 split) into frlg/gates
dayfine Nov 13, 2026
1129a13
Merge frlg/stage14a-blaine (14.02 split) into frlg/gates
dayfine Nov 13, 2026
5b53476
Merge frlg/stage14a-blaine (14.04 split) into frlg/gates
dayfine Nov 13, 2026
1666779
FRLG AutoStory: the chain test expects 66 checkpoints (the split's me…
dayfine Nov 13, 2026
7496f15
Merge remote-tracking branch 'origin/frlg/stage14a-blaine' into HEAD
dayfine Nov 13, 2026
520dd51
Merge frlg/stage14a-blaine into frlg/gates
dayfine Nov 13, 2026
fbfd76a
Merge origin/frlg/stage14a-blaine into frlg/gates
dayfine Nov 13, 2026
0ad0952
FRLG maps: pin PokemonSimulation 1cacf81 (Silph card keys, Mansion sw…
dayfine Nov 13, 2026
54d5210
FRLG gates: Victory Road floor-switch barriers on the real maps
dayfine Nov 13, 2026
4de8e2e
FRLG gates: Victory Road test uses string_view
dayfine Nov 13, 2026
56be015
Merge frlg/stage14a-blaine into frlg/gates: upstream #1881 free party…
dayfine Nov 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cpp-ci-serial-programs-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:

- name: Prepare approved FRLG map resources
id: map-resources
uses: dayfine/PokemonSimulation/integrations/arduino-source/verify-map-packs@d3eea1b5c04180f8b60eb98b0d65f70aca6b1abb
uses: dayfine/PokemonSimulation/integrations/arduino-source/verify-map-packs@1cacf81b2377ec1413317d905ad5415f6fe8dad5
with:
layout: resources
operation: prepare
Expand Down
16 changes: 15 additions & 1 deletion SerialPrograms/Source/CommonFramework/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@



int run_program(int argc, char *argv[]){

Check failure on line 87 in SerialPrograms/Source/CommonFramework/Main.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health

run_program( int argc , char * argv [ ]): function_lines=211, limit=50, allowed 197
// qputenv("QT_RHI_BACKEND", "opengl");

#if defined(__APPLE__)
Expand Down Expand Up @@ -220,20 +220,34 @@
GlobalThreadPools::qt_event_threadpool();

bool augment_test_color_distortions = false;
std::string test_substring;
bool test_substring_missing_value = false;
for (size_t i = 0; i < argc; i++){
constexpr const char* force_run_tests = "--command-line-test-mode";
constexpr const char* distort_test_images = "--augment-color-distortions";
constexpr const char* filter_tests_substring = "--test-substring";

Check failure on line 228 in SerialPrograms/Source/CommonFramework/Main.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health

style: no char* / char[] in new code; use std::string, or std::string_view (inline constexpr std::string_view for constants) (fork AGENTS.md "Strings")

if (strcmp(argv[i], force_run_tests) == 0){
GlobalSettings::instance().COMMAND_LINE_TEST_MODE = true;
}
if (strcmp(argv[i], distort_test_images) == 0){
augment_test_color_distortions = true;
}
if (strcmp(argv[i], filter_tests_substring) == 0){
if (i + 1 < argc){
test_substring = argv[++i];
}else{
test_substring_missing_value = true;
}
}
}
if (test_substring_missing_value){
global_logger_command_line().log("--test-substring requires a value", COLOR_RED);
return 1;
}

if (GlobalSettings::instance().COMMAND_LINE_TEST_MODE){
return run_command_line_tests(augment_test_color_distortions);
return run_command_line_tests(augment_test_color_distortions, test_substring);
}

// Check whether the hardware is powerful enough to run this program.
Expand Down
41 changes: 38 additions & 3 deletions SerialPrograms/Source/CommonTools/ScreenMachine/ScreenMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,43 @@
} // namespace


std::string_view screen_event_name(ScreenEvent event){
switch (event){
case ScreenEvent::FADE_BLACK: return "fade_black";
case ScreenEvent::FADE_WHITE: return "fade_white";
case ScreenEvent::TEXT_BOX: return "text_box";
case ScreenEvent::BATTLE: return "battle";
case ScreenEvent::CAN_MOVE: return "can_move";
case ScreenEvent::STILL: return "still";
case ScreenEvent::CHOICE_BOX: return "choice_box";
case ScreenEvent::INTERACT_PROMPT: return "interact_prompt";
}
return "unknown";
}

std::string describe(const ScreenEvents& events, std::string_view separator){
constexpr ScreenEvent ALL[] = {
ScreenEvent::FADE_BLACK, ScreenEvent::FADE_WHITE, ScreenEvent::TEXT_BOX,
ScreenEvent::BATTLE, ScreenEvent::CAN_MOVE, ScreenEvent::STILL,
ScreenEvent::CHOICE_BOX, ScreenEvent::INTERACT_PROMPT,
};
std::string text;
for (ScreenEvent event : ALL){
if (events.has(event)){
text += text.empty() ? "" : separator;
text += screen_event_name(event);
}
}
return text.empty() ? std::string("nothing") : text;
}

bool same_screen(const VideoSnapshot& a, const VideoSnapshot& b){
if (!a || !b || a->width() != b->width() || a->height() != b->height()){
return false;
}
return ImageMatch::pixel_RMSD(a, b) < 2.0;
}

const ScreenState* match_screen_state(const std::vector<ScreenState>& states, const ScreenObservation& observation){
for (const ScreenState& state : states){
if (state.matches_observation && state.matches_observation(observation)){
Expand Down Expand Up @@ -99,10 +136,8 @@
return std::nullopt;
}

std::optional<std::string> ScreenMachineChecks::problem(const ScreenState& state, VideoSnapshot frame, WallClock when){

Check warning on line 139 in SerialPrograms/Source/CommonTools/ScreenMachine/ScreenMachine.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::ScreenMachineChecks::problem( const ScreenState & state , VideoSnapshot frame , WallClock when): function_lines=27 (advisory above 25, limit 50)
const bool same_size = m_last_frame && frame &&
m_last_frame->width() == frame->width() && m_last_frame->height() == frame->height();
if (same_size && ImageMatch::pixel_RMSD(m_last_frame, frame) < 2.0){
if (same_screen(m_last_frame, frame)){
std::optional<std::string> stalled = unchanged_problem(state, when);
if (stalled){
return stalled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <map>
#include <optional>
#include <string>
#include <string_view>
#include "Common/Cpp/Time.h"
#include "CommonFramework/VideoPipeline/VideoFeed.h"

Expand Down Expand Up @@ -77,6 +78,17 @@ struct ScreenObservation{
std::optional<VideoSnapshot> frame = std::nullopt;
};

// "fade_black", "fade_white", "text_box", "battle", "can_move", "still",
// "choice_box", "interact_prompt".
std::string_view screen_event_name(ScreenEvent event);

// The events in `events` joined by `separator`, or "nothing" when empty.
std::string describe(const ScreenEvents& events, std::string_view separator = ", ");

// Whether `a` and `b` both have a frame of the same size within the
// still-screen RMSD threshold (2.0).
bool same_screen(const VideoSnapshot& a, const VideoSnapshot& b);



} // namespace PokemonAutomation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,17 @@
#include "PokemonBDSP/Inference/PokemonBDSP_DialogDetector.h"
#include "PokemonBDSP/Inference/PokemonBDSP_MenuDetector.h"

#include "Pokemon/Navigation/Pokemon_ConnectedMaps_Tests.h"
#include "Pokemon/Navigation/Pokemon_Gates_Tests.h"
#include "Pokemon/Navigation/Pokemon_LegPlanner_Tests.h"
#include "Pokemon/Navigation/Pokemon_LegWalker_Tests.h"
#include "Pokemon/Navigation/Pokemon_MapData_Tests.h"
#include "Pokemon/Navigation/Pokemon_MoveMechanics_Tests.h"
#include "Pokemon/Navigation/Pokemon_RouteLog_Tests.h"
#include "Pokemon/Navigation/Pokemon_RuntimeMap_Tests.h"
#include "Pokemon/Navigation/Pokemon_WallRecovery_Tests.h"
#include "Pokemon/Navigation/Simulation/Pokemon_SimFaults_Tests.h"
#include "Pokemon/Navigation/Simulation/Pokemon_SimGolden_Tests.h"
#include "VideoGames/PokemonHome/PokemonHome_Tests.h"
#include "VideoGames/PokemonSwSh/PokemonSwSh_Tests.h"
#include "VideoGames/PokemonLA/PokemonLA_Tests.h"
Expand All @@ -59,7 +64,7 @@



UnitTestDatabase make_UNIT_TESTS_ALL(){

Check warning on line 67 in SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::ComputerPrograms::make_UNIT_TESTS_ALL(): function_lines=48 (advisory above 25, limit 50)
UnitTestDatabase ret;

add_tests_QtEventThreadPool(ret, GlobalThreadPools::computation_normal());
Expand All @@ -83,8 +88,13 @@
Pokemon::add_tests_LegWalker(ret);
Pokemon::add_tests_WallRecovery(ret);
Pokemon::add_tests_MapData(ret);
Pokemon::add_tests_ConnectedMaps(ret);
Pokemon::add_tests_Gates(ret);
Pokemon::add_tests_MoveMechanics(ret);
Pokemon::add_tests_RuntimeMap(ret);
Pokemon::add_tests_RouteLog(ret);
Pokemon::add_tests_SimFaults(ret);
Pokemon::add_tests_SimGolden(ret);
Pokemon::add_tests_AutoStory(ret);
NintendoSwitch::add_tests_CheckOnlineDetector(ret);
NintendoSwitch::add_tests_FailedToConnectDetector(ret);
Expand Down Expand Up @@ -123,6 +133,25 @@
}


namespace{

// For each test in `UNIT_TESTS_ALL()` whose name contains `filter`, in name order, call
// `add_test(test)`. An empty `filter` matches all the tests. Return the number of tests
// visited.
template <class AddTest>
size_t add_tests_matching(const std::string& filter, AddTest&& add_test){
size_t count = 0;
for (const auto& test : UNIT_TESTS_ALL()){
if (filter.empty() || test.first.contains(filter)){
count++;
add_test(test.second);
}
}
return count;
}

}

Check failure on line 153 in SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health

namespace-close: close this namespace with // namespace



UnitTestRunner_Descriptor::UnitTestRunner_Descriptor()
Expand Down Expand Up @@ -227,7 +256,7 @@
RUN_MODE.add_listener(*this);
SUBSTRING_TEST.add_listener(*this);
}
void UnitTestRunner::on_config_value_changed(void* object){

Check warning on line 259 in SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::ComputerPrograms::UnitTestRunner::on_config_value_changed( * object): function_lines=38 (advisory above 25, limit 50)
if (object == &RUN_MODE){
SINGLE_TEST_LABEL.set_visibility(ConfigOptionState::HIDDEN);
SINGLE_TEST.set_visibility(ConfigOptionState::HIDDEN);
Expand All @@ -253,15 +282,12 @@
if (object == &SUBSTRING_TEST){
std::string name = SUBSTRING_TEST;
TESTS_TO_RUN.set("");
size_t count = 0;
for (const auto& test : UNIT_TESTS_ALL()){
if (test.first.contains(name)){
count++;
if (count <= 1000){
TESTS_TO_RUN.append(test.first + "\n");
}
size_t num_shown = 0;
size_t count = add_tests_matching(name, [&](std::shared_ptr<const UnitTest> test){
if (++num_shown <= 1000){
TESTS_TO_RUN.append(test->name() + "\n");

Check warning on line 288 in SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

style: build strings with std::format, not + on a literal / std::to_string / std::string (fork AGENTS.md "Strings")
}
}
});
if (count > 1000){
TESTS_TO_RUN.append("<" + tostr_u_commas(count - 1000) + " more...>\n");
}
Expand Down Expand Up @@ -292,6 +318,12 @@

const UnitTestDatabase& all_tests = UNIT_TESTS_ALL();

auto add_matching = [&](const std::string& filter){
add_tests_matching(filter, [&](std::shared_ptr<const UnitTest> test){
runner.add_test(test);
});
};

switch ((RunMode)RUN_MODE){
case RunMode::RUN_ONE:{
auto iter = all_tests.find(SINGLE_TEST.slug());
Expand All @@ -305,22 +337,13 @@
runner.add_test(iter->second);
break;
}
case RunMode::RUN_SUBSTRING_MATCH:{
std::string name = SUBSTRING_TEST;
for (const auto& test : all_tests){
if (test.first.contains(name)){
runner.add_test(test.second);
}
}
case RunMode::RUN_SUBSTRING_MATCH:
add_matching(SUBSTRING_TEST);
break;
}
case RunMode::RUN_ALL:{
for (const auto& test : all_tests){
runner.add_test(test.second);
}
case RunMode::RUN_ALL:
add_matching("");
break;
}
}

runner.run();
}
Expand Down Expand Up @@ -381,7 +404,7 @@



bool CommandLineUnitTestRunner::run(bool augment_color_distortions){
bool CommandLineUnitTestRunner::run(bool augment_color_distortions, const std::string& test_substring){

Check warning on line 407 in SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::ComputerPrograms::CommandLineUnitTestRunner::run( bool augment_color_distortions , const std :: string & test_substring): function_lines=46 (advisory above 25, limit 50)
if (augment_color_distortions){
// Load the distortion data before any test runs. Each `ImageUnitTest` checks the global
// manager when it runs, and only runs with distortions if it is loaded.
Expand All @@ -407,8 +430,15 @@
GlobalThreadPools::unlimited_normal()
);
runner.add_listener(*this);
for (const auto& test : UNIT_TESTS_ALL()){
runner.add_test(test.second);
size_t num_matching = add_tests_matching(test_substring, [&](std::shared_ptr<const UnitTest> test){
runner.add_test(test);
});
if (!test_substring.empty()){
if (num_matching == 0){
m_logger.log("No test name contains \"" + test_substring + "\". No tests will be run.", COLOR_ORANGE);

Check warning on line 438 in SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

style: build strings with std::format, not + on a literal / std::to_string / std::string (fork AGENTS.md "Strings")
}else{
m_logger.log("Running the " + tostr_u_commas(num_matching) + " tests whose name contains \"" + test_substring + "\"");

Check warning on line 440 in SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

style: build strings with std::format, not + on a literal / std::to_string / std::string (fork AGENTS.md "Strings")
}
}
runner.run();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,15 @@ class CommandLineUnitTestRunner : public PokemonAutomation::UnitTestRunner::List
, m_failed_tests(0)
{}

// Run all the unit tests. Return true if any test failed.
// Run the unit tests. Return true if any test failed.
// If `augment_color_distortions` is true, also run each image test under different color
// distortion augmentation to widen the test coverage, using the distortion data in the
// CaptureCardCalibration/ folder of the test repo. If that data can't be loaded, log the
// error and return true without running any test.
bool run(bool augment_color_distortions);
// If `test_substring` is not empty, only run the tests whose name contains that substring
// (case sensitive, the same matching as the GUI's "Run All Tests Containing This Substring"
// mode). If nothing matches, no test runs and a warning is logged.
bool run(bool augment_color_distortions, const std::string& test_substring);


private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,24 @@ enum class Failure{
MISSING_RESOURCE,
};

struct AuthoredInput{
std::string name;
std::string json;
std::string game = "frlg";
bool resource = false;
std::string file = "plan";
};
struct AuthoredCase{
struct Input{
std::string name;
std::string json;
std::string game = "frlg";
bool resource = false;
std::string file = "plan";
};

struct AuthoredExpectation{
std::string checkpoint = "00.05";
std::string execution = R"({"menu":"before_pokedex"})";
std::vector<std::string> events = {"first", "second"};
Failure failure = Failure::NONE;
};
struct Expectation{
std::string checkpoint = "00.05";
std::string execution = R"({"menu":"before_pokedex"})";
std::vector<std::string> events = {"first", "second"};
Failure failure = Failure::NONE;
};

struct AuthoredCase{
AuthoredInput input;
AuthoredExpectation expectation;
Input input;
Expectation expectation;
};

const AuthoredCase CASES[] = {
Expand Down
Loading
Loading