11package stryker4s .mill
22
33import cats .effect .IO
4+ import cats .syntax .all .*
5+ import ciris .ConfigValue
46import fs2 .io .file .Path
7+ import stryker4s .config .*
58import stryker4s .testkit .Stryker4sIOSuite
9+ import sttp .client4 .UriContext
610
711import scala .concurrent .duration .*
812import scala .meta .dialects
@@ -40,15 +44,15 @@ class MillConfigSourceTest extends Stryker4sIOSuite {
4044 val config = new MillConfigSource [IO ](
4145 baseDirValue = Path (" /tmp/project" ),
4246 mutateValue = Some (Seq (" src/main/scala/**.scala" )),
43- filesValue = None ,
47+ filesValue = Some ( Seq ( " src/main/scala/** " )) ,
4448 testFilterValue = Some (Seq (" *MyTest" )),
4549 reportersValue = Some (Seq (" html" , " console" )),
4650 excludedMutationsValue = Some (Seq (" BooleanLiteral" )),
4751 thresholdsHighValue = Some (85 ),
4852 thresholdsLowValue = Some (60 ),
4953 thresholdsBreakValue = Some (0 ),
50- dashboardBaseUrlValue = None ,
51- dashboardReportTypeValue = None ,
54+ dashboardBaseUrlValue = Some ( " https://dashboard.stryker-mutator.io " ) ,
55+ dashboardReportTypeValue = Some ( " full " ) ,
5256 dashboardProjectValue = Some (" github.com/foo/bar" ),
5357 dashboardVersionValue = Some (" main" ),
5458 dashboardModuleValue = Some (" my-module" ),
@@ -66,24 +70,69 @@ class MillConfigSourceTest extends Stryker4sIOSuite {
6670
6771 for {
6872 _ <- config.mutate.load.assertEquals(Seq (" src/main/scala/**.scala" ))
73+ _ <- config.files.load.assertEquals(Seq (" src/main/scala/**" ))
6974 _ <- config.testFilter.load.assertEquals(Seq (" *MyTest" ))
75+ _ <- config.reporters.load.assertEquals(Seq [ReporterType ](Html , Console ))
76+ _ <- config.excludedMutations.load.assertEquals(Seq (ExcludedMutation (" BooleanLiteral" )))
7077 _ <- config.thresholdsHigh.load.assertEquals(85 )
78+ _ <- config.thresholdsLow.load.assertEquals(60 )
79+ _ <- config.thresholdsBreak.load.assertEquals(0 )
80+ _ <- config.dashboardBaseUrl.load.assertEquals(uri " https://dashboard.stryker-mutator.io " )
81+ _ <- config.dashboardReportType.load.assertEquals(Full : DashboardReportType )
7182 _ <- config.dashboardProject.load.assertEquals(Some (" github.com/foo/bar" ))
83+ _ <- config.dashboardVersion.load.assertEquals(Some (" main" ))
7284 _ <- config.dashboardModule.load.assertEquals(Some (" my-module" ))
7385 _ <- config.timeout.load.assertEquals(5 .seconds)
86+ _ <- config.timeoutFactor.load.assertEquals(1.5 )
87+ _ <- config.maxTestRunnerReuse.load.assertEquals(Some (10 ))
88+ _ <- config.scalaDialect.load.assertEquals(dialects.Scala3 )
7489 _ <- config.concurrency.load.assertEquals(4 )
90+ _ <- config.debugLogTestRunnerStdout.load.assertEquals(true )
91+ _ <- config.debugDebugTestRunner.load.assertEquals(false )
92+ _ <- config.staticTmpDir.load.assertEquals(false )
7593 _ <- config.cleanTmpDir.load.assertEquals(true )
94+ _ <- config.openReport.load.assertEquals(false )
7695 } yield ()
7796 }
7897
7998 test(" should make the baseDir absolute" ) {
8099 emptyConfigSource.baseDir.load.assertEquals(Path (" /tmp/project" ).absolute)
81100 }
82101
83- test(" missing values are reported as missing" ) {
84- emptyConfigSource.thresholdsHigh.attempt
85- .map(_.leftValue.messages.loneElement)
86- .assertEquals(" Missing mill config strykerThresholdsHigh" )
102+ test(" missing values are reported as missing with their mill config key" ) {
103+ val source = emptyConfigSource
104+ // Every value-backed config def should report the exact mill build key it reads from when absent
105+ val cases : List [(ConfigValue [IO , ? ], String )] = List (
106+ source.mutate -> " strykerMutate" ,
107+ source.files -> " strykerFiles" ,
108+ source.testFilter -> " strykerTestFilter" ,
109+ source.reporters -> " strykerReporters" ,
110+ source.excludedMutations -> " strykerExcludedMutations" ,
111+ source.thresholdsHigh -> " strykerThresholdsHigh" ,
112+ source.thresholdsLow -> " strykerThresholdsLow" ,
113+ source.thresholdsBreak -> " strykerThresholdsBreak" ,
114+ source.dashboardBaseUrl -> " strykerDashboardBaseUrl" ,
115+ source.dashboardReportType -> " strykerDashboardReportType" ,
116+ source.dashboardProject -> " strykerDashboardProject" ,
117+ source.dashboardVersion -> " strykerDashboardVersion" ,
118+ source.dashboardModule -> " strykerDashboardModule" ,
119+ source.timeout -> " strykerTimeout" ,
120+ source.timeoutFactor -> " strykerTimeoutFactor" ,
121+ source.maxTestRunnerReuse -> " strykerMaxTestRunnerReuse" ,
122+ source.scalaDialect -> " strykerScalaDialect" ,
123+ source.concurrency -> " strykerConcurrency" ,
124+ source.debugLogTestRunnerStdout -> " strykerDebugLogTestRunnerStdout" ,
125+ source.debugDebugTestRunner -> " strykerDebugDebugTestRunner" ,
126+ source.staticTmpDir -> " strykerStaticTmpDir" ,
127+ source.cleanTmpDir -> " strykerCleanTmpDir" ,
128+ source.openReport -> " strykerOpenReport"
129+ )
130+
131+ cases.traverse_ { case (configValue, key) =>
132+ configValue.attempt
133+ .map(_.leftValue.messages.loneElement)
134+ .assertEquals(s " Missing mill config $key" )
135+ }
87136 }
88137
89138 test(" fails on values not supported by the mill plugin" ) {
0 commit comments