Skip to content
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
7 changes: 5 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ These are the main components of the project.
corpus of published Java libraries.
- `scip-java/src/main/kotlin`: implementation of the `scip-java` command-line
interface.
- `scip-java/src/test`: build-tool integration tests and fixtures for the
`scip-java` command-line interface.
- `build.sbt`: the sbt build definition.
- `project/plugins.sbt`: plugins for the sbt build.

Expand All @@ -51,7 +53,7 @@ These are the main components of the project.
| `sbt` | terminal | Start interactive sbt shell with Java 11 (run from `nix develop`). Takes a while to load on the first run. |
| `unit/test` | sbt | Run fast unit tests. |
| `~unit/test` | sbt | Start watch mode to run tests on file save, good for local edit-and-test workflows. |
| `buildTools/test` | sbt | Run slow build tool tests (Gradle, Maven). |
| `cli/test` | sbt | Run slow build tool tests (Gradle, Maven). |
| `snapshots/testOnly tests.MinimizedSnapshotScipTest` | sbt | Runs fast snapshot tests. Indexes a small set of files under `tests/minimized`. |
| `snapshots/test` | sbt | Runs all snapshot tests. |
| `snapshots/run` | sbt | Update only the Java snapshot goldens under `tests/snapshots`. |
Expand Down Expand Up @@ -93,4 +95,5 @@ snapshot suite is a JUnit `@TestFactory` that emits one dynamic test per
generated document, comparing it against the committed goldens under
`tests/snapshots/src/main/generated`
([snapshot testing](https://jestjs.io/docs/en/snapshot-testing) is heavily used
in this codebase). Build-tool tests (`tests/buildTools`) are written in Kotlin.
in this codebase). Build-tool tests (`scip-java/src/test`) are written in
Kotlin.
42 changes: 16 additions & 26 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@ lazy val cli = project
// sbt invokes it directly (e.g. from the scip-kotlinc snapshots
// task) so it cannot kill the surrounding sbt process.
Compile / run / fork := true,
Test / fork := true,
// Our CI set up is a couple of measly vCPUs so parallelising tests there makes
// everything worse.
Test / testForkedParallel := !sys.env.contains("CI"),
// The SCIP build tool drives javac in-process; on JDK 17+ this requires
// opening the JDK-internal javac packages.
Test / javaOptions ++= javacModuleOptions.map(_.stripPrefix("-J")),
// Pin the JDK version embedded in stdlib SCIP symbols so output is stable.
Test / javaOptions += "-Dscip.jdk.version=11",
libraryDependencies ++=
List(
"com.github.ajalt.clikt" % "clikt-jvm" % V.clikt,
Expand All @@ -195,6 +204,13 @@ lazy val cli = project
"org.jetbrains.kotlin" % "kotlin-scripting-dependencies-maven" %
V.kotlinVersion
),
libraryDependencies ++=
Seq(
"org.jetbrains.kotlin" % "kotlin-test" % V.kotlinVersion % Test,
"org.jetbrains.kotlin" % "kotlin-test-junit5" % V.kotlinVersion % Test,
"com.github.sbt.junit" % "jupiter-interface" %
JupiterKeys.jupiterVersion.value % Test
),
(Compile / resourceGenerators) +=
Def
.task {
Expand Down Expand Up @@ -450,32 +466,6 @@ def javacModuleOptions = List(
"-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"
)

lazy val buildTools = project
.in(file("tests/buildTools"))
.enablePlugins(KotlinPlugin)
.settings(
publish / skip := true,
kotlinVersion := V.kotlinVersion,
kotlincJvmTarget := "11",
Test / fork := true,
// Our CI set up is a couple of measly vCPUs so parallelising tests there makes
// everything worse
Test / testForkedParallel := !sys.env.contains("CI"),
// The SCIP build tool drives javac in-process; on JDK 17+ this requires
// opening the JDK-internal javac packages.
Test / javaOptions ++= javacModuleOptions.map(_.stripPrefix("-J")),
// Pin the JDK version embedded in stdlib SCIP symbols so output is stable.
Test / javaOptions += "-Dscip.jdk.version=11",
libraryDependencies ++=
Seq(
"org.jetbrains.kotlin" % "kotlin-test" % V.kotlinVersion % Test,
"org.jetbrains.kotlin" % "kotlin-test-junit5" % V.kotlinVersion % Test,
"com.github.sbt.junit" % "jupiter-interface" %
JupiterKeys.jupiterVersion.value % Test
)
)
.dependsOn(cli)

lazy val snapshots = project
.in(file("tests/snapshots"))
.settings(
Expand Down
11 changes: 6 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,26 @@
cd ${./.}
# Exclude minimized fixtures and generated SCIP snapshot goldens
# (coupled to exact line/column annotations), the standalone example
# projects, and the buildTools test fixtures: these all mirror
# projects, and the scip-java build-tool test fixtures: these all mirror
# real-world project layouts that must not be reformatted here.
find . -name '*.java' \
-not -path './examples/*' \
-not -path './tests/minimized/*' \
-not -path './tests/snapshots/*' \
-not -path './tests/buildTools/src/test/resources/fixtures/*' \
-not -path './scip-java/src/test/resources/fixtures/*' \
-not -path './scip-kotlinc/minimized/*' \
-exec ${pkgs.google-java-format}/bin/google-java-format --dry-run --set-exit-if-changed {} +
touch $out
'';
ktfmt = pkgs.runCommand "check-ktfmt" { } ''
cd ${./.}
# Exclude minimized Kotlin snapshots (coupled to generated SCIP
# goldens with exact line/column annotations) and the buildTools test
# fixtures (real-world project layouts): neither may be reformatted.
# goldens with exact line/column annotations) and the scip-java
# build-tool test fixtures (real-world project layouts): neither may
# be reformatted.
find . -name '*.kt' \
-not -path './scip-kotlinc/minimized/*' \
-not -path './tests/buildTools/src/test/resources/fixtures/*' \
-not -path './scip-java/src/test/resources/fixtures/*' \
-exec ${pkgs.ktfmt}/bin/ktfmt --kotlinlang-style --dry-run --set-exit-if-changed {} +
touch $out
'';
Expand Down
Loading