Skip to content

Commit

Permalink
Preparation for version 3.3.0 - added CLI tool for Mint, fixed few bu…
Browse files Browse the repository at this point in the history
…gs (MakeAWishFoundation#189)

* Fixes redundant constraints in Verify and Perform for methods with stripped generics
* Basic setup for future CLI.
* Updated dependencies, renamed and extracted main elements
* Renamed project and workspace
* Building CLI - mocks setup and Mockfile serialisation
* Added setup command
* Added auto import extraction and generation commands
* Migration setup
* Added migration and targets support
* Updated messaging and provided template for doctor
* Added tools inspection, updated UI
* Doctor command for sources and imports
* Fixed resources handling
* Removed Obj-C dependency
* Setup for SPM tests done
* Updated SiwftyMocky runtime library to check for XCTest availability instead, removed compilation flag check, assured compatibility with SPM
* Updated tests, verified SwiftyMocky works with SPM targets tests
* Fastlane actions updated
* Updated travis config for support matrix
* Different package on linux machines
* Fix for MakeAWishFoundation#187 perform with @autoclosure attributes.
* Fix for MakeAWishFoundation#175 Handling Self as generic parameter for return type
* Added proper resolving Given willReturn parameter.
* Fixed also the case when Self is inside one of the method parameters, also as a generic class type
* Updated test for older swift versions and build system
* New commands and mock init
* Fixed inspection when multiple versions of Sourcery installed
  • Loading branch information
amichnia authored May 19, 2019
1 parent 07f402c commit bc84594
Show file tree
Hide file tree
Showing 68 changed files with 5,172 additions and 343 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,4 @@ Example/fastlane/test_output/report.junit
# Sourcery genreated file
default.profraw
.DS_Store
.vscode
74 changes: 51 additions & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,55 @@
language: objective-c
env:
global:
- SWIFT_BRANCH=swift-5.0-release
- SWIFT_VERSION=swift-5.0-RELEASE

os: osx
language: generic
sudo: required
dist: trusty
osx_image: xcode10
matrix:
include:
- os: osx
language: swift
osx_image: xcode10
install:
- rake pods
- brew install mint
script:
- swift --version
- swift build -c release
- sleep 1
- ./.build/x86_64-apple-macosx10.10/release/swiftymocky doctor
- ./.build/x86_64-apple-macosx10.10/release/swiftymocky generate
- swift test
- fastlane ios test
- rake mock # legacy mock generation
- fastlane tvos test

- os: osx
language: swift
osx_image: xcode10.2
install:
- rake pods
- brew install mint
script:
- swift --version
- swift build -c release
- swift run -c release --skip-build --skip-update swiftymocky doctor
- swift run -c release --skip-build --skip-update swiftymocky generate
- swift test
- fastlane ios test
- rake mock # legacy mock generation
- fastlane tvos test

# For now, Sourcery does not work on linux, so commented it out
# - os: linux
# dist: trusty
# sudo: required
# language: generic
# install:
# - sudo apt-get install clang libicu-dev
# - mkdir swift
# - curl https://swift.org/builds/$SWIFT_BRANCH/ubuntu1404/$SWIFT_VERSION/$SWIFT_VERSION-ubuntu14.04.tar.gz -s | tar xz -C swift &> /dev/null
# - export PATH="$(pwd)/swift/$SWIFT_VERSION-ubuntu14.04/usr/bin:$PATH"
# - git clone https://github.com/yonaskolb/Mint.git
# - cd Mint && swift run mint install yonaskolb/mint

notifications:
#slack: // TODO:
email: false

install:
- if [ `uname` == "Linux" ] ; then
curl -sL https://gist.github.com/kylef/5c0475ff02b7c7671d2a/raw/621ef9b29bbb852fdfd2e10ed147b321d792c1e4/swiftenv-install.sh | bash ;
fi

script:
# - 'if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then bash certs.sh; fi' # certs for macos app
- rake pods
- rake mock
# - 'if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then fastlane mac test; fi' # unable to run macos tests on CI now - turning off on CI
- fastlane ios test
- fastlane tvos test

after_success:
- sleep 5 # workaround https://github.com/travis-ci/travis-ci/issues/4725
60 changes: 60 additions & 0 deletions Mockfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
sourceryCommand: null
mocky.iOS:
sources:
include:
- ./SwiftyMocky-Example/Shared
- ./SwiftyMocky-Example/iOS
- ./SwiftyMocky-Tests/iOS
exclude:
- ./SwiftyMocky-Example/Shared/Other/Excluded.generated.swift
output: ./SwiftyMocky-Tests/iOS/Mocks/Mock.generated.swift
targets:
- Mocky_Tests_iOS
testable:
- Mocky_Example_iOS
import:
- CoreGraphics
- Foundation
- UIKit
mocky.macOS:
sources:
include:
- ./SwiftyMocky-Example/Shared
- ./SwiftyMocky-Example/macOS
- ./SwiftyMocky-Tests/macOS
exclude:
- ./SwiftyMocky-Example/Shared/Other/Excluded.generated.swift
output: ./SwiftyMocky-Tests/macOS/Mocks/Mock.generated.swift
targets:
- Mocky_Tests_macOS
testable:
- Mocky_Example_macOS
import:
- Foundation
mocky.tvOS:
sources:
include:
- ./SwiftyMocky-Example/Shared
- ./SwiftyMocky-Example/tvOS
- ./SwiftyMocky-Tests/tvOS
exclude:
- ./SwiftyMocky-Example/Shared/Other/Excluded.generated.swift
output: ./SwiftyMocky-Tests/tvOS/Mocks/Mock.generated.swift
targets:
- Mocky_Tests_tvOS
testable:
- Mocky_Example_tvOS
import:
- Foundation
cli.core.tests:
sources:
include:
- ./Sources/SwiftyMockyCLICore
output: ./Tests/SwiftyMockyCLICoreTests/Mock.generated.swift
targets:
- Package.swift/SwiftyMockyCLICore
testable:
- SwiftyMockyCLICore
import:
- Foundation
- PathKit
97 changes: 97 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"object": {
"pins": [
{
"package": "AEXML",
"repositoryURL": "https://github.com/tadija/AEXML",
"state": {
"branch": null,
"revision": "54bb8ea6fb693dd3f92a89e5fcc19e199fdeedd0",
"version": "4.3.3"
}
},
{
"package": "Commander",
"repositoryURL": "https://github.com/kylef/Commander",
"state": {
"branch": null,
"revision": "e5b50ad7b2e91eeb828393e89b03577b16be7db9",
"version": "0.8.0"
}
},
{
"package": "Crayon",
"repositoryURL": "https://github.com/jianstm/Crayon",
"state": {
"branch": null,
"revision": "05930604feec1ac77b4633a17a722d428d5be2cc",
"version": "0.0.3"
}
},
{
"package": "PathKit",
"repositoryURL": "https://github.com/kylef/PathKit",
"state": {
"branch": null,
"revision": "e2f5be30e4c8f531c9c1e8765aa7b71c0a45d7a0",
"version": "0.9.2"
}
},
{
"package": "Rainbow",
"repositoryURL": "https://github.com/jianstm/Rainbow",
"state": {
"branch": null,
"revision": "177c6ebae4389c0363ea1bf62a7257151d53acbc",
"version": "0.0.4"
}
},
{
"package": "ShellOut",
"repositoryURL": "https://github.com/JohnSundell/ShellOut.git",
"state": {
"branch": null,
"revision": "d3d54ce662dfee7fef619330b71d251b8d4869f9",
"version": "2.2.0"
}
},
{
"package": "Spectre",
"repositoryURL": "https://github.com/kylef/Spectre.git",
"state": {
"branch": null,
"revision": "f14ff47f45642aa5703900980b014c2e9394b6e5",
"version": "0.9.0"
}
},
{
"package": "SwiftShell",
"repositoryURL": "https://github.com/kareman/SwiftShell",
"state": {
"branch": null,
"revision": "beebe43c986d89ea5359ac3adcb42dac94e5e08a",
"version": "4.1.2"
}
},
{
"package": "xcodeproj",
"repositoryURL": "https://github.com/tuist/xcodeproj.git",
"state": {
"branch": null,
"revision": "065f348754b6155b8037dc43876a8f2ee354b95d",
"version": "6.7.0"
}
},
{
"package": "Yams",
"repositoryURL": "https://github.com/jpsim/Yams.git",
"state": {
"branch": null,
"revision": "c947a306d2e80ecb2c0859047b35c73b8e1ca27f",
"version": "2.0.0"
}
}
]
},
"version": 1
}
95 changes: 95 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

