Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 29 additions & 0 deletions .github/workflows/runtime-map-reader.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Runtime map reader
on:
pull_request:
workflow_dispatch:
jobs:
native-schema:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v7
- uses: actions/checkout@v7
with:
repository: dayfine/PokemonSimulation
ref: 906956e94fc912ae9adb0e44845da780f3bc7e4c
path: publisher
- uses: actions/setup-python@v6
with:
python-version: '3.12'
- run: python devtools/runtime-map-tests/prepare_parity.py --publisher publisher --publisher-revision 906956e94fc912ae9adb0e44845da780f3bc7e4c --out runtime-map-pairs.json
- run: cmake -S devtools/runtime-map-tests -B build-runtime-maps -DCMAKE_BUILD_TYPE=Debug
- run: cmake --build build-runtime-maps --config Debug -j4
- run: ctest --test-dir build-runtime-maps -C Debug --output-on-failure
- if: runner.os != 'Windows'
run: ./build-runtime-maps/RuntimeMapTests runtime-map-pairs.json
- if: runner.os == 'Windows'
run: ./build-runtime-maps/Debug/RuntimeMapTests.exe runtime-map-pairs.json
2 changes: 2 additions & 0 deletions SerialPrograms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ add_library(SerialProgramsLib STATIC ${CORE_LIBRARY_SOURCES} ${LIBRARY_SOURCES})

# Data files built into the program (see cmake/EmbedTextFiles.cmake).
include(cmake/EmbedTextFiles.cmake)
pa_embed_text_files(SerialProgramsLib Source/Pokemon/Navigation/TestMaps
Pokemon/Navigation/Pokemon_NavigationTestMaps.h PokemonAutomation::Pokemon navigation_test_map_json)


# Create binary target
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
#include "PokemonBDSP/Inference/PokemonBDSP_DialogDetector.h"
#include "PokemonBDSP/Inference/PokemonBDSP_MenuDetector.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_RouteLog_Tests.h"
#include "Pokemon/Navigation/Pokemon_RuntimeMap_Tests.h"
#include "Pokemon/Navigation/Pokemon_WallRecovery_Tests.h"
#include "VideoGames/PokemonHome/PokemonHome_Tests.h"
#include "VideoGames/PokemonSwSh/PokemonSwSh_Tests.h"
#include "VideoGames/PokemonLA/PokemonLA_Tests.h"
Expand All @@ -53,7 +59,7 @@



