Skip to content

Commit f8450b2

Browse files
committed
Support the --test flag with the publish & publish local sub-commands
1 parent fdd08e1 commit f8450b2

File tree

9 files changed

+363
-290
lines changed

9 files changed

+363
-290
lines changed

modules/build/src/main/scala/scala/build/Build.scala

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,13 @@ object Build {
318318

319319
val baseOptions = overrideOptions.orElse(sharedOptions)
320320

321-
val scopedSources = value(crossSources.scopedSources(baseOptions))
321+
val scopedSources: ScopedSources = value(crossSources.scopedSources(baseOptions))
322322

323-
val mainSources =
323+
val mainSources: Sources =
324324
value(scopedSources.sources(Scope.Main, baseOptions, inputs.workspace, logger))
325325
val mainOptions = mainSources.buildOptions
326326

327-
val testSources =
327+
val testSources: Sources =
328328
value(scopedSources.sources(Scope.Test, baseOptions, inputs.workspace, logger))
329329
val testOptions = testSources.buildOptions
330330

@@ -370,9 +370,7 @@ object Build {
370370

371371
def testBuildOpt(doc: Boolean = false): Either[BuildException, Option[Build]] = either {
372372
if (buildTests) {
373-
val actualCompilerOpt =
374-
if (doc) docCompilerOpt
375-
else Some(compiler)
373+
val actualCompilerOpt = if doc then docCompilerOpt else Some(compiler)
376374
actualCompilerOpt match {
377375
case None => None
378376
case Some(actualCompiler) =>
@@ -384,7 +382,10 @@ object Build {
384382
extraClassPath = Seq(s.output)
385383
)
386384
)
387-
val testOptions0 = extraTestOptions.orElse(testOptions)
385+
val testOptions0 =
386+
extraTestOptions
387+
.orElse(testOptions)
388+
.copy(scalaOptions = mainOptions.scalaOptions)
388389
val isScala2 =
389390
value(testOptions0.scalaParams).exists(_.scalaVersion.startsWith("2."))
390391
val finalSources = if doc && isScala2 then
@@ -676,10 +677,8 @@ object Build {
676677
): Either[BuildException, Unit] = {
677678
val (errors, otherDiagnostics) = options.validate.partition(_.severity == Severity.Error)
678679
logger.log(otherDiagnostics)
679-
if (errors.nonEmpty)
680-
Left(CompositeBuildException(errors.map(new ValidationException(_))))
681-
else
682-
Right(())
680+
if errors.nonEmpty then Left(CompositeBuildException(errors.map(new ValidationException(_))))
681+
else Right(())
683682
}
684683

685684
def watch(

0 commit comments

Comments
 (0)