mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
Meta: Allow running Lagom tests with "serenity.sh run lagom <target>"
After 5ac57f9
, we could no longer run "serenity.sh run lagom TestString"
because the TestString binary now lives in a subdirectory under
Build/lagom. Thus the existing method of running "$BUILD_DIR/TestString"
could not work.
This adds a "run-lagom-target" custom target to Lagom, to run a command
and pass arguments to that invocation. It turns out there really isn't a
"pretty" way of doing this with CMake or Ninja. But we can pass these as
environment variables for CMake to interpret. We just must be careful to
massage arguments into a CMake list.
This commit is contained in:
parent
a5db4a0551
commit
9743445e44
2 changed files with 28 additions and 2 deletions
|
@ -688,3 +688,12 @@ if (ENABLE_FUZZERS)
|
|||
else()
|
||||
export_components("${CMAKE_BINARY_DIR}/components.ini")
|
||||
endif()
|
||||
|
||||
if (NOT "$ENV{LAGOM_TARGET}" STREQUAL "")
|
||||
add_custom_target(run-lagom-target
|
||||
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SERENITY_PROJECT_ROOT}" "$<TARGET_FILE:$ENV{LAGOM_TARGET}>" $ENV{LAGOM_ARGS}
|
||||
DEPENDS "$<TARGET_FILE:$ENV{LAGOM_TARGET}>"
|
||||
USES_TERMINAL
|
||||
VERBATIM
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -401,6 +401,23 @@ run_gdb() {
|
|||
fi
|
||||
}
|
||||
|
||||
build_and_run_lagom_target() {
|
||||
local lagom_target="${CMD_ARGS[0]}"
|
||||
local lagom_args
|
||||
|
||||
# All command arguments must have any existing semicolon escaped, to prevent CMake from
|
||||
# interpreting them as list separators.
|
||||
local cmd_args=()
|
||||
for arg in "${CMD_ARGS[@]:1}"; do
|
||||
cmd_args+=( "${arg//;/\\;}" )
|
||||
done
|
||||
|
||||
# Then existing list separators must be replaced with a semicolon for CMake.
|
||||
lagom_args=$(IFS=';' ; echo -e "${cmd_args[*]}")
|
||||
|
||||
LAGOM_TARGET="${lagom_target}" LAGOM_ARGS="${lagom_args[*]}" build_target "run-lagom-target"
|
||||
}
|
||||
|
||||
if [[ "$CMD" =~ ^(build|install|image|copy-src|run|gdb|test|rebuild|recreate|kaddr2line|addr2line|setup-and-run)$ ]]; then
|
||||
cmd_with_target
|
||||
[[ "$CMD" != "recreate" && "$CMD" != "rebuild" ]] || delete_target
|
||||
|
@ -429,11 +446,11 @@ if [[ "$CMD" =~ ^(build|install|image|copy-src|run|gdb|test|rebuild|recreate|kad
|
|||
;;
|
||||
run)
|
||||
if [ "$TARGET" = "lagom" ]; then
|
||||
build_target "${CMD_ARGS[0]}"
|
||||
if [ "${CMD_ARGS[0]}" = "ladybird" ]; then
|
||||
build_target "${CMD_ARGS[0]}"
|
||||
ninja -C "$BUILD_DIR" run-ladybird
|
||||
else
|
||||
"$BUILD_DIR/${CMD_ARGS[0]}" "${CMD_ARGS[@]:1}"
|
||||
build_and_run_lagom_target
|
||||
fi
|
||||
else
|
||||
build_target
|
||||
|
|
Loading…
Add table
Reference in a new issue