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

Update fork #1

Merged
merged 5 commits into from
Mar 14, 2022
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ xcuserdata
*.xcuserstate
XcodeGen.xcodeproj
xcodegen.zip
.vscode/launch.json
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@

## Next Version

### Fixed

- Fixed crash caused by a simultaneous write during a glob processing [#1177](https://github.com/yonaskolb/XcodeGen/issues/1177) @tr1ckyf0x

## 2.26.0

### Added

- Added the option to specify a `location` in a test target [#1150](https://github.com/yonaskolb/XcodeGen/issues/1150) @KrisRJack

### Changed

- Speed up source inclusion checking for big projects [#1122](https://github.com/yonaskolb/XcodeGen/pull/1122) @PaulTaykalo

[Commits](https://github.com/yonaskolb/XcodeGen/compare/2.25.0...2.26.0)

## 2.25.0

### Added
Expand Down
1 change: 1 addition & 0 deletions Docs/ProjectSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,7 @@ A multiline script can be written using the various YAML multiline methods, for
- [x] **name**: **String** - The name of the target
- [ ] **parallelizable**: **Bool** - Whether to run tests in parallel. Defaults to false
- [ ] **randomExecutionOrder**: **Bool** - Whether to run tests in a random order. Defaults to false
- [ ] **location**: **String** - GPX file or predefined value for simulating location. See [Simulate Location](#simulate-location) for location examples.
- [ ] **skipped**: **Bool** - Whether to skip all of the test target tests. Defaults to false
- [ ] **skippedTests**: **[String]** - List of tests in the test target to skip. Defaults to empty
- [ ] **selectedTests**: **[String]** - List of tests in the test target to whitelist and select. Defaults to empty. This will override `skippedTests` if provided
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TOOL_NAME = XcodeGen
export EXECUTABLE_NAME = xcodegen
VERSION = 2.25.0
VERSION = 2.26.0

PREFIX = /usr/local
INSTALL_PATH = $(PREFIX)/bin/$(EXECUTABLE_NAME)
Expand Down Expand Up @@ -46,4 +46,4 @@ brew:
brew bump-formula-pr --url=$(RELEASE_TAR) XcodeGen

archive: build
./scripts/archive.sh $(EXECUTABLE_PATH)
./scripts/archive.sh "$(EXECUTABLE_PATH)"
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@
"repositoryURL": "https://github.com/tuist/XcodeProj.git",
"state": {
"branch": null,
"revision": "446f3a0db73e141c7f57e26fcdb043096b1db52c",
"version": "8.3.1"
"revision": "aa2a42c7a744ca18b5918771fdd6cf40f9753db5",
"version": "8.6.0"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let package = Package(
.package(url: "https://github.com/yonaskolb/JSONUtilities.git", from: "4.2.0"),
.package(url: "https://github.com/kylef/Spectre.git", from: "0.9.2"),
.package(url: "https://github.com/onevcat/Rainbow.git", from: "3.0.0"),
.package(url: "https://github.com/tuist/XcodeProj.git", from: "8.3.1"),
.package(url: "https://github.com/tuist/XcodeProj.git", from: "8.6.0"),
.package(url: "https://github.com/jakeheis/SwiftCLI.git", from: "6.0.3"),
.package(url: "https://github.com/mxcl/Version", from: "2.0.0"),
.package(url: "https://github.com/SwiftDocOrg/GraphViz.git", .exact("0.2.0")),
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ swift run xcodegen
Add the following to your Package.swift file's dependencies:

```swift
.package(url: "https://github.com/yonaskolb/XcodeGen.git", from: "2.25.0"),
.package(url: "https://github.com/yonaskolb/XcodeGen.git", from: "2.26.0"),
```

And then import wherever needed: `import XcodeGenKit`
Expand Down
9 changes: 9 additions & 0 deletions Sources/ProjectSpec/Scheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,15 @@ public struct Scheme: Equatable {
public var deleteScreenshotsWhenEachTestSucceeds: Bool

public struct TestTarget: Equatable, ExpressibleByStringLiteral {

public static let randomExecutionOrderDefault = false
public static let parallelizableDefault = false

public var name: String { targetReference.name }
public let targetReference: TargetReference
public var randomExecutionOrder: Bool
public var parallelizable: Bool
public var location: String?
public var skipped: Bool
public var skippedTests: [String]
public var selectedTests: [String]
Expand All @@ -199,13 +201,15 @@ public struct Scheme: Equatable {
targetReference: TargetReference,
randomExecutionOrder: Bool = randomExecutionOrderDefault,
parallelizable: Bool = parallelizableDefault,
location: String? = nil,
skipped: Bool = false,
skippedTests: [String] = [],
selectedTests: [String] = []
) {
self.targetReference = targetReference
self.randomExecutionOrder = randomExecutionOrder
self.parallelizable = parallelizable
self.location = location
self.skipped = skipped
self.skippedTests = skippedTests
self.selectedTests = selectedTests
Expand All @@ -216,6 +220,7 @@ public struct Scheme: Equatable {
targetReference = try TargetReference(value)
randomExecutionOrder = false
parallelizable = false
location = nil
skipped = false
skippedTests = []
selectedTests = []
Expand Down Expand Up @@ -536,6 +541,7 @@ extension Scheme.Test.TestTarget: JSONObjectConvertible {
targetReference = try TargetReference(jsonDictionary.json(atKeyPath: "name"))
randomExecutionOrder = jsonDictionary.json(atKeyPath: "randomExecutionOrder") ?? Scheme.Test.TestTarget.randomExecutionOrderDefault
parallelizable = jsonDictionary.json(atKeyPath: "parallelizable") ?? Scheme.Test.TestTarget.parallelizableDefault
location = jsonDictionary.json(atKeyPath: "location") ?? nil
skipped = jsonDictionary.json(atKeyPath: "skipped") ?? false
skippedTests = jsonDictionary.json(atKeyPath: "skippedTests") ?? []
selectedTests = jsonDictionary.json(atKeyPath: "selectedTests") ?? []
Expand All @@ -559,6 +565,9 @@ extension Scheme.Test.TestTarget: JSONEncodable {
if parallelizable != Scheme.Test.TestTarget.parallelizableDefault {
dict["parallelizable"] = parallelizable
}
if let location = location {
dict["location"] = location
}
if skipped {
dict["skipped"] = skipped
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/XcodeGen/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import ProjectSpec
import XcodeGenCLI
import Version

let version = Version("2.25.0")
let version = Version("2.26.0")
let cli = XcodeGenCLI(version: version)
cli.execute()
27 changes: 27 additions & 0 deletions Sources/XcodeGenCore/Atomic.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// Atomic.swift
//
//
// Created by Vladislav Lisianskii on 23.02.2022.
//

import Foundation

@propertyWrapper
struct Atomic<Value> {
private let queue = DispatchQueue(label: "com.xcodegencore.atomic")
private var value: Value

init(wrappedValue: Value) {
self.value = wrappedValue
}

var wrappedValue: Value {
get {
return queue.sync { value }
}
set {
queue.sync { value = newValue }
}
}
}
2 changes: 1 addition & 1 deletion Sources/XcodeGenCore/Glob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class Glob: Collection {

public static let defaultBlacklistedDirectories = ["node_modules", "Pods"]

private var isDirectoryCache = [String: Bool]()
@Atomic private var isDirectoryCache = [String: Bool]()

public let behavior: Behavior
public let blacklistedDirectories: [String]
Expand Down
22 changes: 19 additions & 3 deletions Sources/XcodeGenKit/SchemeGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,28 @@ public class SchemeGenerator {
runPostActionsOnFailure: scheme.build.runPostActionsOnFailure
)

let testables = zip(testTargets, testBuildTargetEntries).map { testTarget, testBuilEntries in
XCScheme.TestableReference(
let testables: [XCScheme.TestableReference] = zip(testTargets, testBuildTargetEntries).map { testTarget, testBuildEntries in

var locationScenarioReference: XCScheme.LocationScenarioReference?
if var location = testTarget.location {

if location.contains(".gpx") {
var path = Path(components: [project.options.schemePathPrefix, location])
path = path.simplifyingParentDirectoryReferences()
location = path.string
}

let referenceType = location.contains(".gpx") ? "0" : "1"
locationScenarioReference = XCScheme.LocationScenarioReference(identifier: location, referenceType: referenceType)

}

return XCScheme.TestableReference(
skipped: testTarget.skipped,
parallelizable: testTarget.parallelizable,
randomExecutionOrdering: testTarget.randomExecutionOrder,
buildableReference: testBuilEntries.buildableReference,
buildableReference: testBuildEntries.buildableReference,
locationScenarioReference: locationScenarioReference,
skippedTests: testTarget.skippedTests.map(XCScheme.TestItem.init),
selectedTests: testTarget.selectedTests.map(XCScheme.TestItem.init),
useTestSelectionWhitelist: !testTarget.selectedTests.isEmpty ? true : nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
BlueprintName = "App_iOS_Tests"
ReferencedContainer = "container:Project.xcodeproj">
</BuildableReference>
<LocationScenarioReference
identifier = "New York, NY, USA"
referenceType = "1">
</LocationScenarioReference>
</TestableReference>
</Testables>
<MacroExpansion>
Expand Down
1 change: 1 addition & 0 deletions Tests/Fixtures/TestProject/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ schemes:
- name: App_iOS_Tests
parallelizable: true
randomExecutionOrder: true
location: New York, NY, USA
customLLDBInit: ${SRCROOT}/.lldbinit
targetTemplates:
MyTemplate:
Expand Down
4 changes: 4 additions & 0 deletions Tests/ProjectSpecTests/SpecLoadingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ class SpecLoadingTests: XCTestCase {
"name": "ExternalProject/Target2",
"parallelizable": true,
"skipped": true,
"location": "test.gpx",
"randomExecutionOrder": true,
"skippedTests": ["Test/testExample()"],
],
Expand Down Expand Up @@ -836,6 +837,7 @@ class SpecLoadingTests: XCTestCase {
targetReference: "ExternalProject/Target2",
randomExecutionOrder: true,
parallelizable: true,
location: "test.gpx",
skipped: true,
skippedTests: ["Test/testExample()"]
),
Expand All @@ -856,6 +858,7 @@ class SpecLoadingTests: XCTestCase {
[
"name": "ExternalProject/Target2",
"parallelizable": true,
"location": "New York, NY, USA",
"randomExecutionOrder": true,
"selectedTests": ["Test/testExample()"],
],
Expand All @@ -877,6 +880,7 @@ class SpecLoadingTests: XCTestCase {
targetReference: "ExternalProject/Target2",
randomExecutionOrder: true,
parallelizable: true,
location: "New York, NY, USA",
selectedTests: ["Test/testExample()"]
),
]
Expand Down
14 changes: 12 additions & 2 deletions Tests/XcodeGenKitTests/SchemeGeneratorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,14 @@ class SchemeGeneratorTests: XCTestCase {
let preAction = Scheme.ExecutionAction(name: "Script", script: "echo Starting", settingsTarget: app.name)
let simulateLocation = Scheme.SimulateLocation(allow: true, defaultLocation: "New York, NY, USA")
let storeKitConfiguration = "Configuration.storekit"
let scheme = Scheme(
let scheme = try Scheme(
name: "MyScheme",
build: Scheme.Build(targets: [buildTarget], preActions: [preAction]),
run: Scheme.Run(config: "Debug", askForAppToLaunch: true, launchAutomaticallySubstyle: "2", simulateLocation: simulateLocation, storeKitConfiguration: storeKitConfiguration, customLLDBInit: "/sample/.lldbinit"),
test: Scheme.Test(config: "Debug", customLLDBInit: "/test/.lldbinit"),
test: Scheme.Test(config: "Debug", targets: [
Scheme.Test.TestTarget(targetReference: TargetReference(framework.name), location: "test.gpx"),
Scheme.Test.TestTarget(targetReference: TargetReference(framework.name), location: "New York, NY, USA")
], customLLDBInit: "/test/.lldbinit"),
profile: Scheme.Profile(config: "Release", askForAppToLaunch: true)
)
let project = Project(
Expand Down Expand Up @@ -109,6 +112,13 @@ class SchemeGeneratorTests: XCTestCase {
try expect(xcscheme.launchAction?.customLLDBInitFile) == "/sample/.lldbinit"
try expect(xcscheme.testAction?.customLLDBInitFile) == "/test/.lldbinit"
try expect(xcscheme.testAction?.systemAttachmentLifetime).to.beNil()

try expect(xcscheme.testAction?.testables[0].locationScenarioReference?.referenceType) == "0"
try expect(xcscheme.testAction?.testables[0].locationScenarioReference?.identifier) == "../test.gpx"

try expect(xcscheme.testAction?.testables[1].locationScenarioReference?.referenceType) == "1"
try expect(xcscheme.testAction?.testables[1].locationScenarioReference?.identifier) == "New York, NY, USA"

}

let frameworkTarget = Scheme.BuildTarget(target: .local(framework.name), buildTypes: [.archiving])
Expand Down
2 changes: 1 addition & 1 deletion scripts/archive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LICENSE=LICENSE
# copy

mkdir -p $BINDIR
cp -f $1 $BINDIR
cp -f "$1" $BINDIR

mkdir -p $SHAREDIR
cp -R SettingPresets $SHAREDIR/SettingPresets
Expand Down