@@ -63,13 +63,46 @@ function sourceSetupScript(setupPath) {
6363function buildTestMessage ( ) {
6464 // Build the custom_msg_test package synchronously before running the test
6565 const customMsgTestPath = path . join ( __dirname , 'custom_msg_test' ) ;
66+ const fs = require ( 'fs' ) ;
6667
67- const buildResult = require ( 'child_process' ) . spawnSync ( 'colcon' , [ 'build' ] , {
68+ // Try to create log directory with proper permissions, or use temp directory
69+ const logPath = path . join ( customMsgTestPath , 'log' ) ;
70+ let logBase = null ;
71+
72+ try {
73+ // Try to create the log directory
74+ if ( ! fs . existsSync ( logPath ) ) {
75+ fs . mkdirSync ( logPath , { recursive : true , mode : 0o755 } ) ;
76+ }
77+ } catch ( err ) {
78+ // If we can't create log directory, use a temp directory instead
79+ logBase = path . join ( os . tmpdir ( ) , `colcon-log-${ process . pid } ` ) ;
80+ if ( ! fs . existsSync ( logBase ) ) {
81+ fs . mkdirSync ( logBase , { recursive : true , mode : 0o755 } ) ;
82+ }
83+ }
84+
85+ // Build colcon command arguments
86+ const colconArgs = [ 'build' ] ;
87+ if ( logBase ) {
88+ colconArgs . push ( '--log-base' , logBase ) ;
89+ }
90+
91+ const buildResult = require ( 'child_process' ) . spawnSync ( 'colcon' , colconArgs , {
6892 cwd : customMsgTestPath ,
6993 stdio : 'inherit' ,
7094 timeout : 60000 , // 60 second timeout
7195 } ) ;
7296
97+ // Cleanup temp log directory if we created one
98+ if ( logBase && fs . existsSync ( logBase ) ) {
99+ try {
100+ fs . rmSync ( logBase , { recursive : true , force : true } ) ;
101+ } catch ( err ) {
102+ // Ignore cleanup errors
103+ }
104+ }
105+
73106 if ( buildResult . error ) {
74107 throw new Error (
75108 `Failed to build custom_msg_test package: ${ buildResult . error . message } `
0 commit comments