Test runner fixes (#7100)

Co-authored-by: Hedara <hedara90@gmail.com>
This commit is contained in:
hedara90 2025-06-15 12:02:29 +02:00 committed by GitHub
parent 3491cd95e8
commit b2a0107a68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 15 additions and 8 deletions

View File

@ -734,7 +734,7 @@ struct BattleTestRunnerState
bool8 runThen:1;
bool8 runFinally:1;
bool8 runningFinally:1;
bool8 tearDownBattle:1;
bool8 hasTornDownBattle:1;
struct BattleTestData data;
u8 *results;
u8 checkProgressParameter;

View File

@ -15,6 +15,7 @@ enum TestResult
TEST_RESULT_TIMEOUT,
TEST_RESULT_CRASH,
TEST_RESULT_TODO,
TEST_RESULT_KNOWN_FAIL,
};
struct TestRunner
@ -214,7 +215,7 @@ static inline struct Benchmark BenchmarkStop(void)
} while (0)
#define KNOWN_FAILING \
Test_ExpectedResult(TEST_RESULT_FAIL)
Test_ExpectedResult(TEST_RESULT_KNOWN_FAIL)
#define KNOWN_LEAKING \
Test_ExpectLeaks(TRUE)

View File

@ -1016,7 +1016,6 @@ AI_SINGLE_BATTLE_TEST("AI_FLAG_SMART_SWITCHING: AI will switch out if main attac
AI_SINGLE_BATTLE_TEST("Switch AI: AI will switch into mon with good type matchup and SE move if current mon has no SE move and no stats raised")
{
KNOWN_FAILING; // Either remove or replace the function
u32 odds = 0, species = SPECIES_NONE, move = MOVE_NONE;
PARAMETRIZE { odds = 33; species = SPECIES_SCIZOR; move = MOVE_X_SCISSOR; }
PARAMETRIZE { odds = 50; species = SPECIES_DUSCLOPS; move = MOVE_SHADOW_BALL; }

View File

@ -312,7 +312,9 @@ top:
const char *color;
const char *result;
if (gTestRunnerState.result == gTestRunnerState.expectedResult)
if (gTestRunnerState.result == gTestRunnerState.expectedResult
|| (gTestRunnerState.result == TEST_RESULT_FAIL
&& gTestRunnerState.expectedResult == TEST_RESULT_KNOWN_FAIL))
{
color = "\e[32m";
Test_MgbaPrintf(":N%s", gTestRunnerState.test->name);
@ -330,7 +332,7 @@ top:
switch (gTestRunnerState.result)
{
case TEST_RESULT_FAIL:
if (gTestRunnerState.expectedResult == TEST_RESULT_FAIL)
if (gTestRunnerState.expectedResult == TEST_RESULT_KNOWN_FAIL)
{
result = "KNOWN_FAILING";
color = "\e[33m";
@ -387,7 +389,9 @@ top:
Test_MgbaPrintf(":A%s%s\e[0m", color, result);
else if (gTestRunnerState.result == TEST_RESULT_TODO)
Test_MgbaPrintf(":T%s%s\e[0m", color, result);
else if (gTestRunnerState.expectedResult == gTestRunnerState.result)
else if (gTestRunnerState.expectedResult == gTestRunnerState.result
|| (gTestRunnerState.result == TEST_RESULT_FAIL
&& gTestRunnerState.expectedResult == TEST_RESULT_KNOWN_FAIL))
Test_MgbaPrintf(":K%s%s\e[0m", color, result);
else
Test_MgbaPrintf(":F%s%s\e[0m", color, result);

View File

@ -181,6 +181,7 @@ static void BattleTest_SetUp(void *data)
STATE->battlersCount = 4;
break;
}
STATE->hasTornDownBattle = FALSE;
}
static void PrintTestName(void)
@ -1420,8 +1421,11 @@ static void BattleTest_TearDown(void *data)
// aborted unexpectedly.
ClearFlagAfterTest();
TestFreeConfigData();
if (STATE->tearDownBattle)
if (!STATE->hasTornDownBattle)
{
TearDownBattle();
STATE->hasTornDownBattle = TRUE;
}
}
static bool32 BattleTest_CheckProgress(void *data)
@ -1449,7 +1453,6 @@ static bool32 BattleTest_HandleExitWithResult(void *data, enum TestResult result
}
else
{
STATE->tearDownBattle = TRUE;
return FALSE;
}
}