@@ -372,22 +372,9 @@ fn test_plot_get_metadata() {
372372 // [1] "plot(1:10)"
373373
374374 // Verify execution_id matches the msg_id of the execute_request
375- assert ! (
376- result. contains( & msg_id) ,
377- "Metadata should contain execution_id '{msg_id}', got:\n {result}"
378- ) ;
379-
380- // Verify code matches
381- assert ! (
382- result. contains( code) ,
383- "Metadata should contain code '{code}', got:\n {result}"
384- ) ;
385-
386- // Verify kind is "plot" for base R plots
387- assert ! (
388- result. contains( "$kind" ) && result. contains( "\" plot\" " ) ,
389- "Metadata should contain kind 'plot', got:\n {result}"
390- ) ;
375+ assert ! ( result. contains( & format!( "$execution_id\n [1] \" {msg_id}\" " ) ) ) ;
376+ assert ! ( result. contains( & format!( "$code\n [1] \" {code}\" " ) ) ) ;
377+ assert ! ( result. contains( "$kind\n [1] \" plot\" " ) ) ;
391378}
392379
393380/// Test that plot metadata includes origin when code_location is provided.
@@ -443,10 +430,7 @@ fn test_plot_get_metadata_with_origin() {
443430 frontend. recv_shell_execute_reply ( ) ;
444431
445432 // Verify origin_uri is present in the metadata
446- assert ! (
447- result. contains( origin_uri) ,
448- "Metadata should contain origin_uri '{origin_uri}', got:\n {result}"
449- ) ;
433+ assert ! ( result. contains( & format!( "$origin_uri\n [1] \" {origin_uri}\" " ) ) ) ;
450434}
451435
452436/// Test that plots are emitted when created inside source().
@@ -585,16 +569,8 @@ fn test_plot_source_context_stacking() {
585569 frontend. recv_shell_execute_reply ( ) ;
586570
587571 // The origin_uri should point to file B, not file A
588- assert ! (
589- result_b. contains( & file_b. uri_id) ,
590- "Plot from file B should have origin_uri pointing to file B '{}', got:\n {result_b}" ,
591- file_b. uri_id,
592- ) ;
593- assert ! (
594- !result_b. contains( & file_a. uri_id) ,
595- "Plot from file B should NOT have origin_uri pointing to file A '{}', got:\n {result_b}" ,
596- file_a. uri_id,
597- ) ;
572+ assert ! ( result_b. contains( & format!( "$origin_uri\n [1] \" {}\" " , file_b. uri_id) ) ) ;
573+ assert ! ( !result_b. contains( & file_a. uri_id) ) ;
598574
599575 // Query metadata for the second plot (created by file A)
600576 let query_a = format ! ( ".ps.graphics.get_metadata('{display_id_a}')" ) ;
@@ -606,11 +582,7 @@ fn test_plot_source_context_stacking() {
606582 frontend. recv_shell_execute_reply ( ) ;
607583
608584 // The origin_uri should point to file A
609- assert ! (
610- result_a. contains( & file_a. uri_id) ,
611- "Plot from file A should have origin_uri pointing to file A '{}', got:\n {result_a}" ,
612- file_a. uri_id,
613- ) ;
585+ assert ! ( result_a. contains( & format!( "$origin_uri\n [1] \" {}\" " , file_a. uri_id) ) ) ;
614586}
615587
616588/// Test that plots rendered with fig-width/fig-height metadata produce
@@ -777,14 +749,8 @@ fn test_plot_without_execution_context_has_empty_metadata() {
777749
778750 // execution_id and code should be empty since the plot was created
779751 // outside of an execute request's execution context
780- assert ! (
781- result. contains( "$execution_id" ) && result. contains( "[1] \" \" " ) ,
782- "execution_id should be empty, got:\n {result}"
783- ) ;
784- assert ! (
785- result. contains( "$code" ) && result. contains( "[1] \" \" " ) ,
786- "code should be empty, got:\n {result}"
787- ) ;
752+ assert ! ( result. contains( "$execution_id\n [1] \" \" " ) ) ;
753+ assert ! ( result. contains( "$code\n [1] \" \" " ) ) ;
788754}
789755
790756/// Test that `dev.hold()` suppresses intermediate plot output.
0 commit comments