Skip to content

Commit

Permalink
Replace aggregate with dependsOn for single task (#1452)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugo-vrijswijk authored Nov 12, 2023
1 parent f2f3394 commit c6d35ba
Show file tree
Hide file tree
Showing 21 changed files with 51 additions and 62 deletions.
26 changes: 15 additions & 11 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Dependencies.*
import Settings.*
import sbt.internal.ProjectMatrix

lazy val root = (project withId "stryker4s" in file("."))
.settings(
Expand Down Expand Up @@ -33,30 +34,26 @@ lazy val root = (project withId "stryker4s" in file("."))
)

lazy val core = (projectMatrix in file("modules") / "core")
.settings(commonSettings, coreSettings)
.settings(commonSettings, coreSettings, publishLocalDependsOn(api, testRunnerApi, testkit))
.dependsOn(api, testRunnerApi, testkit % Test)
.aggregate(api, testRunnerApi, testkit)
.jvmPlatform(scalaVersions = versions.crossScalaVersions)

lazy val commandRunner = (projectMatrix in file("modules") / "commandRunner")
.settings(commonSettings, commandRunnerSettings)
.settings(commonSettings, commandRunnerSettings, publishLocalDependsOn(core, testkit))
.dependsOn(core, testkit % Test)
.aggregate(core, testkit)
.jvmPlatform(scalaVersions = versions.crossScalaVersions)

// sbt plugins have to use Scala 2.12
lazy val sbtPlugin = (projectMatrix in file("modules") / "sbt")
.enablePlugins(SbtPlugin)
.defaultAxes(VirtualAxis.scalaPartialVersion("2.12"), VirtualAxis.jvm)
.settings(commonSettings, sbtPluginSettings)
.settings(commonSettings, sbtPluginSettings, publishLocalDependsOn(core))
.dependsOn(core)
.aggregate(core)
.jvmPlatform(scalaVersions = Seq(versions.scala212))

lazy val sbtTestRunner = (projectMatrix in file("modules") / "sbtTestRunner")
.settings(commonSettings, sbtTestRunnerSettings)
.settings(commonSettings, sbtTestRunnerSettings, publishLocalDependsOn(testRunnerApi))
.dependsOn(testRunnerApi)
.aggregate(testRunnerApi)
.jvmPlatform(scalaVersions = versions.fullCrossScalaVersions)

lazy val testRunnerApi = (projectMatrix in file("modules") / "testRunnerApi")
Expand All @@ -66,13 +63,20 @@ lazy val testRunnerApi = (projectMatrix in file("modules") / "testRunnerApi")
// Pure Java module with interfaces
lazy val api = (projectMatrix in file("modules") / "api")
.settings(apiSettings)
.jvmPlatform(false)
.jvmPlatform(autoScalaLibrary = false)

lazy val testkit = (projectMatrix in file("modules") / "testkit")
.settings(commonSettings, testkitSettings)
.settings(commonSettings, testkitSettings, publishLocalDependsOn(api))
.dependsOn(api)
.aggregate(api)
.jvmPlatform(scalaVersions = versions.crossScalaVersions)

lazy val writeHooks = taskKey[Unit]("Write git hooks")
Global / writeHooks := GitHooks(file("git-hooks"), file(".git/hooks"), streams.value.log)

def publishLocalDependsOn(matrixes: ProjectMatrix*) = {
val projectRefs = matrixes.flatMap(_.projectRefs)
Seq(
publishLocal := publishLocal.dependsOn(projectRefs.map(_ / publishLocal)*).value,
publishM2 := publishM2.dependsOn(projectRefs.map(_ / publishM2)*).value
)
}
1 change: 0 additions & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ We support mutation testing Stryker4s with Stryker4s! The easiest way is to foll

1. Run `sbt publishPluginLocal` to publish a test snapshot as `0.0.0-TEST-SNAPSHOT` version to your local ivy repository.
2. Add the sbt plugin to `project/plugins.sbt` with `0.0.0-TEST-SNAPSHOT` as the version number.
1. If the project you are running against is not a 2.13 project, publish `stryker4s-api` and `stryker4s-sbt-testrunner` manually for your appropriate version (.e.g. `sbt "testRunnerApi3/publishLocal; sbtTestRunner3/publishLocal"`)
3. Run stryker4s as described in the readme.

## Learning resources
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package stryker4s.model

import cats.syntax.option.*
import stryker4s.api.testprocess.CoverageReport
import stryker4s.testrunner.api.testprocess.CoverageReport

import scala.concurrent.duration.FiniteDuration

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import cats.effect.{Deferred, IO, Ref, Resource}
import cats.syntax.traverse.*
import fansi.Color.*
import mutationtesting.{MutantResult, MutantStatus}
import stryker4s.api.testprocess.CoverageReport
import stryker4s.config.Config
import stryker4s.model.{InitialTestRunCoverageReport, InitialTestRunResult, MutantWithId, NoCoverageInitialTestRun}
import stryker4s.scalatest.LogMatchers
import stryker4s.testrunner.api.testprocess.CoverageReport
import stryker4s.testutil.stubs.TestRunnerStub
import stryker4s.testutil.{Stryker4sIOSuite, TestData}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package stryker4s.model
import cats.syntax.option.*
import sbt.testing.Framework as SbtFramework
import sbt.{TestDefinition as SbtTestDefinition, TestFramework as SbtTestFramework, Tests}
import stryker4s.api.testprocess.*
import stryker4s.testrunner.api.testprocess.*

trait TestInterfaceMapper {
def toApiTestGroups(frameworks: Seq[SbtFramework], sbtTestGroups: Seq[Tests.Group]): Array[TestGroup] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import fs2.io.net.Network
import mutationtesting.{MutantResult, MutantStatus}
import sbt.Tests
import sbt.testing.Framework
import stryker4s.api.testprocess.*
import stryker4s.config.Config
import stryker4s.extension.DurationExtensions.*
import stryker4s.log.Logger
import stryker4s.model.*
import stryker4s.run.TestRunner
import stryker4s.run.process.ProcessResource
import stryker4s.testrunner.api.testprocess.*

import java.net.ConnectException
import java.util.concurrent.TimeUnit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import com.google.protobuf.UInt32Value
import fs2.Chunk
import fs2.io.net.Socket
import scodec.bits.BitVector
import stryker4s.api.testprocess.{Request, RequestMessage, Response, ResponseMessage}
import stryker4s.log.Logger
import stryker4s.testrunner.api.testprocess.{Request, RequestMessage, Response, ResponseMessage}

sealed trait TestRunnerConnection {
def sendMessage(request: Request): IO[Response]
Expand Down
2 changes: 1 addition & 1 deletion modules/sbt/src/sbt-test/sbt-stryker4s/test-1/build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
scalaVersion := "2.12.18"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.13" % Test // scala-steward:off
libraryDependencies += "org.scalameta" %% "munit" % "1.0.0-M10" % Test

// Reproduce https://github.com/stryker-mutator/stryker4s/issues/726
(Compile / scalaSource) := baseDirectory.value / "src" / "main" / "scala"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package example

import org.scalatest.matchers.should.Matchers
import org.scalatest.funspec.AnyFunSpec

class ExampleTest extends AnyFunSpec with Matchers {
describe("Person") {
it("be able to drink with age 18") {
Example.canDrink(18) should be(true)
}
class ExampleTest extends munit.FunSuite {
test("be able to drink with age 18") {
assert(Example.canDrink(18))
}

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package example

import org.scalatest.matchers.should.Matchers
import org.scalatest.funspec.AnyFunSpec

class IgnoreMeTest extends AnyFunSpec with Matchers {
describe("Person") {
it("not be able to drink with age 16") {
fail("This test should never be run because of the test-filter")
}
class IgnoreMeTest extends munit.FunSuite {
test("not be able to drink with age 16") {
fail("This test should never be run because of the test-filter")
}

}
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
package example

import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

class Spec extends AnyFlatSpec with Matchers {
it should "check for a's in mutatesOkay" in {
TestObj.mutatesOkay(" a ") shouldBe true
TestObj.mutatesOkay(" b ") shouldBe false
class Spec extends munit.FunSuite {
test("check for a's in mutatesOkay") {
assert(TestObj.mutatesOkay(" a "))
assert(!TestObj.mutatesOkay(" b "))
}

it should "return false if a file does not exists" in {
TestObj.test2("/home/blah/fake") shouldBe false
test("return false if a file does not exists") {
assert(!TestObj.test2("/home/blah/fake"))
}

it should "check for b's in alsoMutatesOkay" in {
TestObj.alsoMutatesOkay(" b ") shouldBe true
TestObj.alsoMutatesOkay(" a ") shouldBe false
test("check for b's in alsoMutatesOkay") {
assert(TestObj.alsoMutatesOkay(" b "))
assert(!TestObj.alsoMutatesOkay(" a "))
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package example

import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

class Spec2 extends AnyFlatSpec with Matchers {
it should "check the string" in {
TestObj2.str("hi") shouldBe false
TestObj2.str("blah") shouldBe true
class Spec2 extends munit.FunSuite {
test("check the string") {
assert(!TestObj2.str("hi"))
assert(TestObj2.str("blah"))
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import stryker4s.api.testprocess.CoverageTestNameMap
import stryker4s.sbt.testrunner.TestInterfaceMapper
import stryker4s.testrunner.api.testprocess.CoverageTestNameMap

import java.util.concurrent.atomic.{AtomicBoolean, AtomicInteger, AtomicReference}
import java.util.concurrent.{ConcurrentLinkedQueue, TimeUnit}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package stryker4s.sbt.testrunner

import stryker4s.api.testprocess.TestProcessProperties
import stryker4s.testrunner.api.testprocess.TestProcessProperties

object Context {
def resolveSocketConfig(): Int = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package stryker4s.sbt.testrunner

import sbt.testing.Status
import stryker4s.api.testprocess.*
import stryker4s.coverage.{collectCoverage, timed}
import stryker4s.testrunner.api.testprocess.*

import scala.concurrent.duration.FiniteDuration
import scala.util.control.NonFatal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package stryker4s.sbt.testrunner

import com.google.protobuf.CodedInputStream
import stryker4s.api.testprocess.RequestMessage
import stryker4s.testrunner.api.testprocess.RequestMessage

import java.net.{InetAddress, ServerSocket, Socket}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package stryker4s.sbt.testrunner

import sbt.testing.{Status, TaskDef}
import stryker4s.api.testprocess.*
import stryker4s.testrunner.api.testprocess.*

/** Maps stryker4s-api test-interface models to sbt-testinterface models
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package stryker4s.sbt.testrunner

import sbt.testing.{Event, EventHandler, Framework, Status, Task}
import stryker4s.api.testprocess.*
import stryker4s.testrunner.api.testprocess.*

import java.util.concurrent.atomic.{AtomicInteger, AtomicReference}
import java.util.function.UnaryOperator
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

package stryker4s.api;
package stryker4s.testrunner.api;

import "scalapb/scalapb.proto";
option (scalapb.options) = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package stryker4s.api.testprocess
package stryker4s.testrunner.api.testprocess

case class CoverageReport(report: Map[Int, Seq[String]]) extends AnyVal

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package stryker4s.api.testprocess
package stryker4s.testrunner.api.testprocess

/** Keys for system properties passed to the testprocess
*/
Expand Down

0 comments on commit c6d35ba

Please sign in to comment.