#if os(macOS)
/// MacOS swiftymocky mackage
let package = Package(
name: "swiftymocky",
products: [
.executable(name: "swiftymocky", targets: ["SwiftyMockyCLI"]),
.library(name: "SwiftyMocky", targets: ["SwiftyMocky"]),
],
dependencies: [
.package(url: "https://github.com/JohnSundell/ShellOut.git", from: "2.0.0"),
.package(url: "https://github.com/tuist/xcodeproj.git", from: "6.5.0"),
.package(url: "https://github.com/jianstm/Crayon", from: "0.0.3"),
.package(url: "https://github.com/kylef/Commander", from: "0.8.0"),
.package(url: "https://github.com/kylef/PathKit", from: "0.9.0"),
.package(url: "https://github.com/jpsim/Yams.git", from: "2.0.0"),
],
targets: [
.target(
name: "SwiftyMocky",
path: "./Sources/Classes"
),
.target(
name: "SwiftyMockyCLI",
dependencies: [
"Commander",
"SwiftyMockyCLICore"
]),
.target(
name: "SwiftyMockyCLICore",
dependencies: [
"ShellOut",
"Crayon",
"xcodeproj",
"PathKit",
"Yams",
]),
.testTarget(
name: "SwiftyMockyCLICoreTests",
dependencies: [
"SwiftyMockyCLICore",
"SwiftyMocky"
]),
]
)
#else
/// Linux package. For now not really usable, until sourcery would be available too
let package = Package(
name: "swiftymocky",
products: [
.executable(name: "swiftymocky", targets: ["SwiftyMockyCLI"]),
.library(name: "SwiftyMocky", targets: ["SwiftyMocky"]),
],
dependencies: [
.package(url: "https://github.com/JohnSundell/ShellOut.git", from: "2.0.0"),
.package(url: "https://github.com/jianstm/Crayon", from: "0.0.1"),
.package(url: "https://github.com/kylef/Commander", from: "0.8.0"),
.package(url: "https://github.com/kylef/PathKit", from: "0.0.1"),
.package(url: "https://github.com/jpsim/Yams.git", from: "2.0.0"),
],
targets: [
.target(
name: "SwiftyMocky",
path: "./Sources/Classes"),
.target(
name: "SwiftyMockyCLI",
dependencies: [
"Commander",
"SwiftyMockyCLICore"
]),
.target(
name: "SwiftyMockyCLICore",
dependencies: [
"ShellOut",
"Crayon",
"PathKit",
"Yams",
],
exclude: [
"Commands/MacOS",
"Utils/MacOS",
]),
.testTarget(
name: "SwiftyMockyCLICoreTests",
dependencies: [
"SwiftyMockyCLICore",
"SwiftyMocky"
]),
]
)
#endif
8 changes: 4 additions & 4 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
PODS:
- Sourcery (0.16.0)
- Sourcery (0.16.1)
- SwiftyMocky (3.2.0):
- SwiftyMocky/Core (= 3.2.0)
- SwiftyMocky/Core (3.2.0):
- Sourcery (> 0.16)
- Sourcery (>= 0.16)

