Skip to content

Commit

Permalink
PM-3587: Bump mill version to 0.9.9 (#64)
Browse files Browse the repository at this point in the history
* CHORE: Bump mill version to 0.9.9

* PM-3587: Separate specs and props.

* PM-3587: Updated the readme with the testing split.

* PM-3587: Simplified the test module reference syntax.
  • Loading branch information
aakoshh authored Jul 26, 2021
1 parent 1ecab8f commit 9fff57b
Show file tree
Hide file tree
Showing 51 changed files with 59 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .mill-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.8.0
0.9.9
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ mill __.test
mill --watch metronome[2.13.4].rocksdb.test
```

To run a single test class, use the `.single` method with the full path to the spec:
To run a single test class, use the `.single` method with the full path to the spec. Note that `ScalaTest` tests are in the `specs` subdirectories while `ScalaCheck` ones are in `props`.

```console
mill __.storage.test.single io.iohk.metronome.storage.KVStoreStateSpec
mill __.storage.specs.single io.iohk.metronome.storage.KVStoreStateSpec
mill __.hotstuff.consensus.props.single io.iohk.metronome.hotstuff.consensus.basic.ProtocolStateProps
```

To experiment with the code, start an interactive session:
Expand All @@ -67,6 +68,12 @@ To experiment with the code, start an interactive session:
mill -i metronome[2.13.4].hotstuff.consensus.console
```

### Versions

You will need Java 11 to build.

The `mill` version is set in the `.mill-version` file or the `MILL_VERSION` env var. To build with Nix in sandbox environment, it's best to make sure that the build works with the version that Nix comes with, because after [this update](https://github.com/NixOS/nixpkgs/pull/130823) it's not going to dynamically download the one set in the project.

### Formatting the codebase

Please configure your editor to use `scalafmt` on save. CI will be configured to check formatting.
Expand Down
84 changes: 49 additions & 35 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,16 @@ class MetronomeModule(val crossScalaVersion: String) extends CrossScalaModule {
override def scalacOptions =
SubModule.this.scalacOptions

override def testFrameworks =
Seq(
"org.scalatest.tools.Framework",
"org.scalacheck.ScalaCheckFramework"
)
// Test modules might depend on each other for example to get `Arbitrary` instances.
def testModuleDeps: Seq[JavaModule] = Seq.empty

override def moduleDeps: Seq[JavaModule] =
super.moduleDeps ++ testModuleDeps
}

// Since mill 0.9.7 there can be only one `testFramework` per module.
trait SpecsModule extends TestModule {
override def testFramework = "org.scalatest.tools.Framework"

// It may be useful to see logs in tests.
override def moduleDeps: Seq[JavaModule] =
Expand All @@ -137,17 +142,25 @@ class MetronomeModule(val crossScalaVersion: String) extends CrossScalaModule {
// Alternatively, capture logs in memory with `InMemoryLogTracer`.
override def ivyDeps = Agg(
ivy"org.scalatest::scalatest:${VersionOf.scalatest}",
ivy"org.scalacheck::scalacheck:${VersionOf.scalacheck}",
ivy"ch.qos.logback:logback-classic:${VersionOf.logback}"
)

def single(args: String*) = T.command {
// ScalaCheck test
if (args.headOption.exists(_.endsWith("Props")))
super.runMain(args.head, args.tail: _*)
// ScalaTest test
else
super.runMain("org.scalatest.run", args: _*)
super.runMain("org.scalatest.run", args: _*)
}
}

trait PropsModule extends TestModule {
override def testFramework = "org.scalacheck.ScalaCheckFramework"

override def ivyDeps = Agg(
ivy"org.scalacheck::scalacheck:${VersionOf.scalacheck}"
)

def single(args: String*) = T.command {
// ScalaCheck test
super.runMain(args.head, args.tail: _*)
}
}
}
Expand All @@ -162,7 +175,7 @@ class MetronomeModule(val crossScalaVersion: String) extends CrossScalaModule {
ivy"io.monix::monix:${VersionOf.monix}"
)

object test extends TestModule
object specs extends SpecsModule
}

/** Storage abstractions, e.g. a generic key-value store. */
Expand All @@ -173,7 +186,7 @@ class MetronomeModule(val crossScalaVersion: String) extends CrossScalaModule {
ivy"org.scodec::scodec-core:${VersionOf.`scodec-core`}"
)

object test extends TestModule
object specs extends SpecsModule
}

