Skip to content

Commit 6e3f93f

Browse files
committed
Move snapshots to scip-snapshots
1 parent a286bd9 commit 6e3f93f

92 files changed

Lines changed: 198 additions & 143 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.bazelignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ scip-gradle-plugin/target/
99
scip-java/target/
1010
scip-javac/target/
1111
scip-kotlinc/target/
12+
scip-snapshots/target/
13+
scip-snapshots/cases/java/common/target/
14+
scip-snapshots/cases/kotlin/common/target/
1215
target/
1316
tests/buildTools/target/
14-
tests/minimized/target/
15-
tests/snapshots/target/
1617
tests/unit/target/

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@ jobs:
115115
- name: scip-kotlinc tests
116116
run: nix develop --command sbt scipKotlinc/test
117117

118-
- name: Kotlin snapshots
119-
run: nix develop --command sbt scipKotlincMinimized/kotlincSnapshots
118+
- name: Regenerate snapshots
119+
run: nix develop --command sbt scipSnapshots/run
120120

121121
- name: Check snapshot drift
122122
run: |
123123
git diff --exit-code \
124-
scip-kotlinc/minimized/src/generatedSnapshots
124+
scip-snapshots/expected
125125
126126
maven:
127127
runs-on: ubuntu-latest

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ VERSION
7373
scip-gradle-plugin/gradle
7474
/aspects/
7575

76-
tests/snapshots/META-INF/
76+
scip-snapshots/META-INF/
7777

7878
# scip-kotlinc kctfork-based tests run kotlinc with our plugin, which
7979
# writes META-INF/scip/sources/Test.kt.scip relative to the test

build.sbt

Lines changed: 32 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
492441
def 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
}

flake.nix

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,9 @@
5757
# real-world project layouts that must not be reformatted here.
5858
find . -name '*.java' \
5959
-not -path './examples/*' \
60-
-not -path './tests/minimized/*' \
61-
-not -path './tests/snapshots/*' \
60+
-not -path './scip-snapshots/cases/*' \
61+
-not -path './scip-snapshots/expected/*' \
6262
-not -path './scip-java/src/test/resources/fixtures/*' \
63-
-not -path './scip-kotlinc/minimized/*' \
6463
-exec ${pkgs.google-java-format}/bin/google-java-format --dry-run --set-exit-if-changed {} +
6564
touch $out
6665
'';
@@ -71,7 +70,8 @@
7170
# build-tool test fixtures (real-world project layouts): neither may
7271
# be reformatted.
7372
find . -name '*.kt' \
74-
-not -path './scip-kotlinc/minimized/*' \
73+
-not -path './scip-snapshots/cases/*' \
74+
-not -path './scip-snapshots/expected/*' \
7575
-not -path './scip-java/src/test/resources/fixtures/*' \
7676
-exec ${pkgs.ktfmt}/bin/ktfmt --kotlinlang-style --dry-run --set-exit-if-changed {} +
7777
touch $out

scip-snapshots/README.md

Lines changed: 24 additions & 0 deletions

tests/minimized/src/main/java/minimized/AbstractClasses.java renamed to scip-snapshots/cases/java/common/src/main/java/minimized/AbstractClasses.java

File renamed without changes.

tests/minimized/src/main/java/minimized/AnnotationParameters.java renamed to scip-snapshots/cases/java/common/src/main/java/minimized/AnnotationParameters.java

File renamed without changes.

tests/minimized/src/main/java/minimized/Annotations.java renamed to scip-snapshots/cases/java/common/src/main/java/minimized/Annotations.java

File renamed without changes.

0 commit comments

Comments
 (0)