DEPENDENCIES:
- SwiftyMocky (from `./`)
Expand All @@ -17,8 +17,8 @@ EXTERNAL SOURCES:
:path: "./"

SPEC CHECKSUMS:
Sourcery: 3e55aad9719ee5782ab81eb16addd44d272e4d13
SwiftyMocky: 20ee055796bb023142e83a23bee86d43ecb6c29a
Sourcery: 16779170d35ee204666843b09031f36721a84bcc
SwiftyMocky: 360fffbd8e35ed7c46f19320801fd37d9c352520

PODFILE CHECKSUM: 2c8b2a04598345eef7278f0b805b84438bb9f711

Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ task :template do
sh "cd ./Templates && cat VariableWrapper.swift >> #{destination}"
sh "cd ./Templates && echo \"_%>\" >> #{destination}"
sh "cd ./Templates && cat Main.swifttemplate >> #{destination}"
sh "swift run swiftymocky assetize"
end

task :xcode do
Expand Down
2 changes: 2 additions & 0 deletions Sources/Classes/CustomAssertions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2018 MakeAWishFoundation. All rights reserved.
//

#if canImport(XCTest)
import XCTest

/// Allows to verify if error was thrown, and if it is of given type.
Expand Down Expand Up @@ -39,3 +40,4 @@ public func XCTAssertThrowsError<T, E>(_ expression: @autoclosure () throws -> T
XCTAssertTrue((errorThrown as? E) == error, typeMessage, file: file, line: line)
}
}
#endif
Loading

0 comments on commit bc84594

Please sign in to comment.