From 9bd23f2636d2bdab4f2601631e3469d4647c13a9 Mon Sep 17 00:00:00 2001 From: Thomas Grapperon <35562418+tgrapperon@users.noreply.github.com> Date: Mon, 1 Jul 2024 01:34:19 +0200 Subject: [PATCH] Configure `isRecording` default value with launch arguments --- Sources/SnapshotTesting/AssertSnapshot.swift | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Sources/SnapshotTesting/AssertSnapshot.swift b/Sources/SnapshotTesting/AssertSnapshot.swift index 9d4a24318..8e7640a62 100644 --- a/Sources/SnapshotTesting/AssertSnapshot.swift +++ b/Sources/SnapshotTesting/AssertSnapshot.swift @@ -9,7 +9,16 @@ import XCTest public var diffTool: String? = nil /// Whether or not to record all new references. -public var isRecording = false +public var isRecording: Bool = { + let args = ProcessInfo.processInfo.arguments + if let index = args.firstIndex(of: "-co.pointfree.SnapshotTesting.IsRecording"), + index < args.count - 1, + args[index + 1] == "1" + { + return true + } + return false +}() /// Whether or not to record all new references. ///