UnitTestDatabase make_UNIT_TESTS_ALL(){

Check warning on line 62 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=43 (advisory above 25, limit 50)
UnitTestDatabase ret;

add_tests_QtEventThreadPool(ret, GlobalThreadPools::computation_normal());
Expand All @@ -73,6 +79,12 @@
add_tests_LabControl(ret);
OCR::add_tests(ret);
Kernels::add_tests(ret);
Pokemon::add_tests_LegPlanner(ret);
Pokemon::add_tests_LegWalker(ret);
Pokemon::add_tests_WallRecovery(ret);
Pokemon::add_tests_MapData(ret);
Pokemon::add_tests_RuntimeMap(ret);
Pokemon::add_tests_RouteLog(ret);
Pokemon::add_tests_AutoStory(ret);
NintendoSwitch::add_tests_CheckOnlineDetector(ret);
NintendoSwitch::add_tests_FailedToConnectDetector(ret);
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,28 @@ enum class Record{
CHECKPOINT,
};

// A record to read, and which kind it is.
struct WireInput{
std::string_view name;
Record record = Record::STEP;
std::string_view json;
};

// What a read gives.
using ReadRecord = std::variant<GridPose, DeclaredPose, StoryStep, StoryCheckpoint>;

// "" when the record read is as expected, else what differs.
using ReadCheck = std::string (*)(const ReadRecord& record);

// What reading it gives: a record the check accepts, or a rejection.
struct WireExpectation{
ReadCheck check = nullptr;
bool rejected = false;
};

struct WireCase{
WireInput input;
WireExpectation expectation;
// A record to read, and which kind it is.
struct Input{
std::string_view name;
Record record = Record::STEP;
std::string_view json;
};

// What reading it gives: a record the check accepts, or a rejection.
struct Expectation{
ReadCheck check = nullptr;
bool rejected = false;
};

Input input;
Expectation expectation;
};

std::string expect(bool ok, std::string_view what){
Expand Down Expand Up @@ -201,7 +201,7 @@ std::vector<StoryActionSpec> test_actions(){


// `input` read.
ReadRecord read_record(const WireInput& input){
ReadRecord read_record(const WireCase::Input& input){
static const std::vector<StoryActionSpec> actions = test_actions();
const JsonValue value = parse_json(std::string(input.json));
switch (input.record){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,29 +83,29 @@ StoryGame<GridPose> engine_game(std::optional<int> candies){



// One engine run of 00.31 in `phase`, the player ending on `end_map`.
struct EngineInput{
std::string_view name;
std::string_view phase;
HashRecord hash = HashRecord::MATCHING;
std::string_view steps = TALK_STEPS;
// Where the talk leaves the player; empty: the talk opens no text.
std::string_view end_map = "RocketHideout_B3F";
std::optional<int> candies = 2;
};
struct EngineCase{
// One engine run of 00.31 in `phase`, the player ending on `end_map`.
struct Input{
std::string_view name;
std::string_view phase;
HashRecord hash = HashRecord::MATCHING;
std::string_view steps = TALK_STEPS;
// Where the talk leaves the player; empty: the talk opens no text.
std::string_view end_map = "RocketHideout_B3F";
std::optional<int> candies = 2;
};

// The save mode chosen, the verdict, whether the game saved (each save
// logs "[Test] save") and a line the run logged.
struct EngineExpectation{
StorySaveMode mode = StorySaveMode::NONE;
CheckpointVerdict verdict = CheckpointVerdict::PASSED;
size_t saves = 0;
std::string_view line = {};
};
// The save mode chosen, the verdict, whether the game saved (each save
// logs "[Test] save") and a line the run logged.
struct Expectation{
StorySaveMode mode = StorySaveMode::NONE;
CheckpointVerdict verdict = CheckpointVerdict::PASSED;
size_t saves = 0;
std::string_view line = {};
};

struct EngineCase{
EngineInput input;
EngineExpectation expectation;
Input input;
Expectation expectation;
};

const EngineCase ENGINE_CASES[] = {
Expand Down Expand Up @@ -201,23 +201,23 @@ class StoryEngineSaveTest : public UnitTest{



// Two checkpoints' events, hashed with the built-in actions.
struct HashInput{
std::string_view name;
std::string_view a;
std::string_view b;
};
struct HashCase{
// Two checkpoints' events, hashed with the built-in actions.
struct Input{
std::string_view name;
std::string_view a;
std::string_view b;
};

// Whether they hash the same, and `a`'s hash when pinned: a change to it
// means every recorded verification goes stale.
struct HashExpectation{
bool same = true;
std::optional<std::string_view> hash_a = std::nullopt;
};
// Whether they hash the same, and `a`'s hash when pinned: a change to it
// means every recorded verification goes stale.
struct Expectation{
bool same = true;
std::optional<std::string_view> hash_a = std::nullopt;
};

struct HashCase{
HashInput input;
HashExpectation expectation;
Input input;
Expectation expectation;
};

inline constexpr std::string_view ROUTE_B3F = R"([{"id": "go", "kind": "route", "args": {"target": {"map": "RocketHideout_B3F", "tiles": [[12, 13]]}}}])";
Expand Down Expand Up @@ -271,23 +271,23 @@ class StoryStepsHashTest : public UnitTest{



// A checkpoint's "metadata", read.
struct MetadataInput{
std::string_view name;
std::string_view metadata;
};
struct MetadataCase{
// A checkpoint's "metadata", read.
struct Input{
std::string_view name;
std::string_view metadata;
};

// The error the read throws (contained), or what it read.
struct MetadataExpectation{
std::string_view error = {};
StoryPhase phase = StoryPhase::TESTING;
std::string_view steps_hash = {};
size_t items = 0;
};
// The error the read throws (contained), or what it read.
struct Expectation{
std::string_view error = {};
StoryPhase phase = StoryPhase::TESTING;
std::string_view steps_hash = {};
size_t items = 0;
};

struct MetadataCase{
MetadataInput input;
MetadataExpectation expectation;
Input input;
Expectation expectation;
};

const MetadataCase METADATA_CASES[] = {
Expand Down Expand Up @@ -341,21 +341,21 @@ class StoryMetadataTest : public UnitTest{



// What a look showed, classified by ScreenMachine states that match on
// observations.
struct ScreenInput{
std::string_view name;
std::vector<ScreenEvent> events;
};
struct ScreenCase{
// What a look showed, classified by ScreenMachine states that match on
// observations.
struct Input{
std::string_view name;
std::vector<ScreenEvent> events;
};

// The state matched; none when no state did.
struct ScreenExpectation{
std::optional<std::string_view> state = std::nullopt;
};
// The state matched; none when no state did.
struct Expectation{
std::optional<std::string_view> state = std::nullopt;
};

struct ScreenCase{
ScreenInput input;
ScreenExpectation expectation;
Input input;
Expectation expectation;
};

const ScreenCase SCREEN_CASES[] = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Story Engine Runs Tests

Check warning on line 1 in SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryEngineRuns_Tests.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

<file>: file_lines=743 (advisory above 500, limit 1000)
*
* From: https://github.com/PokemonAutomation/
*
Expand Down Expand Up @@ -585,22 +585,22 @@

// Gap 7: the first checkpoint is retried after a reload; one after it
// only when the one before saved at its end (#329).
struct SegmentInput{
std::string_view name;
StoryPhase phase;
// Which checkpoint fails once: 0 or 1.
size_t flaky = 0;
};
struct SegmentCase{
struct Input{
std::string_view name;
StoryPhase phase;
// Which checkpoint fails once: 0 or 1.
size_t flaky = 0;
};

struct SegmentExpectation{
bool completed = false;
size_t reloads = 0;
size_t saves = 0;
};
struct Expectation{
bool completed = false;
size_t reloads = 0;
size_t saves = 0;
};

struct SegmentCase{
SegmentInput input;
SegmentExpectation expectation;
Input input;
Expectation expectation;
};

const SegmentCase SEGMENT_CASES[] = {
Expand Down Expand Up @@ -675,20 +675,20 @@
}


// One check above, by name.
struct RunsInput{
std::string_view name;
std::string (*check)(CancellableScope& scope);
};
struct RunsCase{
// One check above, by name.
struct Input{
std::string_view name;
std::string (*check)(CancellableScope& scope);
};

// The check's error: none.
struct RunsExpectation{
std::string_view error = {};
};
// The check's error: none.
struct Expectation{
std::string_view error = {};
};

struct RunsCase{
RunsInput input;
RunsExpectation expectation;
Input input;
Expectation expectation;
};

const RunsCase RUNS_CASES[] = {
Expand Down
Loading
Loading