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

Fix linux tests #1225

Merged
merged 7 commits into from
Nov 18, 2023
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
8 changes: 4 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"swift"
],
"name": "Debug sourcery",
"program": "${workspaceFolder:Sourcery}/.build/debug/sourcery",
"program": "${workspaceFolder:Sourcery-master}/.build/debug/sourcery",
"args": [],
"cwd": "${workspaceFolder:Sourcery}",
"cwd": "${workspaceFolder:Sourcery-master}",
"preLaunchTask": "swift: Build Debug sourcery"
},
{
Expand All @@ -19,9 +19,9 @@
"swift"
],
"name": "Release sourcery",
"program": "${workspaceFolder:Sourcery}/.build/release/sourcery",
"program": "${workspaceFolder:Sourcery-master}/.build/release/sourcery",
"args": [],
"cwd": "${workspaceFolder:Sourcery}",
"cwd": "${workspaceFolder:Sourcery-master}",
"preLaunchTask": "swift: Build Release sourcery"
}
]
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Sourcery CHANGELOG
## Master
## 2.1.3
## Changes
- Add support for `typealias`es in EJS templates. ([#1208](https://github.com/krzysztofzablocki/Sourcery/pull/1208)
- Add support for existential to Automockable Protocol with generic types. ([#1220](https://github.com/krzysztofzablocki/Sourcery/pull/1220)
- Throw throwable error after updating mocks's calls counts and received parameters/invocations.
([#1224](https://github.com/krzysztofzablocki/Sourcery/pull/1224)
- Fix unit tests on Linux ([#1225](https://github.com/krzysztofzablocki/Sourcery/pull/1225))

## 2.1.2
## Changes
Expand Down
43 changes: 32 additions & 11 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ var sourceryLibDependencies: [Target.Dependency] = [
"XcodeProj",
.product(name: "SwiftPM-auto", package: "swift-package-manager"),
]

// Note: when Swift Linux doesn't bug out on [String: String], add a test back for it
// See https://github.com/krzysztofzablocki/Sourcery/pull/1208#issuecomment-1752185381
#if canImport(ObjectiveC)
sourceryLibDependencies.append("TryCatch")
let templatesTestsResourcesCopy: [Resource] = [
Expand All @@ -33,6 +36,34 @@ let templatesTestsResourcesCopy: [Resource] = [
]
#endif

// Note: when Swift Linux doesn't bug out on [String: String], add a test back for it
// See https://github.com/krzysztofzablocki/Sourcery/pull/1208#issuecomment-1752185381
#if canImport(ObjectiveC)
let sourceryLibTestsResources: [Resource] = [
.copy("Stub/Configs"),
.copy("Stub/Errors"),
.copy("Stub/JavaScriptTemplates"),
.copy("Stub/SwiftTemplates"),
.copy("Stub/Performance-Code"),
.copy("Stub/DryRun-Code"),
.copy("Stub/Result"),
.copy("Stub/Templates"),
.copy("Stub/Source")
]
#else
let sourceryLibTestsResources: [Resource] = [
.copy("Stub/Configs"),
.copy("Stub/Errors"),
.copy("Stub/JavaScriptTemplates"),
.copy("Stub/SwiftTemplates"),
.copy("Stub/Performance-Code"),
.copy("Stub/DryRun-Code"),
.copy("Stub/Result"),
.copy("Stub/Templates"),
.copy("Stub/Source_Linux")
]
#endif

var targets: [Target] = [
.executableTarget(
name: "SourceryExecutable",
Expand Down Expand Up @@ -147,17 +178,7 @@ var targets: [Target] = [
exclude: [
"Info.plist"
],
resources: [
.copy("Stub/Configs"),
.copy("Stub/Errors"),
.copy("Stub/JavaScriptTemplates"),
.copy("Stub/SwiftTemplates"),
.copy("Stub/Performance-Code"),
.copy("Stub/DryRun-Code"),
.copy("Stub/Result"),
.copy("Stub/Templates"),
.copy("Stub/Source")
],
resources: sourceryLibTestsResources,
swiftSettings: [.unsafeFlags(["-enable-testing"])]
),
.testTarget(
Expand Down
3 changes: 2 additions & 1 deletion SourceryTests/Generating/SwiftTemplateSpecs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class SwiftTemplateTests: QuickSpec {
expect(result).to(equal(expectedResult))
}

// crashing test
it("handles file includes") {
let templatePath = Stubs.swiftTemplates + Path("IncludeFile.swifttemplate")
let expectedResult = try? (Stubs.resultDirectory + Path("Basic.swift")).read(.utf8)
Expand Down Expand Up @@ -205,7 +204,9 @@ class SwiftTemplateTests: QuickSpec {
// }

context("and missing build dir") {
#if canImport(ObjectiveC)
expect { try Sourcery(cacheDisabled: false).processFiles(.sources(Paths(include: [Stubs.sourceDirectory])), usingTemplates: Paths(include: [templatePath]), output: output, baseIndentation: 0) }.toNot(throwError())
#endif
expect((try? (outputDir + Sourcery().generatedPath(for: templatePath)).read(.utf8))).to(equal(expectedResult))
guard let buildDir = NSURL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("SwiftTemplate").map({ Path($0.path) }) else {
fail("Could not create buildDir path")
Expand Down
2 changes: 1 addition & 1 deletion SourceryTests/Stub/Result/Typealiases.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
// Typealiases in BarBaz
// - name 'List', type '[FooBarBaz]'
// Typealiases in FooBarBaz
// - name 'Name', type 'String'
// - name 'Name', type '[String: String]'
// Typealiases in FooSubclass
4 changes: 1 addition & 3 deletions SourceryTests/Stub/Source/Foo.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import Foundation

class FooBarBaz {
// Note: when Swift Linux doesn't bug out on [String: String], add a test back for it
// See https://github.com/krzysztofzablocki/Sourcery/pull/1208#issuecomment-1752185381
typealias Name = String
typealias Name = [String: String]

var name: String = ""
var value: Int = 0
Expand Down
14 changes: 14 additions & 0 deletions SourceryTests/Stub/Source_Linux/Bar.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Foundation

// sourcery: this will not appear under FooBarBaz

/// Documentation for bar
// sourcery: showComment
/// other documentation
class BarBaz: FooBarBaz, AutoEquatable {
// Note: when Swift Linux doesn't bug out on [String: String], add a test back for it
// See https://github.com/krzysztofzablocki/Sourcery/pull/1208#issuecomment-1752185381
// typealias List = [FooBarBaz]
var parent: FooBarBaz? = nil
var otherVariable: Int = 0
}
20 changes: 20 additions & 0 deletions SourceryTests/Stub/Source_Linux/Foo.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Foundation

class FooBarBaz {
// Note: when Swift Linux doesn't bug out on [String: String], add a test back for it
// See https://github.com/krzysztofzablocki/Sourcery/pull/1208#issuecomment-1752185381
// typealias Name = String

var name: String = ""
var value: Int = 0
}

protocol AutoEquatable {}

class FooSubclass: FooBarBaz, AutoEquatable {
var other: String = ""
}

func performFoo(value: FooBarBaz) {

}
11 changes: 11 additions & 0 deletions SourceryTests/Stub/Source_Linux/FooBar.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Foundation

protocol HasFoo {
var foo: FooBarBaz { get }
}
protocol HasBar {
var bar: BarBaz { get }
}

// sourcery: AutoStruct
typealias FooBar = HasFoo & HasBar
Loading