/** Emit trace events, abstracting away logs and metrics.
Expand Down Expand Up @@ -203,7 +216,7 @@ class MetronomeModule(val crossScalaVersion: String) extends CrossScalaModule {
ivy"org.scodec::scodec-core:${VersionOf.`scodec-core`}"
)

object test extends TestModule
object specs extends SpecsModule
}

/** Generic Peer-to-Peer components that can multiplex protocols
Expand All @@ -220,10 +233,7 @@ class MetronomeModule(val crossScalaVersion: String) extends CrossScalaModule {
ivy"io.iohk::scalanet:${VersionOf.scalanet}"
)

object test extends TestModule {
override def moduleDeps: Seq[JavaModule] =
super.moduleDeps ++ Seq(logging)
}
object specs extends SpecsModule
}

/** General configuration parser, to be used by application modules. */
Expand All @@ -234,7 +244,7 @@ class MetronomeModule(val crossScalaVersion: String) extends CrossScalaModule {
ivy"io.circe::circe-parser:${VersionOf.circe}"
)

object test extends TestModule {
object specs extends SpecsModule {
override def ivyDeps = super.ivyDeps() ++ Agg(
ivy"io.circe::circe-generic:${VersionOf.circe}"
)
Expand All @@ -254,7 +264,8 @@ class MetronomeModule(val crossScalaVersion: String) extends CrossScalaModule {
override def moduleDeps: Seq[PublishModule] =
Seq(core, crypto)

object test extends TestModule
object props extends PropsModule
object specs extends SpecsModule
}

/** Expose forensics events via tracing. */
Expand All @@ -275,10 +286,10 @@ class MetronomeModule(val crossScalaVersion: String) extends CrossScalaModule {
hotstuff.forensics
)

object test extends TestModule {
override def moduleDeps: Seq[JavaModule] =
super.moduleDeps ++ Seq(hotstuff.consensus.test)
object props extends PropsModule {
override def testModuleDeps = Seq(hotstuff.consensus.props)
}
object specs extends SpecsModule
}
}

Expand All @@ -300,9 +311,11 @@ class MetronomeModule(val crossScalaVersion: String) extends CrossScalaModule {
override def moduleDeps: Seq[PublishModule] =
Seq(core, crypto, hotstuff.consensus)

object test extends TestModule {
override def moduleDeps: Seq[JavaModule] =
super.moduleDeps ++ Seq(hotstuff.consensus.test)
object props extends PropsModule {
override def testModuleDeps = Seq(hotstuff.consensus.props)
}
object specs extends SpecsModule {
override def testModuleDeps = Seq(checkpointing.models.props)
}
}

Expand All @@ -321,10 +334,10 @@ class MetronomeModule(val crossScalaVersion: String) extends CrossScalaModule {
override def moduleDeps: Seq[PublishModule] =
Seq(tracing, crypto, networking, checkpointing.models)

object test extends TestModule {
override def moduleDeps: Seq[JavaModule] =
super.moduleDeps ++ Seq(checkpointing.models.test)
object props extends PropsModule {
override def testModuleDeps = Seq(checkpointing.models.props)
}
object specs extends SpecsModule
}

/** Implements the checkpointing functionality, validation rules,
Expand All @@ -345,13 +358,16 @@ class MetronomeModule(val crossScalaVersion: String) extends CrossScalaModule {
checkpointing.interpreter
)

object test extends TestModule {
object props extends PropsModule {
override def moduleDeps: Seq[JavaModule] =
super.moduleDeps ++ Seq(
checkpointing.models.test,
hotstuff.service.test
checkpointing.models.props,
hotstuff.service.props
)
}
object specs extends SpecsModule {
override def testModuleDeps = Seq(checkpointing.models.props)
}
}

/** Executable application for running HotStuff and checkpointing as a stand-alone process,
Expand All @@ -372,8 +388,6 @@ class MetronomeModule(val crossScalaVersion: String) extends CrossScalaModule {
ivy"ch.qos.logback:logback-classic:${VersionOf.logback}",
ivy"io.iohk::scalanet-discovery:${VersionOf.scalanet}"
)

object test extends TestModule
}
}

Expand Down Expand Up @@ -412,7 +426,7 @@ class MetronomeModule(val crossScalaVersion: String) extends CrossScalaModule {
ivy"org.rocksdb:rocksdbjni:${VersionOf.rocksdb}"
)

object test extends TestModule {
object props extends PropsModule {
override def ivyDeps = super.ivyDeps() ++ Agg(
ivy"io.monix::monix:${VersionOf.monix}"
)
Expand Down
File renamed without changes.

0 comments on commit 9fff57b

Please sign in to comment.