Skip to content

New canGenerateNewSnapshots to avoid automatically creating missing ones in CI #768

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 4, 2024

Conversation

NachoSoto
Copy link
Contributor

Fixes #748.

@NachoSoto
Copy link
Contributor Author

NachoSoto commented Dec 19, 2023

Bump?

NachoSoto referenced this pull request Dec 19, 2023
* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* fix

* beta 6

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* fix

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* small things

* wip

* DocC + swift-format (#765)

* DocC and swift-format support

* wip

* wip

* wip

---------

Co-authored-by: Brandon Williams <[email protected]>
@CraigSiemens
Copy link

CraigSiemens commented Jan 12, 2024

I had a related idea and stumbled across this searching issues for it.

I was looking for a way to record only the snapshots for the failing tests to avoid re-recording all the snapshots in a project. Mainly to avoid unrelated changed being applied and the back and forth of intel/apple silicon shaping out images.


This is just an idea, feel free to take or leave it. We could introduce a recordingMode rather than having more bools in the tests/globally.

enum RecordingMode {
    /// Only record a snapshot when there isn't an existing one. The default behaviour.
    case missingSnapshots
    
    /// Record the snapshots only for failing tests. Useful for when a change affects many
    /// snapshots across a project but you don't want the snapshots for the passing tests
    /// to be recorded as well.
    case failingTests
    
    /// Always record snapshots. The same as setting `isRecording` to true.
    case always
    
    /// Never record a snapshot. The same as setting `canGenerateNewSnapshots` to true.
    case never
}

This could be introduced without being a breaking change by modifying isRecording to be

public var isRecording: Bool {
   get { recordingMode == .always }
   set { recordingMode = newValue ? .always : .missingSnapshot }
}

@mbrandonw
Copy link
Member

Hi @NachoSoto, thanks for the PR!

It's taken some time, but this is now implemented in #867. I'm going to merge this PR and then it will be updated to mold into what we have going on in #867.

@mbrandonw mbrandonw merged commit 346f84c into pointfreeco:main Jul 4, 2024
@mbrandonw
Copy link
Member

Also, @CraigSiemens, #867 adds your option for recording failed snapshots only (see 0c6b449). Thanks for the suggestion!

awaltzforvenus pushed a commit to oreillymedia/native-ios-swift-snapshot-testing that referenced this pull request Jul 30, 2024
… ones in CI (pointfreeco#768)

* New `canGenerateNewSnapshots` to avoid automatically creating missing ones in CI

Fixes pointfreeco#748.

* Update AssertSnapshot.swift
JustasL added a commit to vinted/swift-snapshot-testing that referenced this pull request Dec 11, 2024
* main: (27 commits)
  Run swift-format
  Fix assertSnapshot for Swift Testing tests. (pointfreeco#916)
  Add an NB to @_implementationOnly import.
  Run swift-format
  Import only the implementation of Testing. (pointfreeco#903)
  fix missing inline snapshot testing (pointfreeco#887)
  Feature/fixed decimal separator (pointfreeco#889)
  Run swift-format
  Xcode 16 beta 5: Fix snapshots test trait (pointfreeco#885)
  Run swift-format
  Don't invoke XCTContext when running in the Testing framework. (pointfreeco#884)
  Run swift-format
  Fixed .failed record mode in inline snapshots. (pointfreeco#874)
  Point updated packages to swiftlang organization (pointfreeco#873)
  Fix recordIssue for Xcode beta 3. (pointfreeco#869)
  Run swift-format
  Beta support for Swift Testing, and other improvements. (pointfreeco#867)
  Run swift-format
  New `canGenerateNewSnapshots` to avoid automatically creating missing ones in CI (pointfreeco#768)
  Run swift-format
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Request] Avoid automatically recording snapshots on CI
4 participants