@@ -179,8 +179,7 @@ lazy val cli = project
179179 (Compile / mainClass) := Some (" com.sourcegraph.scip_java.ScipJava" ),
180180 (run / baseDirectory) := (ThisBuild / baseDirectory).value,
181181 // ScipJava.main can call System.exit, so we always fork the JVM when
182- // sbt invokes it directly (e.g. from the scip-kotlinc snapshots
183- // task) so it cannot kill the surrounding sbt process.
182+ // sbt invokes it directly so it cannot kill the surrounding sbt process.
184183 Compile / run / fork := true ,
185184 Test / fork := true ,
186185 // Our CI set up is a couple of measly vCPUs so parallelising tests there makes
@@ -242,14 +241,6 @@ lazy val cli = project
242241 )
243242 .dependsOn(scip)
244243
245- // Task key for regenerating the SCIP golden snapshots emitted by
246- // the scip-kotlinc compiler plugin over the Kotlin minimized fixtures.
247- // We deliberately do NOT call this `snapshots` to avoid colliding with the
248- // existing top-level `snapshots` test project (`lazy val snapshots = project`).
249- lazy val kotlincSnapshots = taskKey[Unit ](
250- " Run the SCIP snapshot generator over the scip-kotlinc minimized project"
251- )
252-
253244// The scip-kotlinc compiler plugin. Built as a fat-jar that is later
254245// embedded into the scip-java CLI distribution (see cli's resourceGenerators)
255246// so the runtime no longer needs to fetch a published scip-kotlinc
@@ -335,14 +326,12 @@ lazy val scipKotlinc = project
335326 )
336327 .dependsOn(scipShared)
337328
338- // `scipKotlincMinimized` mirrors the (still-present) Gradle build at
339- // scip-kotlinc/minimized/build.gradle.kts. It compiles a small set of
340- // Kotlin and Java fixtures with the assembled `scipKotlinc` plugin
341- // attached to kotlinc/javac, producing *.scip files under
342- // target/scip-targetroot/ which are then converted to SCIP and rendered
343- // as the human-readable golden snapshots by the `snapshots` task.
344- lazy val scipKotlincMinimized = project
345- .in(file(" scip-kotlinc/minimized" ))
329+ // Kotlin snapshot case. The fixture includes Java sources as interop
330+ // consumers, but the case is still keyed by the Kotlin compiler/plugin version
331+ // axis. It writes *.scip shards under target/scip-targetroot/ for the central
332+ // scipSnapshots project to aggregate and compare with goldens.
333+ lazy val scipSnapshotsKotlinCommon = project
334+ .in(file(" scip-snapshots/cases/kotlin/common" ))
346335 .enablePlugins(KotlinPlugin )
347336 .settings(
348337 publish / skip := true ,
@@ -391,57 +380,17 @@ lazy val scipKotlincMinimized = project
391380 val tgtRoot = target.value / " scip-targetroot"
392381 s " -Xplugin:scip -sourceroot: ${srcRoot.getAbsolutePath} " +
393382 s " -targetroot: ${tgtRoot.getAbsolutePath}"
394- },
395- // ----- snapshots regeneration task -----
396- // Invokes `com.sourcegraph.scip_java.ScipJava.main` twice in the cli JVM
397- // (forked — ScipJava.main calls System.exit on failure). First pass
398- // converts the *.scip files under target/scip-targetroot/
399- // into an index.scip; second pass renders that index as the human-readable
400- // golden snapshots.
401- //
402- // We use `kotlincSnapshots` instead of `snapshots` to avoid colliding
403- // with the existing top-level `snapshots` test project.
404- kotlincSnapshots :=
405- Def
406- .taskDyn {
407- val srcRoot = (ThisBuild / baseDirectory).value.getAbsolutePath
408- val tgtRoot = (target.value / " scip-targetroot" ).getAbsolutePath
409- val snapDir =
410- (baseDirectory.value / " src" / " generatedSnapshots" / " resources" )
411- .getAbsolutePath
412- // Write the aggregated index OUTSIDE the scanned targetroot. If it
413- // lived under `tgtRoot`, a second `kotlincSnapshots` run would feed
414- // the previous index.scip back into `aggregate`, which re-applies the
415- // package prefix and yields doubled symbols
416- // (e.g. `scip-java maven . . scip-java maven . . kotlin/`).
417- val indexDir = target.value / " scip-index"
418- IO .createDirectory(indexDir)
419- val scipOut = (indexDir / " index.scip" ).getAbsolutePath
420- val mainCls = " com.sourcegraph.scip_java.ScipJava"
421- Def .sequential(
422- Compile / compile,
423- (cli / Compile / runMain).toTask(
424- s " $mainCls aggregate --no-emit-inverse-relationships --cwd $srcRoot --output $scipOut $tgtRoot"
425- ),
426- (cli / Compile / runMain).toTask(
427- s " $mainCls snapshot --cwd $srcRoot --output $snapDir ${indexDir
428- .getAbsolutePath}"
429- )
430- )
431- }
432- .value
383+ }
433384 )
434385
435- lazy val minimized = project
436- .in(file(" tests/minimized/.j11 " ))
386+ lazy val scipSnapshotsJavaCommon = project
387+ .in(file(" scip-snapshots/cases/java/common " ))
437388 .settings(
438389 publish / skip := true ,
439390 run / fork := true ,
440- (Compile / unmanagedSourceDirectories) +=
441- file(" tests/minimized/src/main/java" ).getAbsoluteFile,
442391 libraryDependencies += " org.projectlombok" % " lombok" % " 1.18.22" ,
443392 // Fork javac so it receives real file paths instead of sbt's `vf://` virtual-file URIs
444- // (see the comment on `scipKotlincMinimized ` for the long story).
393+ // (see the comment on `scipSnapshotsKotlinCommon ` for the long story).
445394 javaHome := Some (file(System .getProperty(" java.home" ))),
446395 // Keep minimized snapshots stable across JDK 11/17/21.
447396 Compile / javacOptions ++= Seq (" --release" , " 11" ),
@@ -466,8 +415,8 @@ def javacModuleOptions = List(
466415 " -J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"
467416)
468417
469- lazy val snapshots = project
470- .in(file(" tests/ snapshots" ))
418+ lazy val scipSnapshots = project
419+ .in(file(" scip- snapshots" ))
471420 .settings(
472421 publish / skip := true ,
473422 Test / fork := true ,
@@ -487,18 +436,27 @@ lazy val snapshots = project
487436 .dependsOn(cli)
488437
489438// Runtime paths for the snapshot generator, passed as -D system properties.
490- // Depending on `minimized/ compile` here guarantees a fresh targetroot whenever
491- // `snapshots /test` or `snapshots /run` evaluate javaOptions.
439+ // Depending on each snapshot case's compile task guarantees fresh targetroots
440+ // whenever `scipSnapshots /test` or `scipSnapshots /run` evaluate javaOptions.
492441def snapshotPathOptions = Def .task {
493- val _ = (minimized / Compile / compile).value
442+ val _java = (scipSnapshotsJavaCommon / Compile / compile).value
443+ val _kotlin = (scipSnapshotsKotlinCommon / Compile / compile).value
444+ val snapshotRoot = (ThisBuild / baseDirectory).value / " scip-snapshots"
494445 Seq (
495- s " -Dsnapshot.expectDir= ${((Compile / sourceDirectory).value / " generated" )
496- .getAbsolutePath}" ,
497- s " -Dsnapshot.minimizedTargetroot= ${(
498- minimized / Compile / semanticdbTargetRoot
446+ s " -Dsnapshot.sourceroot= ${(ThisBuild / baseDirectory).value.getAbsolutePath}" ,
447+ " -Dsnapshot.cases=java-common,kotlin-common" ,
448+ s " -Dsnapshot.case.java-common.expectDir= ${(
449+ snapshotRoot / " expected" / " java" / " common"
450+ ).getAbsolutePath}" ,
451+ s " -Dsnapshot.case.java-common.targetroot= ${(
452+ scipSnapshotsJavaCommon / Compile / semanticdbTargetRoot
499453 ).value.getAbsolutePath}" ,
500- s " -Dsnapshot.sourceroot= ${(ThisBuild / baseDirectory)
501- .value
502- .getAbsolutePath}"
454+ s " -Dsnapshot.case.kotlin-common.expectDir= ${(
455+ snapshotRoot / " expected" / " kotlin" / " common"
456+ ).getAbsolutePath}" ,
457+ s " -Dsnapshot.case.kotlin-common.targetroot= ${((
458+ scipSnapshotsKotlinCommon / target
459+ ).value / " scip-targetroot" ).getAbsolutePath}" ,
460+ " -Dsnapshot.case.kotlin-common.aggregateNoEmitInverseRelationships=true"
503461 )
504462}
0 commit comments