Files
dusk/test/duskscript/CMakeLists.txt
T
YourWishesandClaude Sonnet 5 a0294aae98 Load duskscript files through the asset system, not the real filesystem
scriptLoadHandler used fopen/fread directly, but every .ds a script include()s
is packed into dusk.dsk (compiled to .dsb) like every other asset now, not a
loose file next to the binary - raw filesystem reads never found them outside
a dev checkout. It now goes through assetFileInit/Open/Read/Close like the
rest of the engine's asset loaders, failing the load the same way (returning
SCRIPT_LOAD_FAILED) for a missing entry or one bigger than capacity.

test_duskscript's fixtures moved to their own assets/ subfolder and pack into
a small test.dsk with the same tools.asset.pack used for the real dusk.dsk,
and the test opens that archive straight into ASSET.zip (skipping the full
assetInit()/assetInitPlatform(), which expects a launched engine) so the
tests exercise the real compile -> pack -> asset -> runtime pipeline instead
of a filesystem shortcut around it.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
2026-10-14 22:33:46 -05:00

39 lines
1.4 KiB
CMake

# Copyright (c) 2026 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
include(dusktest)
dusktest(test_duskscript.c)
# Scripts are loaded through the asset system (see scriptLoadHandler in
# src/dusk/script/script.c), not the real filesystem, so the fixtures are
# packed into a small test.dsk with the same tools.asset.pack used for the
# game's own dusk.dsk - this exercises the real compiler -> pack -> asset ->
# runtime -> consolePrint pipeline rather than a shortcut around it.
set(DUSKSCRIPT_TEST_ASSETS_DIR ${CMAKE_CURRENT_LIST_DIR}/assets)
set(DUSKSCRIPT_TEST_DSK ${CMAKE_CURRENT_BINARY_DIR}/test.dsk)
add_custom_command(
OUTPUT ${DUSKSCRIPT_TEST_DSK}
COMMAND ${Python3_EXECUTABLE} -m tools.asset.pack
--input ${DUSKSCRIPT_TEST_ASSETS_DIR}
--output ${DUSKSCRIPT_TEST_DSK}
--duskscriptcc "$<TARGET_FILE:duskscriptcc>"
WORKING_DIRECTORY ${DUSK_ROOT_DIR}
DEPENDS
duskscriptcc
${DUSKSCRIPT_TEST_ASSETS_DIR}/fixture.ds
${DUSKSCRIPT_TEST_ASSETS_DIR}/fixture_numbers.ds
COMMENT "Packing duskscript test fixtures"
)
add_custom_target(duskscript_test_fixture DEPENDS ${DUSKSCRIPT_TEST_DSK})
add_dependencies(test_duskscript duskscript_test_fixture)
target_compile_definitions(test_duskscript PRIVATE
DUSKSCRIPT_TEST_DSK="${DUSKSCRIPT_TEST_DSK}"
DUSKSCRIPT_TEST_FIXTURE="fixture.dsb"
DUSKSCRIPT_TEST_NUMBERS="fixture_numbers.dsb"
)