@@ -942,3 +942,160 @@ func getFeaturesForTest() []features.Feature {
942942 }).Feature ()
943943 return []features.Feature {f1 , f2 }
944944}
945+
946+ // TestEnv_FailFast_WithSkip tests that skip does not trigger fail-fast behavior.
947+ func TestEnv_FailFast_WithSkip (t * testing.T ) {
948+ tests := []struct {
949+ name string
950+ setup func (* testing.T ) []string
951+ expected []string
952+ }{
953+ {
954+ name : "skip via skip-assessment flag with fail-fast should continue" ,
955+ expected : []string {
956+ "assess-2" ,
957+ },
958+ setup : func (t * testing.T ) (val []string ) {
959+ // Configure fail-fast and skip first assessment via regex
960+ env := NewWithConfig (envconf .New ().WithFailFast ().WithSkipAssessmentRegex ("assess-1" ))
961+ f := features .New ("test-feat" ).
962+ Assess ("assess-1" , func (ctx context.Context , t * testing.T , _ * envconf.Config ) context.Context {
963+ val = append (val , "assess-1" )
964+ return ctx
965+ }).
966+ Assess ("assess-2" , func (ctx context.Context , t * testing.T , _ * envconf.Config ) context.Context {
967+ val = append (val , "assess-2" )
968+ return ctx
969+ })
970+ _ = env .Test (t , f .Feature ())
971+ return
972+ },
973+ },
974+ {
975+ name : "skip via t.Skip in assessment with fail-fast should continue" ,
976+ expected : []string {
977+ "assess-2" ,
978+ },
979+ setup : func (t * testing.T ) (val []string ) {
980+ // Configure fail-fast, user calls t.Skip() in first assessment
981+ env := NewWithConfig (envconf .New ().WithFailFast ())
982+ f := features .New ("test-feat" ).
983+ Assess ("assess-1" , func (ctx context.Context , t * testing.T , _ * envconf.Config ) context.Context {
984+ t .Skip ("skipping this assessment" )
985+ val = append (val , "assess-1" )
986+ return ctx
987+ }).
988+ Assess ("assess-2" , func (ctx context.Context , t * testing.T , _ * envconf.Config ) context.Context {
989+ val = append (val , "assess-2" )
990+ return ctx
991+ })
992+ _ = env .Test (t , f .Feature ())
993+ return
994+ },
995+ },
996+ {
997+ name : "multiple skips with fail-fast should continue to all non-skipped" ,
998+ expected : []string {
999+ "assess-2" ,
1000+ "assess-4" ,
1001+ },
1002+ setup : func (t * testing.T ) (val []string ) {
1003+ // Configure fail-fast, skip assessments 1 and 3
1004+ env := NewWithConfig (envconf .New ().WithFailFast ().WithSkipAssessmentRegex ("assess-[13]" ))
1005+ f := features .New ("test-feat" ).
1006+ Assess ("assess-1" , func (ctx context.Context , t * testing.T , _ * envconf.Config ) context.Context {
1007+ val = append (val , "assess-1" )
1008+ return ctx
1009+ }).
1010+ Assess ("assess-2" , func (ctx context.Context , t * testing.T , _ * envconf.Config ) context.Context {
1011+ val = append (val , "assess-2" )
1012+ return ctx
1013+ }).
1014+ Assess ("assess-3" , func (ctx context.Context , t * testing.T , _ * envconf.Config ) context.Context {
1015+ val = append (val , "assess-3" )
1016+ return ctx
1017+ }).
1018+ Assess ("assess-4" , func (ctx context.Context , t * testing.T , _ * envconf.Config ) context.Context {
1019+ val = append (val , "assess-4" )
1020+ return ctx
1021+ })
1022+ _ = env .Test (t , f .Feature ())
1023+ return
1024+ },
1025+ },
1026+ {
1027+ name : "pass without fail-fast continues normally" ,
1028+ expected : []string {
1029+ "assess-1" ,
1030+ "assess-2" ,
1031+ },
1032+ setup : func (t * testing.T ) (val []string ) {
1033+ // No fail-fast, both assessments should run
1034+ env := newTestEnv ()
1035+ f := features .New ("test-feat" ).
1036+ Assess ("assess-1" , func (ctx context.Context , t * testing.T , _ * envconf.Config ) context.Context {
1037+ val = append (val , "assess-1" )
1038+ return ctx
1039+ }).
1040+ Assess ("assess-2" , func (ctx context.Context , t * testing.T , _ * envconf.Config ) context.Context {
1041+ val = append (val , "assess-2" )
1042+ return ctx
1043+ })
1044+ _ = env .Test (t , f .Feature ())
1045+ return
1046+ },
1047+ },
1048+ {
1049+ name : "skip in first feature with fail-fast should continue to second feature" ,
1050+ expected : []string {
1051+ "feat1-assess-2" ,
1052+ "feat2-assess-1" ,
1053+ "feat2-assess-2" ,
1054+ },
1055+ setup : func (t * testing.T ) (val []string ) {
1056+ // Configure fail-fast, first feature has skipped assessment
1057+ env := NewWithConfig (envconf .New ().WithFailFast ())
1058+ feat1 := features .New ("skip" ).
1059+ Assess ("Assess 1" , func (ctx context.Context , t * testing.T , _ * envconf.Config ) context.Context {
1060+ t .Skipf ("skipping Assess 1" )
1061+ val = append (val , "feat1-assess-1" )
1062+ return ctx
1063+ }).
1064+ Assess ("Assess 2" , func (ctx context.Context , t * testing.T , _ * envconf.Config ) context.Context {
1065+ val = append (val , "feat1-assess-2" )
1066+ return ctx
1067+ }).
1068+ Feature ()
1069+
1070+ feat2 := features .New ("succeed" ).
1071+ Assess ("Assess 1" , func (ctx context.Context , t * testing.T , _ * envconf.Config ) context.Context {
1072+ val = append (val , "feat2-assess-1" )
1073+ return ctx
1074+ }).
1075+ Assess ("Assess 2" , func (ctx context.Context , t * testing.T , _ * envconf.Config ) context.Context {
1076+ val = append (val , "feat2-assess-2" )
1077+ return ctx
1078+ }).
1079+ Feature ()
1080+
1081+ _ = env .Test (t , feat1 , feat2 )
1082+ return
1083+ },
1084+ },
1085+ }
1086+
1087+ for _ , test := range tests {
1088+ t .Run (test .name , func (t * testing.T ) {
1089+ result := test .setup (t )
1090+ if len (test .expected ) != len (result ) {
1091+ t .Fatalf ("Expected:\n %v but got result:\n %v" , test .expected , result )
1092+ }
1093+ for i := range test .expected {
1094+ if result [i ] != test .expected [i ] {
1095+ t .Errorf ("Expected:\n %v but got result:\n %v" , test .expected , result )
1096+ break
1097+ }
1098+ }
1099+ })
1100+ }
1101+ }
0 commit comments