Skip to content

Commit

Permalink
Configurable snapshots location (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
keynmol committed Mar 24, 2024
1 parent 4a29362 commit d637369
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 8 deletions.
Expand Up @@ -49,6 +49,10 @@ object SnapshotsPlugin extends AutoPlugin {
"This way snapshot compliance will be checked on CI, but local workflow will be much quicker with immediate snapshot overwriting"
)

val snapshotsLocation = settingKey[File](
"Location of the snapshot files (this location is checked in to your VCS)"
)

val snapshotsTemporaryDirectory =
settingKey[File]("Temp folder where snapshot diffs will be created")

Expand Down Expand Up @@ -89,6 +93,7 @@ object SnapshotsPlugin extends AutoPlugin {
snapshotsAddRuntimeDependency := true,
snapshotsIntegrations := Seq.empty,
snapshotsForceOverwrite := false,
snapshotsLocation := sourceDirectory.value / "snapshots",
snapshotsTemporaryDirectory := (
Test / managedResourceDirectories
).value.head / "snapshots-tmp",
Expand Down Expand Up @@ -129,7 +134,7 @@ object SnapshotsPlugin extends AutoPlugin {
projectId = snapshotsProjectIdentifier.value,
packageName = snapshotsPackageName.value,
snapshotsDestination =
(Test / resourceDirectory).value / "snapshots" / snapshotsProjectIdentifier.value,
snapshotsLocation.value / snapshotsProjectIdentifier.value,
sourceDestination = dest / "Snapshots.scala",
tmpLocation = snapshotsTemporaryDirectory.value,
forceOverwrite = snapshotsForceOverwrite.value
Expand Down
Expand Up @@ -11,10 +11,8 @@ lazy val root = projectMatrix
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)),
snapshotsForceOverwrite := true,
check := {
val dir =
(Test / resourceDirectory).value / "snapshots" / snapshotsProjectIdentifier.value

val contents = IO.read(dir / "my_snapshot")
val contents = IO.read(snapshotsLocation.value / snapshotsProjectIdentifier.value / "my_snapshot")
val expected = "hello - more stuff"

assert(
Expand Down
@@ -1,6 +1,6 @@
$ exists src/test/resources/snapshots/root3/my_snapshot
$ exists src/test/resources/snapshots/rootNative3/my_snapshot
$ exists src/test/resources/snapshots/rootJS3/my_snapshot
$ exists src/snapshots/root3/my_snapshot
$ exists src/snapshots/rootNative3/my_snapshot
$ exists src/snapshots/rootJS3/my_snapshot
> root3/test
> rootNative3/test
> rootJS3/test
Expand Down
Expand Up @@ -3,7 +3,7 @@
-> rootNative3/test
-> rootJS3/test
> snapshotsAcceptAll
$ exists src/test/resources/snapshots/root/my_snapshot
$ exists src/snapshots/root/my_snapshot
> root3/test
> rootNative3/test
> rootJS3/test
Expand Down

0 comments on commit d637369

Please sign in to comment.