@@ -81,16 +81,36 @@ public function two_script_jobs_with_same_executable_are_distinguishable(): void
8181
8282 file_put_contents ($ this ->configPath , $ this ->configurationFileBuilder ->buildV3Php ());
8383
84- passthru ("$ this ->githooks flow shards --config= $ this ->configPath 2>&1 " , $ exitCode );
84+ $ stdoutPath = self ::TESTS_PATH . '/diag-script-stdout.log ' ;
85+ $ stderrPath = self ::TESTS_PATH . '/diag-script-stderr.log ' ;
86+ $ cmd = "$ this ->githooks flow shards --config= $ this ->configPath > $ stdoutPath 2> $ stderrPath " ;
87+ exec ($ cmd , $ unused , $ exitCode );
8588
86- $ this ->assertEquals (0 , $ exitCode );
87- $ output = $ this ->getActualOutput ();
88- $ this ->assertStringContainsString ('shard_a - OK ' , $ output );
89- $ this ->assertStringContainsString ('shard_b - OK ' , $ output );
89+ $ stdout = (string ) file_get_contents ($ stdoutPath );
90+ $ stderr = (string ) file_get_contents ($ stderrPath );
91+ @unlink ($ stdoutPath );
92+ @unlink ($ stderrPath );
93+
94+ if ($ exitCode !== 0 ) {
95+ $ configContent = (string ) file_get_contents ($ this ->configPath );
96+ fwrite (
97+ STDERR ,
98+ "\n=== ScriptJobDisplayNameReleaseTest diagnostic === \n"
99+ . "exitCode: $ exitCode \n"
100+ . "--- config --- \n$ configContent \n"
101+ . "--- stdout --- \n$ stdout \n"
102+ . "--- stderr --- \n$ stderr \n"
103+ . "=== end diagnostic === \n"
104+ );
105+ }
106+
107+ $ this ->assertSame (0 , $ exitCode , 'flow shards must exit 0; see diagnostic dump above for stdout/stderr/config ' );
108+ $ this ->assertStringContainsString ('shard_a - OK ' , $ stdout );
109+ $ this ->assertStringContainsString ('shard_b - OK ' , $ stdout );
90110 // The pre-fix output would have shown "/bin/echo identical-runner - OK" twice.
91111 $ this ->assertLessThanOrEqual (
92112 1 ,
93- substr_count ($ output , '/bin/echo identical-runner - OK ' ),
113+ substr_count ($ stdout , '/bin/echo identical-runner - OK ' ),
94114 'Two script jobs were shown with their executable instead of their job key. '
95115 );
96116 }
0 commit comments