@@ -721,12 +721,14 @@ func TestRunGraph(t *testing.T) {
721
721
wantErrs []string
722
722
}{
723
723
{
724
+ name : "tasks executed in order" ,
724
725
nodes : []* TaskNode {
725
726
{Tasks : tasks ("a" , "b" )},
726
727
},
727
728
order : []string {"a" , "b" },
728
729
},
729
730
{
731
+ name : "nodes executed after dependencies" ,
730
732
nodes : []* TaskNode {
731
733
{Tasks : tasks ("c" ), In : []int {3 }},
732
734
{Tasks : tasks ("d" , "e" ), In : []int {3 }},
@@ -756,6 +758,7 @@ func TestRunGraph(t *testing.T) {
756
758
},
757
759
},
758
760
{
761
+ name : "task error interrupts node processing" ,
759
762
nodes : []* TaskNode {
760
763
{Tasks : tasks ("c" ), In : []int {2 }},
761
764
{Tasks : tasks ("d" ), In : []int {2 }, Out : []int {3 }},
@@ -781,6 +784,7 @@ func TestRunGraph(t *testing.T) {
781
784
},
782
785
},
783
786
{
787
+ name : "mid-task cancellation error interrupts node processing" ,
784
788
nodes : []* TaskNode {
785
789
{Tasks : tasks ("c" ), In : []int {2 }},
786
790
{Tasks : tasks ("d" ), In : []int {2 }, Out : []int {3 }},
@@ -796,15 +800,15 @@ func TestRunGraph(t *testing.T) {
796
800
case <- time .After (time .Second ):
797
801
t .Fatalf ("expected context" )
798
802
case <- ctx .Done ():
799
- t .Logf ("got cancelled context" )
800
- return fmt . Errorf ( "cancelled" )
803
+ t .Logf ("got canceled context" )
804
+ return ctx . Err ( )
801
805
}
802
806
return fmt .Errorf ("error A" )
803
807
}
804
808
return nil
805
809
},
806
810
want : []string {"a" , "b" , "c" },
807
- wantErrs : []string {"cancelled " },
811
+ wantErrs : []string {"context canceled " },
808
812
invariants : func (t * testing.T , got []string ) {
809
813
for _ , s := range got {
810
814
if s == "e" {
@@ -814,6 +818,7 @@ func TestRunGraph(t *testing.T) {
814
818
},
815
819
},
816
820
{
821
+ name : "task errors in parallel nodes both reported" ,
817
822
nodes : []* TaskNode {
818
823
{Tasks : tasks ("a" ), Out : []int {1 }},
819
824
{Tasks : tasks ("b" ), In : []int {0 }, Out : []int {2 , 4 , 8 }},
@@ -839,6 +844,26 @@ func TestRunGraph(t *testing.T) {
839
844
want : []string {"a" , "b" , "d1" , "d2" , "d3" },
840
845
wantErrs : []string {"error - c1" , "error - f" },
841
846
},
847
+ {
848
+ name : "cancelation without task errors is reported" ,
849
+ nodes : []* TaskNode {
850
+ {Tasks : tasks ("a" ), Out : []int {1 }},
851
+ {Tasks : tasks ("b" ), In : []int {0 }},
852
+ },
853
+ sleep : time .Millisecond ,
854
+ parallel : 1 ,
855
+ errorOn : func (t * testing.T , name string , ctx context.Context , cancelFn func ()) error {
856
+ if name == "a" {
857
+ cancelFn ()
858
+ time .Sleep (time .Second )
859
+ return nil
860
+ }
861
+ t .Fatalf ("task b should never run" )
862
+ return nil
863
+ },
864
+ want : []string {"a" },
865
+ wantErrs : []string {"context canceled" },
866
+ },
842
867
}
843
868
for _ , tt := range tests {
844
869
t .Run (tt .name , func (t * testing.T ) {
0 commit comments