Skip to content

Commit

Permalink
Refactor Tests Using Firewalk (#440)
Browse files Browse the repository at this point in the history
* Refactor tests with Endpoint.

* Increase stress tests.

* Update actions to use Firewalk.

* Test AFI on Catalyst.

* Fix flaky tests.

* Refactor test.

* Fix test reliability on tvOS.
  • Loading branch information
jshier authored Apr 4, 2021
1 parent e9a13dd commit 4307047
Show file tree
Hide file tree
Showing 20 changed files with 987 additions and 659 deletions.
48 changes: 30 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Dependencies
run: ./carthage.sh bootstrap --no-use-binaries --platform macOS
run: carthage bootstrap --no-build
- name: macOS (5.1)
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -workspace "AlamofireImage.xcworkspace" -scheme "AlamofireImage macOS" -destination "platform=macOS" clean build | xcpretty
macOS_5_2:
Expand All @@ -30,8 +30,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Firewalk
run: brew install alamofire/alamofire/firewalk && firewalk &
- name: Dependencies
run: ./carthage.sh bootstrap --no-use-binaries --platform macOS
run: carthage bootstrap --no-build
- name: macOS (5.2)
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -workspace "AlamofireImage.xcworkspace" -scheme "AlamofireImage macOS" -destination "platform=macOS" clean test | xcpretty
macOS_5_3:
Expand All @@ -42,21 +44,26 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Firewalk
run: brew install alamofire/alamofire/firewalk && firewalk &
- name: Dependencies
run: ./carthage.sh bootstrap --no-use-binaries --platform macOS
run: carthage bootstrap --no-build
- name: macOS (5.3)
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -workspace "AlamofireImage.xcworkspace" -scheme "AlamofireImage macOS" -destination "platform=macOS" clean test | xcpretty
# Catalyst:
# name: Test Catalyst
# runs-on: macOS-latest
# env:
# DEVELOPER_DIR: /Applications/Xcode_11.6.app/Contents/Developer
# steps:
# - uses: actions/checkout@v2
# - name: Dependencies
# run: carthage bootstrap --no-use-binaries --platform macCatalyst
# - name: Catalyst
# run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -workspace "AlamofireImage.xcworkspace" -scheme "Alamofire iOS" -destination "platform=macOS" clean test | xcpretty
Catalyst:
name: Test Catalyst
runs-on: macOS-latest
env:
DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Firewalk
run: brew install alamofire/alamofire/firewalk && firewalk &
- name: Dependencies
run: carthage bootstrap --no-build
- name: Catalyst
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -workspace "AlamofireImage.xcworkspace" -scheme "AlamofireImage iOS" -destination "platform=macOS" clean test | xcpretty
iOS:
name: Test iOS
runs-on: macOS-latest
Expand All @@ -68,8 +75,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Firewalk
run: brew install alamofire/alamofire/firewalk && firewalk &
- name: Dependencies
run: ./carthage.sh bootstrap --no-use-binaries --platform iOS
run: carthage bootstrap --no-build
- name: iOS - ${{ matrix.destination }}
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -workspace "AlamofireImage.xcworkspace" -scheme "AlamofireImage iOS" -destination "${{ matrix.destination }}" clean test | xcpretty
tvOS:
Expand All @@ -83,8 +92,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Firewalk
run: brew install alamofire/alamofire/firewalk && firewalk &
- name: Dependencies
run: ./carthage.sh bootstrap --no-use-binaries --platform tvOS
run: carthage bootstrap --no-build
- name: tvOS - ${{ matrix.destination }}
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -workspace "AlamofireImage.xcworkspace" -scheme "AlamofireImage tvOS" -destination "${{ matrix.destination }}" clean test | xcpretty
watchOS:
Expand All @@ -99,7 +110,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Dependencies
run: ./carthage.sh bootstrap --no-use-binaries --platform watchOS
run: carthage bootstrap --no-build
- name: watchOS - ${{ matrix.destination }}
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -workspace "AlamofireImage.xcworkspace" -scheme "AlamofireImage watchOS" -destination "${{ matrix.destination }}" clean build | xcpretty
spm:
Expand All @@ -108,7 +119,8 @@ jobs:
env:
DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer
steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2
- name: SPM Build
run: swift build -c debug

2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.1
2.7.2
16 changes: 16 additions & 0 deletions AlamofireImage.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
objects = {

/* Begin PBXBuildFile section */
31FA4D672619207200CEAD2B /* TestHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31FA4D662619207200CEAD2B /* TestHelpers.swift */; };
31FA4D682619207200CEAD2B /* TestHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31FA4D662619207200CEAD2B /* TestHelpers.swift */; };
31FA4D692619207200CEAD2B /* TestHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31FA4D662619207200CEAD2B /* TestHelpers.swift */; };
31FA4D7926192E4500CEAD2B /* CGSize.ScreenScaling.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31FA4D7826192E4500CEAD2B /* CGSize.ScreenScaling.swift */; };
31FA4D7A26192E4500CEAD2B /* CGSize.ScreenScaling.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31FA4D7826192E4500CEAD2B /* CGSize.ScreenScaling.swift */; };
31FA4D7B26192E4500CEAD2B /* CGSize.ScreenScaling.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31FA4D7826192E4500CEAD2B /* CGSize.ScreenScaling.swift */; };
4C0893EC1B936A7A005125D9 /* UIImage+AlamofireImageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C0893EB1B936A7A005125D9 /* UIImage+AlamofireImageTests.swift */; };
4C0893F51B937404005125D9 /* UIImageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C0893F41B937404005125D9 /* UIImageTests.swift */; };
4C0894E41B9382EB005125D9 /* apple.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 4C0894501B9382EB005125D9 /* apple.jpg */; };
Expand Down Expand Up @@ -566,6 +572,8 @@
3143544B1F4A16FE00266E5F /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
3143544C1F4A16FE00266E5F /* CHANGELOG.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = "<group>"; };
314354501F4A16FE00266E5F /* CONTRIBUTING.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = CONTRIBUTING.md; sourceTree = "<group>"; };
31FA4D662619207200CEAD2B /* TestHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestHelpers.swift; sourceTree = "<group>"; };
31FA4D7826192E4500CEAD2B /* CGSize.ScreenScaling.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CGSize.ScreenScaling.swift; sourceTree = "<group>"; };
4C0893EB1B936A7A005125D9 /* UIImage+AlamofireImageTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIImage+AlamofireImageTests.swift"; sourceTree = "<group>"; };
4C0893F41B937404005125D9 /* UIImageTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIImageTests.swift; sourceTree = "<group>"; };
4C0894501B9382EB005125D9 /* apple.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = apple.jpg; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1239,6 +1247,7 @@
4CBE9C642401FE2100B2AAC0 /* Helpers */ = {
isa = PBXGroup;
children = (
31FA4D662619207200CEAD2B /* TestHelpers.swift */,
B30AFF7B23F49CC500883238 /* ThrowingURLRequestConvertible.swift */,
);
name = Helpers;
Expand All @@ -1265,6 +1274,7 @@
children = (
4CD5BCF41D7FBE380055E232 /* AFError+AlamofireImageTests.swift */,
4C7DD7EE224EC07000249836 /* AFResult+AlamofireImageTests.swift */,
31FA4D7826192E4500CEAD2B /* CGSize.ScreenScaling.swift */,
4C0893EB1B936A7A005125D9 /* UIImage+AlamofireImageTests.swift */,
);
name = Extensions;
Expand Down Expand Up @@ -2057,8 +2067,10 @@
4C16B3AA1BA93ADB00A66EF0 /* ImageFilterTests.swift in Sources */,
4C16B3A71BA93ADB00A66EF0 /* BaseTestCase.swift in Sources */,
B30AFF7F23F4A3FD00883238 /* ThrowingURLRequestConvertible.swift in Sources */,
31FA4D692619207200CEAD2B /* TestHelpers.swift in Sources */,
4CBE8FB92316008300782A2E /* ImageDownloaderStressTests.swift in Sources */,
4C16B3AD1BA93ADB00A66EF0 /* UIImageViewTests.swift in Sources */,
31FA4D7B26192E4500CEAD2B /* CGSize.ScreenScaling.swift in Sources */,
4C16B3A91BA93ADB00A66EF0 /* ImageDownloaderTests.swift in Sources */,
4C16B3AC1BA93ADB00A66EF0 /* UIImageTests.swift in Sources */,
);
Expand Down Expand Up @@ -2109,8 +2121,10 @@
4CEBB5401B93C622001391DE /* ImageCacheTests.swift in Sources */,
4C0893EC1B936A7A005125D9 /* UIImage+AlamofireImageTests.swift in Sources */,
B30AFF7D23F4A3FB00883238 /* ThrowingURLRequestConvertible.swift in Sources */,
31FA4D672619207200CEAD2B /* TestHelpers.swift in Sources */,
4CBE8FB72316008300782A2E /* ImageDownloaderStressTests.swift in Sources */,
4C1624851AABE8E600A0385D /* BaseTestCase.swift in Sources */,
31FA4D7926192E4500CEAD2B /* CGSize.ScreenScaling.swift in Sources */,
4C0893F51B937404005125D9 /* UIImageTests.swift in Sources */,
4C5874861B93F81800407E58 /* ImageDownloaderTests.swift in Sources */,
);
Expand Down Expand Up @@ -2145,8 +2159,10 @@
4CEBB5411B93C622001391DE /* ImageCacheTests.swift in Sources */,
4C86C1121DA0B3400032ECC3 /* UIImageViewTests.swift in Sources */,
B30AFF7E23F4A3FC00883238 /* ThrowingURLRequestConvertible.swift in Sources */,
31FA4D682619207200CEAD2B /* TestHelpers.swift in Sources */,
4CBE8FB82316008300782A2E /* ImageDownloaderStressTests.swift in Sources */,
4C5874871B93F81800407E58 /* ImageDownloaderTests.swift in Sources */,
31FA4D7A26192E4500CEAD2B /* CGSize.ScreenScaling.swift in Sources */,
4C86C1131DA0B3440032ECC3 /* UIImage+AlamofireImageTests.swift in Sources */,
4C0897EC1B93BC0D005125D9 /* RequestTests.swift in Sources */,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@
value = "1"
isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
key = "OS_ACTIVITY_MODE"
value = "disable"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
<CodeCoverageTargets>
<BuildableReference
Expand Down
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "Alamofire/Alamofire" "5.4.1"
github "Alamofire/Alamofire" "5.4.2"
65 changes: 34 additions & 31 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.2)
activesupport (4.2.11.1)
i18n (~> 0.7)
CFPropertyList (3.0.3)
activesupport (5.2.5)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
algoliasearch (1.27.1)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
atomos (0.1.3)
claide (1.0.3)
cocoapods (1.9.1)
activesupport (>= 4.0.2, < 5)
cocoapods (1.10.1)
addressable (~> 2.6)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.9.1)
cocoapods-core (= 1.10.1)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 1.2.2, < 2.0)
cocoapods-downloader (>= 1.4.0, < 2.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
cocoapods-search (>= 1.0.0, < 2.0)
cocoapods-stats (>= 1.0.0, < 2.0)
cocoapods-trunk (>= 1.4.0, < 2.0)
cocoapods-try (>= 1.1.0, < 2.0)
colored2 (~> 3.1)
Expand All @@ -30,38 +31,39 @@ GEM
molinillo (~> 0.6.6)
nap (~> 1.0)
ruby-macho (~> 1.4)
xcodeproj (>= 1.14.0, < 2.0)
cocoapods-core (1.9.1)
activesupport (>= 4.0.2, < 6)
xcodeproj (>= 1.19.0, < 2.0)
cocoapods-core (1.10.1)
activesupport (> 5.0, < 6)
addressable (~> 2.6)
algoliasearch (~> 1.0)
concurrent-ruby (~> 1.1)
fuzzy_match (~> 2.0.4)
nap (~> 1.0)
netrc (~> 0.11)
public_suffix
typhoeus (~> 1.0)
cocoapods-deintegrate (1.0.4)
cocoapods-downloader (1.3.0)
cocoapods-downloader (1.4.0)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.0)
cocoapods-stats (1.1.0)
cocoapods-trunk (1.4.1)
cocoapods-trunk (1.5.0)
nap (>= 0.8, < 2.0)
netrc (~> 0.11)
cocoapods-try (1.1.0)
cocoapods-try (1.2.0)
colored2 (3.1.2)
concurrent-ruby (1.1.6)
concurrent-ruby (1.1.8)
escape (0.0.4)
ethon (0.12.0)
ffi (>= 1.3.0)
ffi (1.12.2)
ffi (1.15.0)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
httpclient (2.8.3)
i18n (0.9.5)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
jazzy (0.13.2)
jazzy (0.13.6)
cocoapods (~> 1.5)
mustache (~> 1.1)
open4
Expand All @@ -70,34 +72,35 @@ GEM
sassc (~> 2.1)
sqlite3 (~> 1.3)
xcinvoke (~> 0.3.0)
json (2.3.0)
json (2.5.1)
liferaft (0.0.6)
minitest (5.14.0)
minitest (5.14.4)
molinillo (0.6.6)
mustache (1.1.1)
nanaimo (0.2.6)
nanaimo (0.3.0)
nap (1.1.0)
netrc (0.11.0)
open4 (1.3.4)
redcarpet (3.5.0)
rouge (3.17.0)
public_suffix (4.0.6)
redcarpet (3.5.1)
rouge (3.26.0)
ruby-macho (1.4.0)
sassc (2.2.1)
sassc (2.4.0)
ffi (~> 1.9)
sqlite3 (1.4.2)
thread_safe (0.3.6)
typhoeus (1.3.1)
typhoeus (1.4.0)
ethon (>= 0.9.0)
tzinfo (1.2.7)
tzinfo (1.2.9)
thread_safe (~> 0.1)
xcinvoke (0.3.0)
liferaft (~> 0.0.6)
xcodeproj (1.15.0)
xcodeproj (1.19.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.2.6)
nanaimo (~> 0.3.0)

PLATFORMS
ruby
Expand Down
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/Alamofire/Alamofire.git",
"state": {
"branch": null,
"revision": "fca036f7aeca07124067cb6e0c12b0ad6359e3d4",
"version": "5.1.0"
"revision": "4d19ad82f80cc71ff829b941ded114c56f4f604c",
"version": "5.4.2"
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion Source/ImageDownloader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ open class ImageDownloader {
case fifo, lifo
}

class ResponseHandler {
final class ResponseHandler {
let urlID: String
let handlerID: String
let request: DataRequest
Expand Down
39 changes: 39 additions & 0 deletions Tests/CGSize.ScreenScaling.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// CGSize.ScreenScaling.swift
//
// Copyright (c) 2021 Alamofire Software Foundation (http://alamofire.org/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

#if canImport(UIKit)

import UIKit

extension CGSize {
var scaledToScreen: CGSize {
scaled(by: UIScreen.main.scale)
}

func scaled(by scale: CGFloat) -> CGSize {
CGSize(width: width / scale, height: height / scale)
}
}

#endif
Loading

0 comments on commit 4307047

Please sign in to comment.