@@ -12,7 +12,7 @@ use owo_colors::Style;
1212use tokio:: io:: { AsyncWrite , AsyncWriteExt as _} ;
1313use vite_path:: AbsolutePath ;
1414use vite_str:: Str ;
15- use vite_task_plan:: { ExecutionItem , ExecutionItemDisplay , ExecutionItemKind , LeafExecutionKind } ;
15+ use vite_task_plan:: { ExecutionItemDisplay , LeafExecutionKind } ;
1616
1717use super :: {
1818 CACHE_MISS_STYLE , COMMAND_STYLE , ColorizeExt , ExitStatus , GraphExecutionReporter ,
@@ -119,14 +119,13 @@ pub struct LabeledGraphReporter {
119119impl GraphExecutionReporter for LabeledGraphReporter {
120120 fn new_leaf_execution (
121121 & mut self ,
122- item : & ExecutionItem ,
122+ display : & ExecutionItemDisplay ,
123+ leaf_kind : & LeafExecutionKind ,
123124 all_ancestors_single_node : bool ,
124125 ) -> Box < dyn LeafExecutionReporter > {
125- let display = item. execution_item_display . clone ( ) ;
126- let stdio_suggestion = match & item. kind {
127- ExecutionItemKind :: Leaf ( LeafExecutionKind :: Spawn ( _) ) if all_ancestors_single_node => {
128- StdioSuggestion :: Inherited
129- }
126+ let display = display. clone ( ) ;
127+ let stdio_suggestion = match leaf_kind {
128+ LeafExecutionKind :: Spawn ( _) if all_ancestors_single_node => StdioSuggestion :: Inherited ,
130129 _ => StdioSuggestion :: Piped ,
131130 } ;
132131
@@ -552,6 +551,8 @@ fn format_summary(
552551
553552#[ cfg( test) ]
554553mod tests {
554+ use vite_task_plan:: ExecutionItemKind ;
555+
555556 use super :: * ;
556557 use crate :: session:: {
557558 event:: CacheDisabledReason ,
@@ -561,25 +562,36 @@ mod tests {
561562 } ,
562563 } ;
563564
565+ /// Extract the `LeafExecutionKind` from a test fixture item.
566+ /// Panics if the item is not a leaf (test fixtures always produce leaves).
567+ fn leaf_kind ( item : & vite_task_plan:: ExecutionItem ) -> & LeafExecutionKind {
568+ match & item. kind {
569+ ExecutionItemKind :: Leaf ( kind) => kind,
570+ ExecutionItemKind :: Expanded ( _) => panic ! ( "test fixture item must be a Leaf" ) ,
571+ }
572+ }
573+
564574 fn build_labeled_leaf (
565- item : & ExecutionItem ,
575+ display : & ExecutionItemDisplay ,
576+ leaf_kind : & LeafExecutionKind ,
566577 all_ancestors_single_node : bool ,
567578 ) -> Box < dyn LeafExecutionReporter > {
568579 let builder =
569580 Box :: new ( LabeledReporterBuilder :: new ( test_path ( ) , Box :: new ( tokio:: io:: sink ( ) ) ) ) ;
570581 let mut reporter = builder. build ( ) ;
571- reporter. new_leaf_execution ( item , all_ancestors_single_node)
582+ reporter. new_leaf_execution ( display , leaf_kind , all_ancestors_single_node)
572583 }
573584
574585 #[ expect(
575586 clippy:: future_not_send,
576587 reason = "LeafExecutionReporter futures are !Send in single-threaded reporter tests"
577588 ) ]
578589 async fn suggestion_for (
579- item : & ExecutionItem ,
590+ display : & ExecutionItemDisplay ,
591+ leaf_kind : & LeafExecutionKind ,
580592 all_ancestors_single_node : bool ,
581593 ) -> StdioSuggestion {
582- let mut leaf = build_labeled_leaf ( item , all_ancestors_single_node) ;
594+ let mut leaf = build_labeled_leaf ( display , leaf_kind , all_ancestors_single_node) ;
583595 let stdio_config =
584596 leaf. start ( CacheStatus :: Disabled ( CacheDisabledReason :: NoCacheMetadata ) ) . await ;
585597 stdio_config. suggestion
@@ -588,24 +600,40 @@ mod tests {
588600 #[ tokio:: test]
589601 async fn spawn_with_all_single_node_ancestors_suggests_inherited ( ) {
590602 let task = spawn_task ( "build" ) ;
591- assert_eq ! ( suggestion_for( & task. items[ 0 ] , true ) . await , StdioSuggestion :: Inherited ) ;
603+ let item = & task. items [ 0 ] ;
604+ assert_eq ! (
605+ suggestion_for( & item. execution_item_display, leaf_kind( item) , true ) . await ,
606+ StdioSuggestion :: Inherited
607+ ) ;
592608 }
593609
594610 #[ tokio:: test]
595611 async fn spawn_without_all_single_node_ancestors_suggests_piped ( ) {
596612 let task = spawn_task ( "build" ) ;
597- assert_eq ! ( suggestion_for( & task. items[ 0 ] , false ) . await , StdioSuggestion :: Piped ) ;
613+ let item = & task. items [ 0 ] ;
614+ assert_eq ! (
615+ suggestion_for( & item. execution_item_display, leaf_kind( item) , false ) . await ,
616+ StdioSuggestion :: Piped
617+ ) ;
598618 }
599619
600620 #[ tokio:: test]
601621 async fn in_process_leaf_suggests_piped_even_with_single_node_ancestors ( ) {
602622 let task = in_process_task ( "echo" ) ;
603- assert_eq ! ( suggestion_for( & task. items[ 0 ] , true ) . await , StdioSuggestion :: Piped ) ;
623+ let item = & task. items [ 0 ] ;
624+ assert_eq ! (
625+ suggestion_for( & item. execution_item_display, leaf_kind( item) , true ) . await ,
626+ StdioSuggestion :: Piped
627+ ) ;
604628 }
605629
606630 #[ tokio:: test]
607631 async fn in_process_leaf_suggests_piped_without_single_node_ancestors ( ) {
608632 let task = in_process_task ( "echo" ) ;
609- assert_eq ! ( suggestion_for( & task. items[ 0 ] , false ) . await , StdioSuggestion :: Piped ) ;
633+ let item = & task. items [ 0 ] ;
634+ assert_eq ! (
635+ suggestion_for( & item. execution_item_display, leaf_kind( item) , false ) . await ,
636+ StdioSuggestion :: Piped
637+ ) ;
610638 }
611639}
0 commit comments