mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-25 19:24:16 +01:00
Separate build directory for tests and TESTING define (#3002)
* Separate build directory for tests and TESTING define * fixup! Separate build directory for tests and TESTING define * fixup! Separate build directory for tests and TESTING define * fixup! Separate build directory for tests and TESTING define
This commit is contained in:
parent
2e08277a4e
commit
412f6f5352
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -50,6 +50,8 @@ jobs:
|
|||||||
run: make -j${nproc} -O all
|
run: make -j${nproc} -O all
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
|
env:
|
||||||
|
TEST: 1
|
||||||
run: |
|
run: |
|
||||||
make -j${nproc} -O pokeemerald-test.elf
|
make -j${nproc} -O pokeemerald-test.elf
|
||||||
make -j${nproc} check
|
make -j${nproc} check
|
||||||
|
30
Makefile
30
Makefile
@ -41,11 +41,16 @@ GAME_CODE := BPEE
|
|||||||
MAKER_CODE := 01
|
MAKER_CODE := 01
|
||||||
REVISION := 0
|
REVISION := 0
|
||||||
MODERN ?= 0
|
MODERN ?= 0
|
||||||
|
TEST ?= 0
|
||||||
|
|
||||||
ifeq (modern,$(MAKECMDGOALS))
|
ifeq (modern,$(MAKECMDGOALS))
|
||||||
MODERN := 1
|
MODERN := 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq (check,$(MAKECMDGOALS))
|
||||||
|
TEST := 1
|
||||||
|
endif
|
||||||
|
|
||||||
# use arm-none-eabi-cpp for macOS
|
# use arm-none-eabi-cpp for macOS
|
||||||
# as macOS's default compiler is clang
|
# as macOS's default compiler is clang
|
||||||
# and clang's preprocessor will warn on \u
|
# and clang's preprocessor will warn on \u
|
||||||
@ -79,6 +84,7 @@ ELF = $(ROM:.gba=.elf)
|
|||||||
MAP = $(ROM:.gba=.map)
|
MAP = $(ROM:.gba=.map)
|
||||||
SYM = $(ROM:.gba=.sym)
|
SYM = $(ROM:.gba=.sym)
|
||||||
|
|
||||||
|
TEST_OBJ_DIR_NAME := build/test
|
||||||
TESTELF = $(ROM:.gba=-test.elf)
|
TESTELF = $(ROM:.gba=-test.elf)
|
||||||
HEADLESSELF = $(ROM:.gba=-test-headless.elf)
|
HEADLESSELF = $(ROM:.gba=-test-headless.elf)
|
||||||
|
|
||||||
@ -119,7 +125,15 @@ LIBPATH := -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libgcc.a)
|
|||||||
LIB := $(LIBPATH) -lc -lnosys -lgcc -L../../libagbsyscall -lagbsyscall
|
LIB := $(LIBPATH) -lc -lnosys -lgcc -L../../libagbsyscall -lagbsyscall
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CPPFLAGS := -iquote include -iquote $(GFLIB_SUBDIR) -Wno-trigraphs -DMODERN=$(MODERN)
|
ifeq ($(TESTELF),$(MAKECMDGOALS))
|
||||||
|
TEST := 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TEST),1)
|
||||||
|
OBJ_DIR := $(TEST_OBJ_DIR_NAME)
|
||||||
|
endif
|
||||||
|
|
||||||
|
CPPFLAGS := -iquote include -iquote $(GFLIB_SUBDIR) -Wno-trigraphs -DMODERN=$(MODERN) -DTESTING=$(TEST)
|
||||||
ifneq ($(MODERN),1)
|
ifneq ($(MODERN),1)
|
||||||
CPPFLAGS += -I tools/agbcc/include -I tools/agbcc -nostdinc -undef
|
CPPFLAGS += -I tools/agbcc/include -I tools/agbcc -nostdinc -undef
|
||||||
endif
|
endif
|
||||||
@ -168,7 +182,7 @@ infoshell = $(foreach line, $(shell $1 | sed "s/ /__SPACE__/g"), $(info $(subst
|
|||||||
# Disable dependency scanning for clean/tidy/tools
|
# Disable dependency scanning for clean/tidy/tools
|
||||||
# Use a separate minimal makefile for speed
|
# Use a separate minimal makefile for speed
|
||||||
# Since we don't need to reload most of this makefile
|
# Since we don't need to reload most of this makefile
|
||||||
ifeq (,$(filter-out all rom compare modern check libagbsyscall syms,$(MAKECMDGOALS)))
|
ifeq (,$(filter-out all rom compare modern check libagbsyscall syms $(TESTELF),$(MAKECMDGOALS)))
|
||||||
$(call infoshell, $(MAKE) -f make_tools.mk)
|
$(call infoshell, $(MAKE) -f make_tools.mk)
|
||||||
else
|
else
|
||||||
NODEP ?= 1
|
NODEP ?= 1
|
||||||
@ -178,9 +192,9 @@ endif
|
|||||||
ifeq (,$(MAKECMDGOALS))
|
ifeq (,$(MAKECMDGOALS))
|
||||||
SCAN_DEPS ?= 1
|
SCAN_DEPS ?= 1
|
||||||
else
|
else
|
||||||
# clean, tidy, tools, check-tools, mostlyclean, clean-tools, clean-check-tools, $(TOOLDIRS), $(CHECKTOOLDIRS), tidymodern, tidynonmodern don't even build the ROM
|
# clean, tidy, tools, check-tools, mostlyclean, clean-tools, clean-check-tools, $(TOOLDIRS), $(CHECKTOOLDIRS), tidymodern, tidynonmodern, tidycheck don't even build the ROM
|
||||||
# libagbsyscall does its own thing
|
# libagbsyscall does its own thing
|
||||||
ifeq (,$(filter-out clean tidy tools mostlyclean clean-tools $(TOOLDIRS) clean-check-tools $(CHECKTOOLDIRS) tidymodern tidynonmodern libagbsyscall,$(MAKECMDGOALS)))
|
ifeq (,$(filter-out clean tidy tools mostlyclean clean-tools $(TOOLDIRS) clean-check-tools $(CHECKTOOLDIRS) tidymodern tidynonmodern tidycheck libagbsyscall,$(MAKECMDGOALS)))
|
||||||
SCAN_DEPS ?= 0
|
SCAN_DEPS ?= 0
|
||||||
else
|
else
|
||||||
SCAN_DEPS ?= 1
|
SCAN_DEPS ?= 1
|
||||||
@ -257,7 +271,7 @@ clean-tools:
|
|||||||
clean-check-tools:
|
clean-check-tools:
|
||||||
@$(foreach tooldir,$(CHECKTOOLDIRS),$(MAKE) clean -C $(tooldir);)
|
@$(foreach tooldir,$(CHECKTOOLDIRS),$(MAKE) clean -C $(tooldir);)
|
||||||
|
|
||||||
mostlyclean: tidynonmodern tidymodern
|
mostlyclean: tidynonmodern tidymodern tidycheck
|
||||||
rm -f $(SAMPLE_SUBDIR)/*.bin
|
rm -f $(SAMPLE_SUBDIR)/*.bin
|
||||||
rm -f $(CRY_SUBDIR)/*.bin
|
rm -f $(CRY_SUBDIR)/*.bin
|
||||||
rm -f $(MID_SUBDIR)/*.s
|
rm -f $(MID_SUBDIR)/*.s
|
||||||
@ -268,7 +282,7 @@ mostlyclean: tidynonmodern tidymodern
|
|||||||
rm -f $(AUTO_GEN_TARGETS)
|
rm -f $(AUTO_GEN_TARGETS)
|
||||||
@$(MAKE) clean -C libagbsyscall
|
@$(MAKE) clean -C libagbsyscall
|
||||||
|
|
||||||
tidy: tidynonmodern tidymodern
|
tidy: tidynonmodern tidymodern tidycheck
|
||||||
|
|
||||||
tidynonmodern:
|
tidynonmodern:
|
||||||
rm -f $(ROM_NAME) $(ELF_NAME) $(MAP_NAME)
|
rm -f $(ROM_NAME) $(ELF_NAME) $(MAP_NAME)
|
||||||
@ -278,6 +292,10 @@ tidymodern:
|
|||||||
rm -f $(MODERN_ROM_NAME) $(MODERN_ELF_NAME) $(MODERN_MAP_NAME)
|
rm -f $(MODERN_ROM_NAME) $(MODERN_ELF_NAME) $(MODERN_MAP_NAME)
|
||||||
rm -rf $(MODERN_OBJ_DIR_NAME)
|
rm -rf $(MODERN_OBJ_DIR_NAME)
|
||||||
|
|
||||||
|
tidycheck:
|
||||||
|
rm -f $(TESTELF) $(HEADLESSELF)
|
||||||
|
rm -rf $(TEST_OBJ_DIR_NAME)
|
||||||
|
|
||||||
ifneq ($(MODERN),0)
|
ifneq ($(MODERN),0)
|
||||||
$(C_BUILDDIR)/berry_crush.o: override CFLAGS += -Wno-address-of-packed-member
|
$(C_BUILDDIR)/berry_crush.o: override CFLAGS += -Wno-address-of-packed-member
|
||||||
endif
|
endif
|
||||||
|
@ -44,9 +44,18 @@ struct MemBlock
|
|||||||
|
|
||||||
extern u8 gHeap[];
|
extern u8 gHeap[];
|
||||||
|
|
||||||
|
#if TESTING || !defined(NDEBUG)
|
||||||
|
|
||||||
#define Alloc(size) Alloc_(size, __FILE__ ":" STR(__LINE__))
|
#define Alloc(size) Alloc_(size, __FILE__ ":" STR(__LINE__))
|
||||||
#define AllocZeroed(size) AllocZeroed_(size, __FILE__ ":" STR(__LINE__))
|
#define AllocZeroed(size) AllocZeroed_(size, __FILE__ ":" STR(__LINE__))
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define Alloc(size) Alloc_(size, NULL)
|
||||||
|
#define AllocZeroed(size) AllocZeroed_(size, NULL)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void *Alloc_(u32 size, const char *location);
|
void *Alloc_(u32 size, const char *location);
|
||||||
void *AllocZeroed_(u32 size, const char *location);
|
void *AllocZeroed_(u32 size, const char *location);
|
||||||
void Free(void *pointer);
|
void Free(void *pointer);
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
|
|
||||||
extern const bool8 gTestRunnerEnabled;
|
extern const bool8 gTestRunnerEnabled;
|
||||||
extern const bool8 gTestRunnerHeadless;
|
extern const bool8 gTestRunnerHeadless;
|
||||||
|
|
||||||
|
#if TESTING
|
||||||
|
|
||||||
extern const bool8 gTestRunnerSkipIsFail;
|
extern const bool8 gTestRunnerSkipIsFail;
|
||||||
|
|
||||||
void TestRunner_Battle_RecordAbilityPopUp(u32 battlerId, u32 ability);
|
void TestRunner_Battle_RecordAbilityPopUp(u32 battlerId, u32 ability);
|
||||||
@ -12,6 +15,19 @@ void TestRunner_Battle_RecordMessage(const u8 *message);
|
|||||||
void TestRunner_Battle_RecordStatus1(u32 battlerId, u32 status1);
|
void TestRunner_Battle_RecordStatus1(u32 battlerId, u32 status1);
|
||||||
void TestRunner_Battle_AfterLastTurn(void);
|
void TestRunner_Battle_AfterLastTurn(void);
|
||||||
|
|
||||||
void BattleTest_CheckBattleRecordActionType(u32 battlerId, u32 recordIndex, u32 actionType);
|
void TestRunner_Battle_CheckBattleRecordActionType(u32 battlerId, u32 recordIndex, u32 actionType);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define TestRunner_Battle_RecordAbilityPopUp(...) (void)0
|
||||||
|
#define TestRunner_Battle_RecordAnimation(...) (void)0
|
||||||
|
#define TestRunner_Battle_RecordHP(...) (void)0
|
||||||
|
#define TestRunner_Battle_RecordMessage(...) (void)0
|
||||||
|
#define TestRunner_Battle_RecordStatus1(...) (void)0
|
||||||
|
#define TestRunner_Battle_AfterLastTurn(...) (void)0
|
||||||
|
|
||||||
|
#define TestRunner_Battle_CheckBattleRecordActionType(...) (void)0
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -176,7 +176,7 @@ void RecordedBattle_ClearBattlerAction(u8 battlerId, u8 bytesToClear)
|
|||||||
u8 RecordedBattle_GetBattlerAction(u32 actionType, u8 battlerId)
|
u8 RecordedBattle_GetBattlerAction(u32 actionType, u8 battlerId)
|
||||||
{
|
{
|
||||||
if (gTestRunnerEnabled)
|
if (gTestRunnerEnabled)
|
||||||
BattleTest_CheckBattleRecordActionType(battlerId, sBattlerRecordSizes[battlerId], actionType);
|
TestRunner_Battle_CheckBattleRecordActionType(battlerId, sBattlerRecordSizes[battlerId], actionType);
|
||||||
|
|
||||||
// Trying to read past array or invalid action byte, battle is over.
|
// Trying to read past array or invalid action byte, battle is over.
|
||||||
if (sBattlerRecordSizes[battlerId] >= BATTLER_RECORD_SIZE || sBattleRecords[battlerId][sBattlerRecordSizes[battlerId]] == 0xFF)
|
if (sBattlerRecordSizes[battlerId] >= BATTLER_RECORD_SIZE || sBattleRecords[battlerId][sBattlerRecordSizes[battlerId]] == 0xFF)
|
||||||
|
@ -9,38 +9,3 @@ const bool8 gTestRunnerEnabled = FALSE;
|
|||||||
// animations and messages play, which helps when debugging a test.
|
// animations and messages play, which helps when debugging a test.
|
||||||
const bool8 gTestRunnerHeadless = FALSE;
|
const bool8 gTestRunnerHeadless = FALSE;
|
||||||
const bool8 gTestRunnerSkipIsFail = FALSE;
|
const bool8 gTestRunnerSkipIsFail = FALSE;
|
||||||
|
|
||||||
__attribute__((weak))
|
|
||||||
void TestRunner_Battle_RecordAbilityPopUp(u32 battlerId, u32 ability)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((weak))
|
|
||||||
void TestRunner_Battle_RecordAnimation(u32 animType, u32 animId)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((weak))
|
|
||||||
void TestRunner_Battle_RecordHP(u32 battlerId, u32 oldHP, u32 newHP)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((weak))
|
|
||||||
void TestRunner_Battle_RecordMessage(const u8 *string)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((weak))
|
|
||||||
void TestRunner_Battle_RecordStatus1(u32 battlerId, u32 status1)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((weak))
|
|
||||||
void TestRunner_Battle_AfterLastTurn(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((weak))
|
|
||||||
void BattleTest_CheckBattleRecordActionType(u32 battlerId, u32 recordIndex, u32 actionType)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
@ -1241,7 +1241,7 @@ static void PushBattlerAction(u32 sourceLine, s32 battlerId, u32 actionType, u32
|
|||||||
DATA.recordedBattle.battleRecord[battlerId][recordIndex] = byte;
|
DATA.recordedBattle.battleRecord[battlerId][recordIndex] = byte;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleTest_CheckBattleRecordActionType(u32 battlerId, u32 recordIndex, u32 actionType)
|
void TestRunner_Battle_CheckBattleRecordActionType(u32 battlerId, u32 recordIndex, u32 actionType)
|
||||||
{
|
{
|
||||||
// An illegal move choice will cause the battle to request a new
|
// An illegal move choice will cause the battle to request a new
|
||||||
// move slot and target. This detects the move slot.
|
// move slot and target. This detects the move slot.
|
||||||
|
Loading…
Reference in New Issue
Block a user