Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Mill export for projects with just the test scope #3046

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ final case class MillProjectDescriptor(

val pureJava = !options.scalaOptions.addScalaLibrary.contains(true) &&
!options.scalaOptions.addScalaCompiler.contains(true) &&
sources.paths.forall(_._1.last.endsWith(".java")) &&
sources.inMemory.forall(_.generatedRelPath.last.endsWith(".java")) &&
sources.hasJava &&
!sources.hasScala &&
options.classPathOptions.allExtraDependencies.toSeq
.forall(_.value.nameAttributes == NoAttributes)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@ trait ExportCommonTestDefinitions { _: ScalaCliSuite & TestScalaVersionArgs =>
}
}

def justTestScope(): Unit = {
val expectedMessage = "exporting just the test scope actually works!"
prepareTestInputs(ExportTestProjects.justTestScope(expectedMessage))
.fromRoot { root =>
exportCommand(".").call(cwd = root)
val testRes = buildToolCommand(root, runTestsArgs*)
.call(cwd = root / outputDir)
val testOutput = testRes.out.text()
expect(testOutput.contains(expectedMessage))
}
}

private val scalaVersionsInDir: Seq[String] = Seq("2.12", "2.13", "2", "3", "3.lts")

if (runExportTests) {
Expand Down Expand Up @@ -123,5 +135,9 @@ trait ExportCommonTestDefinitions { _: ScalaCliSuite & TestScalaVersionArgs =>
}
}

test("just test scope") {
justTestScope()
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package scala.cli.integration

import com.eed3si9n.expecty.Expecty.expect

import scala.cli.integration.Constants.munitVersion

object ExportTestProjects {
def jvmTest(scalaVersion: String): TestInputs = {

Expand Down Expand Up @@ -324,4 +326,17 @@ object ExportTestProjects {
|}
|""".stripMargin
)

def justTestScope(msg: String): TestInputs = TestInputs(
os.rel / "MyTests.test.scala" ->
s"""//> using dep org.scalameta::munit::$munitVersion
|
|class MyTests extends munit.FunSuite {
| test("foo") {
| assert(2 + 2 == 4)
| println("$msg")
| }
|}
|""".stripMargin
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ abstract class ScalaCliSuite extends munit.FunSuite {
}
}

override def munitTimeout: Duration = new FiniteDuration(240, TimeUnit.SECONDS)
override def munitTimeout: Duration = new FiniteDuration(300, TimeUnit.SECONDS)

override def munitFixtures: List[Fixture[Unit]] = List(testStartEndLogger)
def group: ScalaCliSuite.TestGroup = ScalaCliSuite.TestGroup.Third
Expand Down
Loading