Skip to content

Commit 4dcf906

Browse files
committed
Initial
0 parents  commit 4dcf906

File tree

5 files changed

+84
-0
lines changed

5 files changed

+84
-0
lines changed

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
xcuserdata/
5+
DerivedData/
6+
.swiftpm/configuration/registries.json
7+
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
8+
.netrc

Package.resolved

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"pins" : [
3+
{
4+
"identity" : "swift-snapshot-testing",
5+
"kind" : "remoteSourceControl",
6+
"location" : "https://github.com/pointfreeco/swift-snapshot-testing",
7+
"state" : {
8+
"revision" : "696b86a6d151578bca7c1a2a3ed419a5f834d40f",
9+
"version" : "1.13.0"
10+
}
11+
},
12+
{
13+
"identity" : "swift-syntax",
14+
"kind" : "remoteSourceControl",
15+
"location" : "https://github.com/apple/swift-syntax.git",
16+
"state" : {
17+
"revision" : "74203046135342e4a4a627476dd6caf8b28fe11b",
18+
"version" : "509.0.0"
19+
}
20+
}
21+
],
22+
"version" : 2
23+
}

Package.swift

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// swift-tools-version: 5.7
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let lib = "SnapshotTestingCli"
7+
8+
let package = Package(
9+
name: "swift-snapshot-testing-cli",
10+
platforms: [.macOS(.v13)],
11+
products: [.library(name: lib, targets: [lib]),],
12+
dependencies: [
13+
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.13.0")
14+
],
15+
targets: [
16+
.target(
17+
name: lib,
18+
dependencies: [
19+
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
20+
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
21+
]),]
22+
)

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# swift snapshot testing + cli
2+
3+
Very small addition to https://github.com/pointfreeco/swift-snapshot-testing
4+
5+
## Use case
6+
7+
To update tests in a swift package from commandline rather then in code.
8+
9+
```
10+
export SNAPSHOT_TESTING_UPDATE_TESTS=true &&swift test --generate-linuxmain
11+
```
12+
13+
## Discussion
14+
15+
I wonder if it would be a nice addition and I am dissussing it here https://github.com/pointfreeco/swift-snapshot-testing/discussions/457#discussioncomment-6998554
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import SnapshotTesting
2+
import XCTest
3+
import InlineSnapshotTesting
4+
5+
/// Convenience that looks for an environment variable SNAPSHOT_TESTING_UPDATE_TESTS that can be set to true in order to
6+
/// have the tests update from commandline
7+
open class XCTestCaseSnapshot: XCTestCase {
8+
open override class func setUp() {
9+
super.setUp()
10+
SnapshotTesting.diffTool = "ksdiff"
11+
InlineSnapshotTesting.diffTool = SnapshotTesting.diffTool
12+
let isRecording = Bool(ProcessInfo.processInfo.environment["SNAPSHOT_TESTING_UPDATE_TESTS"] ?? "false") ?? false
13+
SnapshotTesting.isRecording = isRecording
14+
InlineSnapshotTesting.isRecording = isRecording
15+
}
16+
}

0 commit comments

Comments
 (0)