Skip to content
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

Generic Snapshots #3

Merged
merged 1 commit into from
Jul 9, 2017
Merged

Generic Snapshots #3

merged 1 commit into from
Jul 9, 2017

Conversation

stephencelis
Copy link
Member

This is a bit of a mess, naming/protocol-wise, and can probably be cleaned up quite a bit, but it's a start.

Copy link
Member Author

@stephencelis stephencelis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really want some better naming on these protocols and protocol methods, but maybe they're OK :/

let image = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
let data = UIImagePNGRepresentation(image)!
var diffTool: String? = nil
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can assign this "ksdiff", e.g., to print out a Kaleidoscope line.

+ ".png"

let snapshotURL = URL(string: snapshotName, relativeTo: snapshotsDirectoryURL)!
public protocol Diffable {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This protocol is used to describe types that can be diffed (images, text).

try! data.write(to: snapshotURL)
return nil
}
public protocol Snapshot {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This protocol describes types that can have snapshots taken, deferring to a Diffable type.

)

return attachment
XCTContext.runActivity(named: "Attached failure diff") { activity in activity.add(attachment) }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to return attachment anymore!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoa, amazing!

Copy link
Member

@mbrandonw mbrandonw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amazing! I can't wait to use this!

}

public func diff(comparing other: Data) -> XCTAttachment? {
return nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we at least just do an attachment of a string with current: \(self)\nnew: \(other) or something?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably! I'll try to improve these soon.

)

return attachment
XCTContext.runActivity(named: "Attached failure diff") { activity in activity.add(attachment) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoa, amazing!

let image = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
return image
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're in a guard 😬

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh lord 🙄

@stephencelis stephencelis merged commit f7eec12 into master Jul 9, 2017
@stephencelis stephencelis deleted the generic-snapshots branch July 9, 2017 01:17
tokopedia-ios-bot pushed a commit to tokopedia-ios-bot/swift-snapshot-testing that referenced this pull request Mar 22, 2021
[Update Fork] Make image diffing strategies custom scale aware (pointfreeco#336)
niil-qb pushed a commit to quickbit/swift-snapshot-testing that referenced this pull request Feb 23, 2023
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.

2 participants