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

Turn on tests on Ubuntu, fix compile errors in tests #125

Merged
merged 2 commits into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-run-tests-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,5 @@ jobs:

- name: Build
run: /opt/swift/bin/swift build -v
# - name: Run tests
# run: /opt/swift/bin/swift test -v
- name: Run tests
run: /opt/swift/bin/swift test -v
26 changes: 15 additions & 11 deletions Tests/geometrizeTests/BitmapDiffing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import SnapshotTesting
import PNG
@testable import Geometrize

extension XCTAttachment {
convenience init(bitmap: Bitmap) {
self.init(data: try! bitmap.pngData(), uniformTypeIdentifier: "public.png") // swiftlint:disable:this force_try
}
}
// On Ubuntu this produces error
// error: initializers in structs are not marked with 'convenience'
//extension XCTAttachment {
// convenience init(bitmap: Bitmap) {
// self.init(data: try! bitmap.pngData(), uniformTypeIdentifier: "public.png") // swiftlint:disable:this force_try
// }
//}

extension Diffing where Value == Bitmap {

Expand All @@ -28,12 +30,14 @@ extension Diffing where Value == Bitmap {
let message = new.width == old.width && new.height == old.height
? "Newly-taken snapshot does not match reference."
: "Newly-taken snapshot@\(new.width),\(new.height) does not match reference@\(old.width),\(old.height)."
let oldAttachment = XCTAttachment(bitmap: old)
oldAttachment.name = "reference"
let newAttachment = XCTAttachment(bitmap: new)
newAttachment.name = "failure"
let differenceAttachment = XCTAttachment(bitmap: difference)
differenceAttachment.name = "difference"
let oldAttachment = XCTAttachment(data: try! old.pngData(), uniformTypeIdentifier: "public.png") // swiftlint:disable:this force_try)
//oldAttachment.name = "reference"
// on Ubuntu this produces error
// error: value of type 'XCTAttachment' has no member 'name'
let newAttachment = XCTAttachment(data: try! new.pngData(), uniformTypeIdentifier: "public.png") // swiftlint:disable:this force_try)
//newAttachment.name = "failure"
let differenceAttachment = XCTAttachment(data: try! difference.pngData(), uniformTypeIdentifier: "public.png") // swiftlint:disable:this force_try: difference)
//differenceAttachment.name = "difference"
return (
message,
[oldAttachment, newAttachment, differenceAttachment]
Expand Down