@@ -155,32 +155,57 @@ async fn run_test(args: &Args, test_case: TestCase) -> TestResult {
155155 }
156156}
157157
158- fn print_result ( result : & TestResult , verbose : bool ) {
159- let status = if result. passed { "✓ " } else { "✗ " } ;
158+ fn print_tap_result ( test_number : usize , result : & TestResult , verbose : bool ) {
159+ let status = if result. passed { "ok " } else { "not ok " } ;
160160 let name = result. test_case . name ( ) ;
161- let duration_ms = result . duration . as_millis ( ) ;
162-
163- // Format CIDs for display
164- let cid_str = if result . cids . is_empty ( ) {
165- String :: new ( )
166- } else {
167- format ! ( " [CID: {}]" , result . cids . join ( ", " ) )
168- } ;
169-
170- if result . passed {
171- println ! ( "{} {} ({} ms){}" , status , name , duration_ms , cid_str ) ;
172- } else {
173- println ! ( "{} {} ({} ms){}" , status , name , duration_ms , cid_str ) ;
174- if let Some ( ref msg ) = result. message {
175- if verbose {
176- println ! ( " Error : {}" , msg ) ;
161+ println ! ( "{} {} - {}" , status , test_number , name ) ;
162+
163+ // YAML diagnostic block
164+ println ! ( " ---" ) ;
165+ println ! ( " duration_ms: {}" , result . duration . as_millis ( ) ) ;
166+
167+ // Connection IDs for mlog correlation
168+ match result . cids . len ( ) {
169+ 0 => { }
170+ 1 => println ! ( " connection_id: {}" , result . cids [ 0 ] ) ,
171+ 2 => {
172+ // Multi-connection tests: first is publisher, second is subscriber
173+ // (except subscribe-before-announce where subscriber connects first)
174+ if result. test_case == TestCase :: SubscribeBeforeAnnounce {
175+ println ! ( " subscriber_connection_id: {}" , result . cids [ 0 ] ) ;
176+ println ! ( " publisher_connection_id : {}" , result . cids [ 1 ] ) ;
177177 } else {
178- // Show first line of error
179- let first_line = msg. lines ( ) . next ( ) . unwrap_or ( msg) ;
180- println ! ( " Error: {}" , first_line) ;
178+ println ! ( " publisher_connection_id: {}" , result. cids[ 0 ] ) ;
179+ println ! ( " subscriber_connection_id: {}" , result. cids[ 1 ] ) ;
180+ }
181+ }
182+ _ => {
183+ // More than 2 CIDs - just list them all
184+ for ( i, cid) in result. cids . iter ( ) . enumerate ( ) {
185+ println ! ( " connection_id_{}: {}" , i + 1 , cid) ;
181186 }
182187 }
183188 }
189+
190+ // Error message for failed tests
191+ if let Some ( ref msg) = result. message {
192+ // Escape quotes and newlines for YAML string
193+ let escaped = if verbose {
194+ msg. replace ( '\\' , "\\ \\ " )
195+ . replace ( '"' , "\\ \" " )
196+ . replace ( '\n' , "\\ n" )
197+ } else {
198+ // Non-verbose: just first line
199+ msg. lines ( )
200+ . next ( )
201+ . unwrap_or ( msg)
202+ . replace ( '\\' , "\\ \\ " )
203+ . replace ( '"' , "\\ \" " )
204+ } ;
205+ println ! ( " message: \" {}\" " , escaped) ;
206+ }
207+
208+ println ! ( " ..." ) ;
184209}
185210
186211#[ tokio:: main]
@@ -205,39 +230,31 @@ async fn main() -> Result<()> {
205230 return Ok ( ( ) ) ;
206231 }
207232
208- println ! ( "MoQT Interop Test Client" ) ;
209- println ! ( "========================" ) ;
210- println ! ( "Relay: {}" , args. relay) ;
211- println ! ( ) ;
212-
213233 let tests_to_run = match args. test {
214234 Some ( tc) => vec ! [ tc] ,
215235 None => TestCase :: all ( ) ,
216236 } ;
217237
218- let mut passed = 0 ;
238+ // TAP version 14 header with run-level comments
239+ println ! ( "TAP version 14" ) ;
240+ println ! ( "# moq-test-client v{}" , env!( "CARGO_PKG_VERSION" ) ) ;
241+ println ! ( "# Relay: {}" , args. relay) ;
242+ println ! ( "1..{}" , tests_to_run. len( ) ) ;
243+
219244 let mut failed = 0 ;
220245
221- for test_case in tests_to_run {
222- let result = run_test ( & args, test_case) . await ;
223- print_result ( & result, args. verbose ) ;
246+ for ( i , test_case) in tests_to_run. iter ( ) . enumerate ( ) {
247+ let result = run_test ( & args, * test_case) . await ;
248+ print_tap_result ( i + 1 , & result, args. verbose ) ;
224249
225- if result. passed {
226- passed += 1 ;
227- } else {
250+ if !result. passed {
228251 failed += 1 ;
229252 }
230253 }
231254
232- println ! ( ) ;
233- println ! ( "Results: {} passed, {} failed" , passed, failed) ;
234-
235- // Standard test output for parsing
236255 if failed == 0 {
237- println ! ( "\n MOQT_TEST_RESULT: SUCCESS" ) ;
238256 Ok ( ( ) )
239257 } else {
240- println ! ( "\n MOQT_TEST_RESULT: FAILURE" ) ;
241258 std:: process:: exit ( 1 ) ;
242259 }
243260}
0 commit comments