diff --git a/ddsrouter_yaml/CMakeLists.txt b/ddsrouter_yaml/CMakeLists.txt index fde575692..9eb0da37b 100644 --- a/ddsrouter_yaml/CMakeLists.txt +++ b/ddsrouter_yaml/CMakeLists.txt @@ -77,8 +77,14 @@ compile_test_library( ############################################################################### # Resources ############################################################################### -set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS - "${PROJECT_SOURCE_DIR}/../resources/configurations/ddsrouter_config_schema.json") +# NOTE: the path must be normalized (no "..") so that it matches the one registered by +# configure_file. The Ninja generator emits every CMake input in a single build statement and +# canonicalizes the paths, so two spellings of the same file would collide with +# "multiple rules generate ". +get_filename_component(_CONFIG_SCHEMA_FILE + "${PROJECT_SOURCE_DIR}/../resources/configurations/ddsrouter_config_schema.json" ABSOLUTE) + +set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${_CONFIG_SCHEMA_FILE}") file(READ "${PROJECT_SOURCE_DIR}/../resources/configurations/ddsrouter_config_schema.json" DDSROUTER_CONFIG_SCHEMA_CONTENT) diff --git a/tools/ddsrouter_tool/test/application/launcher.ps1 b/tools/ddsrouter_tool/test/application/launcher.ps1 index b63352002..655b1157c 100644 --- a/tools/ddsrouter_tool/test/application/launcher.ps1 +++ b/tools/ddsrouter_tool/test/application/launcher.ps1 @@ -24,19 +24,31 @@ Param( $test_config_file ) -$test = Start-Process -Passthru -Wait ` - -FilePath $python_path ` - -ArgumentList ( - $test_script, - "--exe", $tool_path, - "--config-file", $test_config_file, - "--debug", - "--signal", "sigint") ` - -WindowStyle Hidden - -if( $test.ExitCode -ne 0 ) +# The test runs in a new hidden console: the CTRL_C_EVENT it sends to the DDS Router reaches every +# process attached to the console, so it must not share the console with CTest. +# +# The console is created by Python's subprocess (CreateProcess) instead of Start-Process: Start-Process +# fails with "An attempt was made to reference a token that does not exist" when there is no +# interactive user session, e.g. on CI runners running as a service. +$new_console_launcher = ` + 'import subprocess, sys; ' + ` + 'startupinfo = subprocess.STARTUPINFO(); ' + ` + 'startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW; ' + ` + 'startupinfo.wShowWindow = 0; ' + ` + 'sys.exit(subprocess.call(sys.argv[1:], ' + ` + 'creationflags=subprocess.CREATE_NEW_CONSOLE, startupinfo=startupinfo))' + +& $python_path -c $new_console_launcher ` + $python_path $test_script ` + --exe $tool_path ` + --config-file $test_config_file ` + --debug ` + --signal sigint +$exit_code = $LASTEXITCODE + +if( $exit_code -ne 0 ) { - $error_message = "Test: $test_name failed with exit code $($test.ExitCode)." + $error_message = "Test: $test_config_file failed with exit code $exit_code." throw $error_message }