Add acceptance tests
This commit is contained in:
parent
87f964b8eb
commit
d5f70c400a
|
@ -16,7 +16,7 @@ class EditCommand: NSObject, Command {
|
|||
private let projectEditor: ProjectEditing
|
||||
private let opener: Opening
|
||||
private let pathArgument: OptionArgument<String>
|
||||
private let nonTemporaryArgument: OptionArgument<Bool>
|
||||
private let permanentArgument: OptionArgument<Bool>
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
|
@ -32,29 +32,30 @@ class EditCommand: NSObject, Command {
|
|||
usage: "The path to the directory whose project will be edited.",
|
||||
completion: .filename)
|
||||
|
||||
nonTemporaryArgument = subparser.add(option: "--non-temporary",
|
||||
shortName: "-n",
|
||||
kind: Bool.self,
|
||||
usage: "It creates the project in the current directory or the one indicated by -p and doesn't block the process.")
|
||||
permanentArgument = subparser.add(option: "--permanent",
|
||||
shortName: "-P",
|
||||
kind: Bool.self,
|
||||
usage: "It creates the project in the current directory or the one indicated by -p and doesn't block the process.")
|
||||
self.projectEditor = projectEditor
|
||||
self.opener = opener
|
||||
}
|
||||
|
||||
func run(with arguments: ArgumentParser.Result) throws {
|
||||
let path = self.path(arguments: arguments)
|
||||
let temporary = self.temporary(arguments: arguments)
|
||||
let generationDirectory = temporary ? EditCommand.temporaryDirectory.path : path
|
||||
let permanent = self.permanent(arguments: arguments)
|
||||
let generationDirectory = permanent ? path : EditCommand.temporaryDirectory.path
|
||||
let xcodeprojPath = try projectEditor.edit(at: path, in: generationDirectory)
|
||||
|
||||
if !temporary {
|
||||
if !permanent {
|
||||
Signals.trap(signals: [.int, .abrt]) { _ in
|
||||
try! FileHandler.shared.delete(EditCommand.temporaryDirectory.path)
|
||||
exit(0)
|
||||
}
|
||||
Printer.shared.print(success: "Opening Xcode to edit the project. Press CTRL + C once you are done editing")
|
||||
try opener.open(path: xcodeprojPath, wait: true)
|
||||
} else {
|
||||
Printer.shared.print(success: "Xcode project generated at \(xcodeprojPath.pathString)")
|
||||
}
|
||||
|
||||
Printer.shared.print("Opening Xcode to edit the project. Press CTRL + C once you are done editing")
|
||||
try opener.open(path: xcodeprojPath, wait: temporary)
|
||||
}
|
||||
|
||||
// MARK: - Fileprivate
|
||||
|
@ -74,11 +75,11 @@ class EditCommand: NSObject, Command {
|
|||
}
|
||||
}
|
||||
|
||||
private func temporary(arguments: ArgumentParser.Result) -> Bool {
|
||||
if let nonTemporary = arguments.get(nonTemporaryArgument) {
|
||||
return !nonTemporary
|
||||
private func permanent(arguments: ArgumentParser.Result) -> Bool {
|
||||
if let permanent = arguments.get(permanentArgument) {
|
||||
return permanent
|
||||
} else {
|
||||
return true
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
Feature: Edit an existing project using Tuist
|
||||
|
||||
Scenario: The project is an application with helpers (ios_app_with_helpers)
|
||||
Given that tuist is available
|
||||
And I have a working directory
|
||||
Then I copy the fixture ios_app_with_helpers into the working directory
|
||||
Then tuist edits the project
|
||||
Then I should be able to build for macOS the scheme ProjectDescriptionHelpers
|
||||
Then I should be able to build for macOS the scheme Manifests
|
|
@ -10,6 +10,12 @@ Then(/tuist generates the project/) do
|
|||
@xcodeproj_path = Dir.glob(File.join(@dir, "*.xcodeproj")).first
|
||||
end
|
||||
|
||||
Then(/tuist edits the project/) do
|
||||
system("swift", "run", "tuist", "edit", "--path", @dir, "--permanent")
|
||||
@workspace_path = Dir.glob(File.join(@dir, "*.xcworkspace")).first
|
||||
@xcodeproj_path = Dir.glob(File.join(@dir, "*.xcodeproj")).first
|
||||
end
|
||||
|
||||
Then(/tuist sets up the project/) do
|
||||
system("swift", "run", "tuist", "up", "--path", @dir)
|
||||
@workspace_path = Dir.glob(File.join(@dir, "*.xcworkspace")).first
|
||||
|
|
|
@ -8,9 +8,10 @@ Then(/I should be able to (.+) for (iOS|macOS|tvOS|watchOS) the scheme (.+)/) do
|
|||
|
||||
args = [
|
||||
"-scheme", scheme,
|
||||
"-workspace", @workspace_path,
|
||||
"-derivedDataPath", @derived_data_path
|
||||
]
|
||||
args.concat(["-workspace", @workspace_path]) unless @workspace_path.nil?
|
||||
args.concat(["-project", @xcodeproj_path]) unless @xcodeproj_path.nil?
|
||||
|
||||
if action == "test" && platform == "iOS"
|
||||
args << "-destination\ \'name=iPhone 11\'"
|
||||
|
|
|
@ -268,3 +268,7 @@ An example of a workspace that has a dependency cycle between targets in differe
|
|||
## ios_app_with_carthage_frameworks
|
||||
|
||||
An example of an iOS app that contains Carthage frameworks \*(fat frameworks with device & simulators architectures)\*. This fixture is useful to test the script that embeds them stripping the architectures that are not necessary.
|
||||
|
||||
## ios_app_with_helpers
|
||||
|
||||
A basic iOS app that has some manifest bits extracted into helpers.
|
|
@ -0,0 +1,66 @@
|
|||
### macOS ###
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
### Xcode ###
|
||||
# Xcode
|
||||
#
|
||||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
|
||||
|
||||
## User settings
|
||||
xcuserdata/
|
||||
|
||||
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
|
||||
*.xcscmblueprint
|
||||
*.xccheckout
|
||||
|
||||
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
|
||||
build/
|
||||
DerivedData/
|
||||
*.moved-aside
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
|
||||
### Xcode Patch ###
|
||||
*.xcodeproj/*
|
||||
!*.xcodeproj/project.pbxproj
|
||||
!*.xcodeproj/xcshareddata/
|
||||
!*.xcworkspace/contents.xcworkspacedata
|
||||
/*.gcno
|
||||
|
||||
### Projects ###
|
||||
*.xcodeproj
|
||||
*.xcworkspace
|
||||
|
||||
### Tuist derived files ###
|
||||
graph.dot
|
|
@ -0,0 +1,6 @@
|
|||
import ProjectDescription
|
||||
import ProjectDescriptionHelpers
|
||||
|
||||
let project = Project.app(name: "App", platform: .iOS, dependencies: [
|
||||
.project(target: "AppKit", path: .relativeToManifest("../AppKit"))
|
||||
])
|
|
@ -0,0 +1,21 @@
|
|||
import UIKit
|
||||
import ios_app_with_helpersKit
|
||||
|
||||
@UIApplicationMain
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
var window: UIWindow?
|
||||
|
||||
func application(
|
||||
_ application: UIApplication,
|
||||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil
|
||||
) -> Bool {
|
||||
window = UIWindow(frame: UIScreen.main.bounds)
|
||||
let viewController = UIViewController()
|
||||
viewController.view.backgroundColor = .white
|
||||
window?.rootViewController = viewController
|
||||
window?.makeKeyAndVisible()
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
|
||||
@testable import ios_app_with_helpers
|
||||
|
||||
final class ios_app_with_helpersTests: XCTestCase {
|
||||
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
import ProjectDescription
|
||||
import ProjectDescriptionHelpers
|
||||
|
||||
let project = Project.framework(name: "AppKit", platform: .iOS, dependencies: [
|
||||
.project(target: "AppSupport", path: .relativeToManifest("../AppSupport"))
|
||||
])
|
|
@ -0,0 +1,4 @@
|
|||
import Foundation
|
||||
import ios_app_with_helpersSupport
|
||||
|
||||
public final class ios_app_with_helpers {}
|
|
@ -0,0 +1,8 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
|
||||
@testable import ios_app_with_helpersKit
|
||||
|
||||
final class ios_app_with_helpersKitTests: XCTestCase {
|
||||
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
import ProjectDescription
|
||||
import ProjectDescriptionHelpers
|
||||
|
||||
let project = Project.framework(name: "AppSupport", platform: .iOS, dependencies: [])
|
|
@ -0,0 +1,3 @@
|
|||
import Foundation
|
||||
|
||||
public final class ios_app_with_helpers {}
|
|
@ -0,0 +1,8 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
|
||||
@testable import ios_app_with_helpersSupport
|
||||
|
||||
final class ios_app_with_helpersSupportTests: XCTestCase {
|
||||
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
import ProjectDescription
|
||||
|
||||
let setup = Setup([
|
||||
// .homebrew(packages: ["swiftlint", "carthage"]),
|
||||
// .carthage()
|
||||
])
|
|
@ -0,0 +1,43 @@
|
|||
import ProjectDescription
|
||||
|
||||
extension Project {
|
||||
|
||||
public static func app(name: String, platform: Platform, dependencies: [TargetDependency] = []) -> Project {
|
||||
return self.project(name: name, product: .app, platform: platform, dependencies: dependencies, infoPlist: [
|
||||
"CFBundleShortVersionString": "1.0",
|
||||
"CFBundleVersion": "1"
|
||||
])
|
||||
}
|
||||
|
||||
public static func framework(name: String, platform: Platform, dependencies: [TargetDependency] = []) -> Project {
|
||||
return self.project(name: name, product: .framework, platform: platform, dependencies: dependencies)
|
||||
}
|
||||
|
||||
public static func project(name: String,
|
||||
product: Product,
|
||||
platform: Platform,
|
||||
dependencies: [TargetDependency] = [],
|
||||
infoPlist: [String: InfoPlist.Value] = [:]) -> Project {
|
||||
return Project(name: name,
|
||||
targets: [
|
||||
Target(name: name,
|
||||
platform: platform,
|
||||
product: product,
|
||||
bundleId: "io.tuist.\(name)",
|
||||
infoPlist: .extendingDefault(with: infoPlist),
|
||||
sources: ["Sources/**"],
|
||||
resources: [],
|
||||
dependencies: dependencies),
|
||||
Target(name: "\(name)Tests",
|
||||
platform: platform,
|
||||
product: .unitTests,
|
||||
bundleId: "io.tuist.\(name)Tests",
|
||||
infoPlist: .default,
|
||||
sources: "Tests/**",
|
||||
dependencies: [
|
||||
.target(name: "\(name)")
|
||||
])
|
||||
])
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import ProjectDescription
|
||||
|
||||
let config = TuistConfig(generationOptions: [
|
||||
.generateManifest
|
||||
])
|
|
@ -0,0 +1,8 @@
|
|||
import ProjectDescription
|
||||
import ProjectDescriptionHelpers
|
||||
|
||||
let workspace = Workspace(name: "App", projects: [
|
||||
"Projects/App",
|
||||
"Projects/AppKit",
|
||||
"Projects/AppSupport"
|
||||
])
|
Loading…
Reference in New Issue