diff --git a/.swiftformat b/.swiftformat index da563d461..90f81d0ea 100644 --- a/.swiftformat +++ b/.swiftformat @@ -3,4 +3,4 @@ --exclude Tests/Fixtures/ --exclude Tests/AccessibilityTests/AccessibilityProject/ --exclude Tests/XcodeTests/UIKitProject/ ---exclude Tests/XcodeTests/SwiftUIProject/ \ No newline at end of file +--exclude Tests/XcodeTests/SwiftUIProject/ diff --git a/.swiftlint.yml b/.swiftlint.yml index 556cff3d2..ee8faf64e 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -1,68 +1,38 @@ -included: - - Sources - - Tests - - Package.swift excluded: + - .build - Tests/Fixtures - Tests/AccessibilityTests/AccessibilityProject - Tests/XcodeTests/UIKitProject + - Tests/XcodeTests/SwiftUIProject -# Enabled/disabled rules -analyzer_rules: - - all opt_in_rules: - - all + - single_test_class + disabled_rules: - - anyobject_protocol - - inert_defer - - unused_capture_list - - explicit_acl - - explicit_type_interface - - missing_docs - - required_deinit - - line_length - - type_contents_order - - prefer_nimble - - explicit_top_level_acl + # Formatting is handled by SwiftFormat + - trailing_comma + - opening_brace + - vertical_parameter_alignment_on_call + - let_var_whitespace + - indentation_width + - attributes - anonymous_argument_in_multiline_closure - - one_declaration_per_file - - conditional_returns_on_newline - vertical_whitespace_between_cases - - no_grouping_extension - - explicit_enum_raw_value - - file_types_order - - indentation_width - - identifier_name - - trailing_closure - - multiline_arguments_brackets - - multiline_function_chains - - no_extension_access_modifier - - force_try - - switch_case_on_newline - - sorted_enum_cases - - prefer_self_in_static_references - - superfluous_else - - force_unwrapping - - file_name - - todo - - no_magic_numbers - - prefixed_toplevel_constant - - untyped_error_in_catch + + # Length/size rules - cyclomatic_complexity - closure_body_length - function_body_length - type_body_length - - file_length - - contrasted_opening_brace - - unused_parameter - - no_empty_block - - prefer_key_path + - file_length + - line_length + - identifier_name + - type_name + - large_tuple + - function_parameter_count -balanced_xctest_lifecycle: &unit_test_configuration - test_parent_classes: - - SourceGraphTestCase - - FixtureSourceGraphTestCase - - XCTestCase -empty_xctest_method: *unit_test_configuration -final_test_case: *unit_test_configuration -single_test_class: *unit_test_configuration + # Other + - discouraged_optional_collection + - non_optional_string_data_conversion # https://github.com/realm/SwiftLint/issues/5263#issuecomment-2115182747 + - balanced_xctest_lifecycle + - todo diff --git a/Makefile b/Makefile index e179b1030..5f6366acd 100644 --- a/Makefile +++ b/Makefile @@ -22,4 +22,9 @@ show_bin_path: @echo ${EXECUTABLE} swiftformat: - @./scripts/lint/swiftformat.sh \ No newline at end of file + @./scripts/lint/swiftformat.sh + +swiftlint: + @./scripts/lint/swiftlint.sh + +lint: swiftlint swiftformat \ No newline at end of file diff --git a/Sources/Frontend/UpdateChecker.swift b/Sources/Frontend/UpdateChecker.swift index 83fc25bd5..4e7de130d 100644 --- a/Sources/Frontend/UpdateChecker.swift +++ b/Sources/Frontend/UpdateChecker.swift @@ -39,13 +39,12 @@ final class UpdateChecker { urlRequest.setValue("application/vnd.github.v3+json", forHTTPHeaderField: "Accept") let task = urlSession.dataTask(with: urlRequest) { [weak self] data, _, error in - // swiftlint:disable:next self_binding - guard let strongSelf = self else { return } + guard let self else { return } if let error { - strongSelf.debugLogger.debug("error: \(error.localizedDescription)") - strongSelf.error = error - strongSelf.semaphore.signal() + debugLogger.debug("error: \(error.localizedDescription)") + self.error = error + semaphore.signal() return } @@ -63,14 +62,14 @@ final class UpdateChecker { } let message = "Failed to identify latest release tag in: \(json)" - strongSelf.error = PeripheryError.updateCheckError(message: message) - strongSelf.debugLogger.debug(message) - strongSelf.semaphore.signal() + self.error = PeripheryError.updateCheckError(message: message) + debugLogger.debug(message) + semaphore.signal() return } - strongSelf.latestVersion = tagName - strongSelf.semaphore.signal() + latestVersion = tagName + semaphore.signal() } task.resume() diff --git a/Sources/PeripheryKit/Results/CsvFormatter.swift b/Sources/PeripheryKit/Results/CsvFormatter.swift index 280f70122..07d082279 100644 --- a/Sources/PeripheryKit/Results/CsvFormatter.swift +++ b/Sources/PeripheryKit/Results/CsvFormatter.swift @@ -52,7 +52,6 @@ final class CsvFormatter: OutputFormatter { // MARK: - Private - // swiftlint:disable:next function_parameter_count private func format( kind: String, name: String?, diff --git a/Sources/PeripheryKit/Results/OutputFormatter.swift b/Sources/PeripheryKit/Results/OutputFormatter.swift index 807ea3ad0..d388f9c4f 100644 --- a/Sources/PeripheryKit/Results/OutputFormatter.swift +++ b/Sources/PeripheryKit/Results/OutputFormatter.swift @@ -39,7 +39,6 @@ extension OutputFormatter { var secondaryResults: [(Location, String)] = [] if var name = result.declaration.name { - // swiftlint:disable:next identifier_name if let kind = result.declaration.kind.displayName, let first_ = kind.first { let first = String(first_) description += "\(first.uppercased())\(kind.dropFirst()) " @@ -95,7 +94,6 @@ extension OutputFormatter { } } -// swiftlint:disable:next no_extension_access_modifier public extension OutputFormat { var formatter: OutputFormatter.Type { switch self { diff --git a/Sources/ProjectDrivers/XcodeProjectDriver.swift b/Sources/ProjectDrivers/XcodeProjectDriver.swift index 1d67b53fd..1e52b1c59 100644 --- a/Sources/ProjectDrivers/XcodeProjectDriver.swift +++ b/Sources/ProjectDrivers/XcodeProjectDriver.swift @@ -53,7 +53,6 @@ private let project: XcodeProjectlike private let schemes: Set - // swiftlint:disable:next function_default_parameter_at_end init( logger: Logger = .init(), configuration: Configuration, diff --git a/Sources/Shared/Configuration.swift b/Sources/Shared/Configuration.swift index a0bed551f..de43a10ae 100644 --- a/Sources/Shared/Configuration.swift +++ b/Sources/Shared/Configuration.swift @@ -144,10 +144,8 @@ public final class Configuration { public func asYaml() throws -> String { var config: [String: Any?] = [:] - for setting in settings { - if setting.hasNonDefaultValue { - config[setting.key] = setting.wrappedValue - } + for setting in settings where setting.hasNonDefaultValue { + config[setting.key] = setting.wrappedValue } return try Yams.dump(object: config) @@ -187,7 +185,6 @@ public final class Configuration { } } - // swiftlint:disable:next discouraged_optional_collection private var _indexExcludeMatchers: [FilenameMatcher]? public var indexExcludeMatchers: [FilenameMatcher] { if let _indexExcludeMatchers { @@ -199,7 +196,6 @@ public final class Configuration { return matchers } - // swiftlint:disable:next discouraged_optional_collection private var _retainFilesMatchers: [FilenameMatcher]? public var retainFilesMatchers: [FilenameMatcher] { if let _retainFilesMatchers { @@ -263,7 +259,7 @@ protocol AbstractSetting { private let setter: Setter private var value: Value - fileprivate init( + init( key: String, defaultValue: Value, setter: @escaping Setter = { $0 as? Value } @@ -292,7 +288,6 @@ protocol AbstractSetting { func reset() { wrappedValue = defaultValue } - // swiftlint:enable strict_fileprivate } private let filePathSetter: (Any) -> FilePath? = { value in diff --git a/Sources/Shared/Extensions/Array+Extension.swift b/Sources/Shared/Extensions/Array+Extension.swift index ed0a26c21..48aaba5b0 100644 --- a/Sources/Shared/Extensions/Array+Extension.swift +++ b/Sources/Shared/Extensions/Array+Extension.swift @@ -3,7 +3,6 @@ import Foundation public extension Array { @inlinable func group(by transform: (Element) -> U) -> [U: [Element]] { - // swiftlint:disable:next reduce_into reduce([:]) { dictionary, element in var dictionary = dictionary let key = transform(element) diff --git a/Sources/Shared/Extensions/FilePath+Glob.swift b/Sources/Shared/Extensions/FilePath+Glob.swift index eae07c6a3..788f28276 100644 --- a/Sources/Shared/Extensions/FilePath+Glob.swift +++ b/Sources/Shared/Extensions/FilePath+Glob.swift @@ -1,4 +1,3 @@ -// swiftlint:disable file_header // Created by Eric Firestone on 3/22/16. // Copyright © 2016 Square, Inc. All rights reserved. // Released under the Apache v2 License. @@ -31,7 +30,6 @@ private class Glob { private let logger: Logger private var isDirectoryCache: [String: Bool] = [:] - // swiftlint:disable:next strict_fileprivate fileprivate var paths: Set = [] init( @@ -99,7 +97,6 @@ private class Glob { for directory in directories { let partiallyResolvedPattern = directory.appendingPathComponent(lastPart) - // swiftlint:disable:next legacy_objc_type let standardizedPattern = (partiallyResolvedPattern.relativePath as NSString).standardizingPath results.append(contentsOf: expandGlobstar(pattern: standardizedPattern)) } diff --git a/Sources/Shared/Shell.swift b/Sources/Shared/Shell.swift index 4db373d57..86c602c9b 100644 --- a/Sources/Shared/Shell.swift +++ b/Sources/Shared/Shell.swift @@ -54,7 +54,7 @@ open class Shell { stderr: Bool = true ) throws -> String { let env = environment - let (status, output) = try exec(args, stderr: stderr, environment: env) + let (status, output) = try exec(args, environment: env, stderr: stderr) if status == 0 { return output @@ -73,7 +73,7 @@ open class Shell { stderr: Bool = true ) throws -> Int32 { let env = environment - let (status, _) = try exec(args, stderr: stderr, captureOutput: false, environment: env) + let (status, _) = try exec(args, environment: env, stderr: stderr, captureOutput: false) return status } @@ -81,9 +81,9 @@ open class Shell { private func exec( _ args: [String], + environment: [String: String], stderr: Bool = false, - captureOutput: Bool = true, - environment: [String: String] + captureOutput: Bool = true ) throws -> (Int32, String) { let launchPath: String let newArgs: [String] diff --git a/Sources/Shared/SwiftVersion.swift b/Sources/Shared/SwiftVersion.swift index aa19effbf..dbc711867 100644 --- a/Sources/Shared/SwiftVersion.swift +++ b/Sources/Shared/SwiftVersion.swift @@ -9,8 +9,8 @@ public struct SwiftVersion { public let fullVersion: String init(shell: Shell = .shared) { - fullVersion = try! shell.exec(["swift", "-version"]).trimmed - version = try! SwiftVersionParser.parse(fullVersion) + fullVersion = try! shell.exec(["swift", "-version"]).trimmed // swiftlint:disable:this force_try + version = try! SwiftVersionParser.parse(fullVersion) // swiftlint:disable:this force_try } public func validateVersion() throws { diff --git a/Sources/SourceGraph/Mutators/ExternalTypeProtocolConformanceReferenceRemover.swift b/Sources/SourceGraph/Mutators/ExternalTypeProtocolConformanceReferenceRemover.swift index 84bfde6d0..b3db554bb 100644 --- a/Sources/SourceGraph/Mutators/ExternalTypeProtocolConformanceReferenceRemover.swift +++ b/Sources/SourceGraph/Mutators/ExternalTypeProtocolConformanceReferenceRemover.swift @@ -1,7 +1,6 @@ import Foundation import Shared -// swiftlint:disable:next type_name final class ExternalTypeProtocolConformanceReferenceRemover: SourceGraphMutator { private let graph: SourceGraph diff --git a/Sources/SourceGraph/Mutators/GenericClassAndStructConstructorReferenceBuilder.swift b/Sources/SourceGraph/Mutators/GenericClassAndStructConstructorReferenceBuilder.swift index 1daecaf86..f59a0fb99 100644 --- a/Sources/SourceGraph/Mutators/GenericClassAndStructConstructorReferenceBuilder.swift +++ b/Sources/SourceGraph/Mutators/GenericClassAndStructConstructorReferenceBuilder.swift @@ -5,8 +5,6 @@ import Shared /// Constructors on a class/struct with generic type parameters are not referenced despite being used. /// We therefore must reference the constructor from the class/struct. final class GenericClassAndStructConstructorReferenceBuilder: SourceGraphMutator { - // swiftlint:disable:previous type_name - private let graph: SourceGraph required init(graph: SourceGraph, configuration _: Configuration) { diff --git a/Sources/SourceGraph/Mutators/RedundantExplicitPublicAccessibilityMarker.swift b/Sources/SourceGraph/Mutators/RedundantExplicitPublicAccessibilityMarker.swift index 207536987..7bc0becaf 100644 --- a/Sources/SourceGraph/Mutators/RedundantExplicitPublicAccessibilityMarker.swift +++ b/Sources/SourceGraph/Mutators/RedundantExplicitPublicAccessibilityMarker.swift @@ -1,6 +1,5 @@ import Shared -// swiftlint:disable:next type_name final class RedundantExplicitPublicAccessibilityMarker: SourceGraphMutator { private let graph: SourceGraph private let configuration: Configuration diff --git a/Sources/SourceGraph/Mutators/StringInterpolationAppendInterpolationRetainer.swift b/Sources/SourceGraph/Mutators/StringInterpolationAppendInterpolationRetainer.swift index 4ae57cd45..46c42ae26 100644 --- a/Sources/SourceGraph/Mutators/StringInterpolationAppendInterpolationRetainer.swift +++ b/Sources/SourceGraph/Mutators/StringInterpolationAppendInterpolationRetainer.swift @@ -4,7 +4,6 @@ import Shared // https://github.com/apple/swift/issues/56189 // The index store does not contain references to `appendInterpolation` functions from their use in string literals. final class StringInterpolationAppendInterpolationRetainer: SourceGraphMutator { - // swiftlint:disable:previous type_name private let graph: SourceGraph required init(graph: SourceGraph, configuration _: Configuration) { diff --git a/Sources/SourceGraph/Mutators/StructImplicitInitializerReferenceBuilder.swift b/Sources/SourceGraph/Mutators/StructImplicitInitializerReferenceBuilder.swift index 77e092c71..ed6852423 100644 --- a/Sources/SourceGraph/Mutators/StructImplicitInitializerReferenceBuilder.swift +++ b/Sources/SourceGraph/Mutators/StructImplicitInitializerReferenceBuilder.swift @@ -3,7 +3,6 @@ import Shared /// Builds references from struct implicit initializers to the properties it assigns. final class StructImplicitInitializerReferenceBuilder: SourceGraphMutator { - // swiftlint:disable:previous type_name private let graph: SourceGraph init(graph: SourceGraph, configuration _: Configuration) { diff --git a/Sources/SyntaxAnalysis/DeclarationSyntaxVisitor.swift b/Sources/SyntaxAnalysis/DeclarationSyntaxVisitor.swift index d70e3ce4e..213407854 100644 --- a/Sources/SyntaxAnalysis/DeclarationSyntaxVisitor.swift +++ b/Sources/SyntaxAnalysis/DeclarationSyntaxVisitor.swift @@ -3,7 +3,6 @@ import SourceGraph import SwiftSyntax public final class DeclarationSyntaxVisitor: PeripherySyntaxVisitor { - // swiftlint:disable:next large_tuple public typealias Result = ( location: Location, accessibility: Accessibility?, @@ -220,10 +219,8 @@ public final class DeclarationSyntaxVisitor: PeripherySyntaxVisitor { func visitVariableTupleBinding(node: VariableDeclSyntax, pattern: TuplePatternSyntax, typeTuple: TupleTypeElementListSyntax?, initializerTuple: LabeledExprListSyntax?) { let elements = Array(pattern.elements) - // swiftlint:disable array_init let types: [TupleTypeElementSyntax?] = typeTuple?.map { $0 } ?? Array(repeating: nil, count: elements.count) let initializers: [LabeledExprSyntax?] = initializerTuple?.map { $0 } ?? Array(repeating: nil, count: elements.count) - // swiftlint:enable array_init for (element, (type, initializer)) in zip(elements, zip(types, initializers)) { if let elementTuplePattern = element.pattern.as(TuplePatternSyntax.self) { @@ -301,7 +298,6 @@ public final class DeclarationSyntaxVisitor: PeripherySyntaxVisitor { // MARK: - Private - // swiftlint:disable:next function_default_parameter_at_end private func parse( modifiers: DeclModifierListSyntax?, attributes: AttributeListSyntax?, diff --git a/Sources/SyntaxAnalysis/MultiplexingSyntaxVisitor.swift b/Sources/SyntaxAnalysis/MultiplexingSyntaxVisitor.swift index ee150ad4b..abb8bfed2 100644 --- a/Sources/SyntaxAnalysis/MultiplexingSyntaxVisitor.swift +++ b/Sources/SyntaxAnalysis/MultiplexingSyntaxVisitor.swift @@ -48,7 +48,6 @@ public protocol PeripherySyntaxVisitor { func visitPost(_ node: FunctionCallExprSyntax) } -// swiftlint:disable:next extension_access_modifier public extension PeripherySyntaxVisitor { func visit(_: ActorDeclSyntax) {} func visit(_: ClassDeclSyntax) {} diff --git a/Sources/SyntaxAnalysis/UnusedParameterParser.swift b/Sources/SyntaxAnalysis/UnusedParameterParser.swift index 801839543..391a69e22 100644 --- a/Sources/SyntaxAnalysis/UnusedParameterParser.swift +++ b/Sources/SyntaxAnalysis/UnusedParameterParser.swift @@ -319,7 +319,6 @@ struct UnusedParameterParser { collector) } - // swiftlint:disable:next function_parameter_count private func build( function syntax: SyntaxProtocol, attributes: AttributeListSyntax?, diff --git a/Sources/XcodeSupport/Xcodebuild.swift b/Sources/XcodeSupport/Xcodebuild.swift index 9efbf6507..5a2117dac 100644 --- a/Sources/XcodeSupport/Xcodebuild.swift +++ b/Sources/XcodeSupport/Xcodebuild.swift @@ -107,7 +107,6 @@ public final class Xcodebuild { // MARK: - Private - // swiftlint:disable:next discouraged_optional_collection private func deserialize(_ jsonString: String) throws -> [String: Any]? { do { guard let jsonData = jsonString.data(using: .utf8) else { return nil } diff --git a/Tests/.swiftlint.yml b/Tests/.swiftlint.yml new file mode 100644 index 000000000..fe1c569e1 --- /dev/null +++ b/Tests/.swiftlint.yml @@ -0,0 +1,3 @@ +disabled_rules: + - implicitly_unwrapped_optional + - force_try \ No newline at end of file diff --git a/Tests/AccessibilityTests/RedundantPublicAccessibilityTest.swift b/Tests/AccessibilityTests/RedundantPublicAccessibilityTest.swift index e2b9fa33b..61b0316db 100644 --- a/Tests/AccessibilityTests/RedundantPublicAccessibilityTest.swift +++ b/Tests/AccessibilityTests/RedundantPublicAccessibilityTest.swift @@ -1,7 +1,6 @@ @testable import TestShared import XCTest -// swiftlint:disable:next balanced_xctest_lifecycle class RedundantPublicAccessibilityTest: SPMSourceGraphTestCase { override static func setUp() { super.setUp() diff --git a/Tests/PeripheryTests/CrossModuleRetentionTest.swift b/Tests/PeripheryTests/CrossModuleRetentionTest.swift index 06772cba2..3ce66115e 100644 --- a/Tests/PeripheryTests/CrossModuleRetentionTest.swift +++ b/Tests/PeripheryTests/CrossModuleRetentionTest.swift @@ -1,7 +1,6 @@ import SystemPackage @testable import TestShared -// swiftlint:disable:next balanced_xctest_lifecycle final class CrossModuleRetentionTest: SPMSourceGraphTestCase { override static func setUp() { super.setUp() diff --git a/Tests/PeripheryTests/ObjcAccessibleRetentionTest.swift b/Tests/PeripheryTests/ObjcAccessibleRetentionTest.swift index 10c4fdb54..255503da9 100644 --- a/Tests/PeripheryTests/ObjcAccessibleRetentionTest.swift +++ b/Tests/PeripheryTests/ObjcAccessibleRetentionTest.swift @@ -2,7 +2,7 @@ import SystemPackage @testable import TestShared import XCTest -#if os(macOS) // swiftlint:disable:next balanced_xctest_lifecycle +#if os(macOS) final class ObjcAccessibleRetentionTest: FixtureSourceGraphTestCase { let performKnownFailures = false diff --git a/Tests/PeripheryTests/ObjcAnnotatedRetentionTest.swift b/Tests/PeripheryTests/ObjcAnnotatedRetentionTest.swift index a0f8dee25..a2f344343 100644 --- a/Tests/PeripheryTests/ObjcAnnotatedRetentionTest.swift +++ b/Tests/PeripheryTests/ObjcAnnotatedRetentionTest.swift @@ -2,7 +2,7 @@ import SystemPackage @testable import TestShared import XCTest -#if os(macOS) // swiftlint:disable:next balanced_xctest_lifecycle +#if os(macOS) final class ObjcAnnotatedRetentionTest: FixtureSourceGraphTestCase { func testRetainsAnnotatedExtensionDeclarations() { analyze(retainObjcAnnotated: true) { diff --git a/Tests/PeripheryTests/RetentionTest.swift b/Tests/PeripheryTests/RetentionTest.swift index 6e98ad76d..1c48227e0 100644 --- a/Tests/PeripheryTests/RetentionTest.swift +++ b/Tests/PeripheryTests/RetentionTest.swift @@ -137,9 +137,9 @@ final class RetentionTest: FixtureSourceGraphTestCase { assertReferenced(.protocol("FixtureProtocol114")) assertRedundantProtocol("FixtureProtocol114", implementedBy: - .class("FixtureClass114"), // swiftlint:disable vertical_parameter_alignment_on_call + .class("FixtureClass114"), .class("FixtureClass115"), - .struct("FixtureStruct116")) // swiftlint:enable vertical_parameter_alignment_on_call + .struct("FixtureStruct116")) } } diff --git a/Tests/PeripheryTests/Syntax/FunctionVisitTest.swift b/Tests/PeripheryTests/Syntax/FunctionVisitTest.swift index 64c901ebd..ef07c9b38 100644 --- a/Tests/PeripheryTests/Syntax/FunctionVisitTest.swift +++ b/Tests/PeripheryTests/Syntax/FunctionVisitTest.swift @@ -5,7 +5,6 @@ import Foundation import XCTest final class FunctionVisitTest: XCTestCase { - // swiftlint:disable:next implicitly_unwrapped_optional private var results: [Location: DeclarationSyntaxVisitor.Result]! override func setUpWithError() throws { diff --git a/Tests/PeripheryTests/Syntax/PropertyVisitTest.swift b/Tests/PeripheryTests/Syntax/PropertyVisitTest.swift index 67a959d2c..58aa49cbf 100644 --- a/Tests/PeripheryTests/Syntax/PropertyVisitTest.swift +++ b/Tests/PeripheryTests/Syntax/PropertyVisitTest.swift @@ -5,7 +5,6 @@ import Foundation import XCTest final class PropertyVisitTest: XCTestCase { - // swiftlint:disable:next implicitly_unwrapped_optional private var results: [Location: DeclarationSyntaxVisitor.Result]! override func setUpWithError() throws { diff --git a/Tests/PeripheryTests/Syntax/TypeSyntaxInspectorTest.swift b/Tests/PeripheryTests/Syntax/TypeSyntaxInspectorTest.swift index db7480e87..ea44fba69 100644 --- a/Tests/PeripheryTests/Syntax/TypeSyntaxInspectorTest.swift +++ b/Tests/PeripheryTests/Syntax/TypeSyntaxInspectorTest.swift @@ -7,7 +7,6 @@ import SwiftSyntax import XCTest final class TypeSyntaxInspectorTest: XCTestCase { - // swiftlint:disable:next implicitly_unwrapped_optional private var results: [Location: TypeSyntaxInspectorTestVisitor.Result]! override func setUpWithError() throws { diff --git a/Tests/SPMTests/SPMProjectTest.swift b/Tests/SPMTests/SPMProjectTest.swift index 8fc099af1..25ec6b4a0 100644 --- a/Tests/SPMTests/SPMProjectTest.swift +++ b/Tests/SPMTests/SPMProjectTest.swift @@ -1,8 +1,7 @@ @testable import TestShared import XCTest -// swiftlint:disable:next balanced_xctest_lifecycle -class SPMProjectTest: SPMSourceGraphTestCase { +final class SPMProjectTest: SPMSourceGraphTestCase { override static func setUp() { super.setUp() diff --git a/Tests/Shared/FixtureSourceGraphTestCase.swift b/Tests/Shared/FixtureSourceGraphTestCase.swift index 39a34442a..24ce9d685 100644 --- a/Tests/Shared/FixtureSourceGraphTestCase.swift +++ b/Tests/Shared/FixtureSourceGraphTestCase.swift @@ -2,7 +2,6 @@ import SystemPackage import XCTest -// swiftlint:disable:next final_test_case balanced_xctest_lifecycle class FixtureSourceGraphTestCase: SPMSourceGraphTestCase { override static func setUp() { super.setUp() diff --git a/Tests/Shared/SourceGraphTestCase.swift b/Tests/Shared/SourceGraphTestCase.swift index 0935d0465..237c96619 100644 --- a/Tests/Shared/SourceGraphTestCase.swift +++ b/Tests/Shared/SourceGraphTestCase.swift @@ -5,12 +5,9 @@ import Shared import SystemPackage import XCTest -// swiftlint:disable:next blanket_disable_command -// swiftlint:disable test_case_accessibility open class SourceGraphTestCase: XCTestCase { static var plan: IndexPlan! static var configuration: Configuration! - // swiftlint:enable implicitly_unwrapped_optional static var results: [ScanResult] = [] private static var graph = SourceGraph() @@ -195,7 +192,6 @@ open class SourceGraphTestCase: XCTestCase { // MARK: - Private - // swiftlint:disable:next function_default_parameter_at_end discouraged_optional_collection private func materialize(_ description: DeclarationDescription, in defaultDeclarations: Set? = nil, fail: Bool = true, file: StaticString, line: UInt) -> Declaration? { let declarations = scopedDeclarations(from: defaultDeclarations) let matchingDeclarations = declarations.filter { $0.kind == description.kind && $0.name == description.name } @@ -212,7 +208,6 @@ open class SourceGraphTestCase: XCTestCase { return matchedDeclaration } - // swiftlint:disable:next discouraged_optional_collection private func scopedDeclarations(from defaultDeclarations: Set? = nil) -> Set { let allDeclarations = defaultDeclarations ?? Self.graph.rootDeclarations diff --git a/Tests/XcodeTests/ShellMock.swift b/Tests/XcodeTests/ShellMock.swift new file mode 100644 index 000000000..6a7e23acc --- /dev/null +++ b/Tests/XcodeTests/ShellMock.swift @@ -0,0 +1,14 @@ +import Foundation +import Shared + +class ShellMock: Shell { + var output: String = "" + + convenience init() { + self.init(environment: ProcessInfo.processInfo.environment, logger: Logger()) + } + + override func exec(_: [String], stderr _: Bool = true) throws -> String { + output + } +} diff --git a/Tests/XcodeTests/SwiftUIProjectTest.swift b/Tests/XcodeTests/SwiftUIProjectTest.swift index 8368d1e2f..5ffd96239 100644 --- a/Tests/XcodeTests/SwiftUIProjectTest.swift +++ b/Tests/XcodeTests/SwiftUIProjectTest.swift @@ -1,7 +1,6 @@ @testable import TestShared -// swiftlint:disable:next balanced_xctest_lifecycle -class SwiftUIProjectTest: XcodeSourceGraphTestCase { +final class SwiftUIProjectTest: XcodeSourceGraphTestCase { override static func setUp() { super.setUp() diff --git a/Tests/XcodeTests/UIKitProjectTest.swift b/Tests/XcodeTests/UIKitProjectTest.swift index c37847cd4..418753f93 100644 --- a/Tests/XcodeTests/UIKitProjectTest.swift +++ b/Tests/XcodeTests/UIKitProjectTest.swift @@ -1,7 +1,6 @@ @testable import TestShared -// swiftlint:disable:next final_test_case balanced_xctest_lifecycle -class UIKitProjectTest: XcodeSourceGraphTestCase { +final class UIKitProjectTest: XcodeSourceGraphTestCase { override static func setUp() { super.setUp() diff --git a/Tests/XcodeTests/XcodebuildBuildProjectTest.swift b/Tests/XcodeTests/XcodebuildBuildProjectTest.swift index 63c798fd3..29ffd7497 100644 --- a/Tests/XcodeTests/XcodebuildBuildProjectTest.swift +++ b/Tests/XcodeTests/XcodebuildBuildProjectTest.swift @@ -3,7 +3,6 @@ import Shared @testable import XcodeSupport import XCTest -// swiftlint:disable single_test_class final class XcodebuildBuildProjectTest: XCTestCase { private var xcodebuild: Xcodebuild! private var project: XcodeProject! @@ -26,174 +25,3 @@ final class XcodebuildBuildProjectTest: XCTestCase { try xcodebuild.build(project: project, scheme: scheme, allSchemes: [scheme]) } } - -final class XcodebuildSchemesTest: XCTestCase { - private var shell: ShellMock! - private var xcodebuild: Xcodebuild! - private var project: XcodeProject! - - override func setUp() { - super.setUp() - - shell = ShellMock() - xcodebuild = Xcodebuild(shell: shell) - project = try! XcodeProject(path: UIKitProjectPath) - } - - override func tearDown() { - shell = nil - xcodebuild = nil - project = nil - super.tearDown() - } - - func testParseSchemes() { - for output in XcodebuildListOutputs { - shell.output = output - let schemes = try! xcodebuild.schemes(project: project, additionalArguments: []) - XCTAssertEqual(schemes, ["SchemeA", "SchemeB"]) - } - } -} - -class ShellMock: Shell { - var output: String = "" - - convenience init() { - self.init(environment: ProcessInfo.processInfo.environment, logger: Logger()) - } - - override func exec(_: [String], stderr _: Bool = true) throws -> String { - output - } -} - -private let XcodebuildListOutputs = [ - XcodebuildListOutputA, - XcodebuildListOutputB, - XcodebuildListOutputC, - XcodebuildListOutputD, -] - -private let XcodebuildListOutputA = """ -{ - "project" : { - "schemes" : [ - "SchemeA", - "SchemeB", - ], - "name" : "Periphery" - } -} -""" - -private let XcodebuildListOutputB = """ -2018-06-02 20:49:14.055 xcodebuild[62679:970667] DTDeviceKit: deviceType from caf916135a63496e6af846cb8b73eeca8ba63dbd was NULL -2018-06-02 20:49:14.082 xcodebuild[62679:970671] DTDeviceKit: deviceType from caf916135a63496e6af846cb8b73eeca8ba63dbd was NULL -{ - "project" : { - "schemes" : [ - "SchemeA", - "SchemeB", - ], - "name" : "Periphery" - } -} -""" - -private let XcodebuildListOutputC = """ -2018-05-29 10:29:11.199 xcodebuild[82596:2040519] iPhoneConnect: ## Unable to mount developer disk image, (Error Domain=com.apple.dtdevicekit Code=-402652958 "Development cannot be enabled while your device is locked." UserInfo={NSLocalizedDescription=Development cannot be enabled while your device is locked., com.apple.dtdevicekit.stacktrace=( -0 DTDeviceKitBase 0x000000011722ff4f DTDKCreateNSError + 113 -1 DTDeviceKitBase 0x0000000117230793 DTDK_AMDErrorToNSError + 1135 -2 DTDeviceKitBase 0x000000011726fb1a -[DTDKMobileDeviceToken mountDeveloperDiskImage:withError:] + 774 -3 DTDeviceKitBase 0x00000001172703d0 -[DTDKMobileDeviceToken mountDeveloperDiskImageWithError:] + 479 -4 IDEiOSSupportCore 0x0000000115f15922 __37-[DVTiOSDevice(Connect) hasConnected]_block_invoke_2 + 133 -5 DVTFoundation 0x000000010c8b6f28 __DVTDispatchGroupAsync_block_invoke + 806 -6 libdispatch.dylib 0x00007fff5dca264a _dispatch_call_block_and_release + 12 -7 libdispatch.dylib 0x00007fff5dc9ae08 _dispatch_client_callout + 8 -8 libdispatch.dylib 0x00007fff5dcadf50 _dispatch_continuation_pop + 599 -9 libdispatch.dylib 0x00007fff5dca5783 _dispatch_async_redirect_invoke + 703 -10 libdispatch.dylib 0x00007fff5dc9c9f9 _dispatch_root_queue_drain + 515 -11 libdispatch.dylib 0x00007fff5dc9c7a5 _dispatch_worker_thread3 + 101 -12 libsystem_pthread.dylib 0x00007fff5dfec169 _pthread_wqthread + 1387 -13 libsystem_pthread.dylib 0x00007fff5dfebbe9 start_wqthread + 13 -), NSLocalizedRecoverySuggestion=Please unlock your device and reattach. (0xE80000E2)., NSLocalizedFailureReason=Please unlock your device and reattach. (0xE80000E2).}) { -NSLocalizedDescription = "Development cannot be enabled while your device is locked."; -NSLocalizedFailureReason = "Please unlock your device and reattach. (0xE80000E2)."; -NSLocalizedRecoverySuggestion = "Please unlock your device and reattach. (0xE80000E2)."; -"com.apple.dtdevicekit.stacktrace" = ( -0 DTDeviceKitBase 0x000000011722ff4f DTDKCreateNSError + 113 -1 DTDeviceKitBase 0x0000000117230793 DTDK_AMDErrorToNSError + 1135 -2 DTDeviceKitBase 0x000000011726fb1a -[DTDKMobileDeviceToken mountDeveloperDiskImage:withError:] + 774 -3 DTDeviceKitBase 0x00000001172703d0 -[DTDKMobileDeviceToken mountDeveloperDiskImageWithError:] + 479 -4 IDEiOSSupportCore 0x0000000115f15922 __37-[DVTiOSDevice(Connect) hasConnected]_block_invoke_2 + 133 -5 DVTFoundation 0x000000010c8b6f28 __DVTDispatchGroupAsync_block_invoke + 806 -6 libdispatch.dylib 0x00007fff5dca264a _dispatch_call_block_and_release + 12 -7 libdispatch.dylib 0x00007fff5dc9ae08 _dispatch_client_callout + 8 -8 libdispatch.dylib 0x00007fff5dcadf50 _dispatch_continuation_pop + 599 -9 libdispatch.dylib 0x00007fff5dca5783 _dispatch_async_redirect_invoke + 703 -10 libdispatch.dylib 0x00007fff5dc9c9f9 _dispatch_root_queue_drain + 515 -11 libdispatch.dylib 0x00007fff5dc9c7a5 _dispatch_worker_thread3 + 101 -12 libsystem_pthread.dylib 0x00007fff5dfec169 _pthread_wqthread + 1387 -13 libsystem_pthread.dylib 0x00007fff5dfebbe9 start_wqthread + 13 -); -} -2018-05-29 10:29:12.224 xcodebuild[82596:2040519] iPhoneConnect: ## Unable to mount developer disk image, (Error Domain=com.apple.dtdevicekit Code=-402652958 "Development cannot be enabled while your device is locked." UserInfo={NSLocalizedDescription=Development cannot be enabled while your device is locked., com.apple.dtdevicekit.stacktrace=( -0 DTDeviceKitBase 0x000000011722ff4f DTDKCreateNSError + 113 -1 DTDeviceKitBase 0x0000000117230793 DTDK_AMDErrorToNSError + 1135 -2 DTDeviceKitBase 0x000000011726fb1a -[DTDKMobileDeviceToken mountDeveloperDiskImage:withError:] + 774 -3 DTDeviceKitBase 0x00000001172703d0 -[DTDKMobileDeviceToken mountDeveloperDiskImageWithError:] + 479 -4 IDEiOSSupportCore 0x0000000115f15922 __37-[DVTiOSDevice(Connect) hasConnected]_block_invoke_2 + 133 -5 DVTFoundation 0x000000010c8b6f28 __DVTDispatchGroupAsync_block_invoke + 806 -6 libdispatch.dylib 0x00007fff5dca264a _dispatch_call_block_and_release + 12 -7 libdispatch.dylib 0x00007fff5dc9ae08 _dispatch_client_callout + 8 -8 libdispatch.dylib 0x00007fff5dcadf50 _dispatch_continuation_pop + 599 -9 libdispatch.dylib 0x00007fff5dca5783 _dispatch_async_redirect_invoke + 703 -10 libdispatch.dylib 0x00007fff5dc9c9f9 _dispatch_root_queue_drain + 515 -11 libdispatch.dylib 0x00007fff5dc9c7a5 _dispatch_worker_thread3 + 101 -12 libsystem_pthread.dylib 0x00007fff5dfec169 _pthread_wqthread + 1387 -13 libsystem_pthread.dylib 0x00007fff5dfebbe9 start_wqthread + 13 -), NSLocalizedRecoverySuggestion=Please unlock your device and reattach. (0xE80000E2)., NSLocalizedFailureReason=Please unlock your device and reattach. (0xE80000E2).}) { -NSLocalizedDescription = "Development cannot be enabled while your device is locked."; -NSLocalizedFailureReason = "Please unlock your device and reattach. (0xE80000E2)."; -NSLocalizedRecoverySuggestion = "Please unlock your device and reattach. (0xE80000E2)."; -"com.apple.dtdevicekit.stacktrace" = ( -0 DTDeviceKitBase 0x000000011722ff4f DTDKCreateNSError + 113 -1 DTDeviceKitBase 0x0000000117230793 DTDK_AMDErrorToNSError + 1135 -2 DTDeviceKitBase 0x000000011726fb1a -[DTDKMobileDeviceToken mountDeveloperDiskImage:withError:] + 774 -3 DTDeviceKitBase 0x00000001172703d0 -[DTDKMobileDeviceToken mountDeveloperDiskImageWithError:] + 479 -4 IDEiOSSupportCore 0x0000000115f15922 __37-[DVTiOSDevice(Connect) hasConnected]_block_invoke_2 + 133 -5 DVTFoundation 0x000000010c8b6f28 __DVTDispatchGroupAsync_block_invoke + 806 -6 libdispatch.dylib 0x00007fff5dca264a _dispatch_call_block_and_release + 12 -7 libdispatch.dylib 0x00007fff5dc9ae08 _dispatch_client_callout + 8 -8 libdispatch.dylib 0x00007fff5dcadf50 _dispatch_continuation_pop + 599 -9 libdispatch.dylib 0x00007fff5dca5783 _dispatch_async_redirect_invoke + 703 -10 libdispatch.dylib 0x00007fff5dc9c9f9 _dispatch_root_queue_drain + 515 -11 libdispatch.dylib 0x00007fff5dc9c7a5 _dispatch_worker_thread3 + 101 -12 libsystem_pthread.dylib 0x00007fff5dfec169 _pthread_wqthread + 1387 -13 libsystem_pthread.dylib 0x00007fff5dfebbe9 start_wqthread + 13 -); -} -{ - "project" : { - "schemes" : [ - "SchemeA", - "SchemeB", - ], - "name" : "Periphery" - } -} -""" - -private let XcodebuildListOutputD = """ -{ - "project" : { - "schemes" : [ - "SchemeA", - "SchemeB", - ], - "name" : "Periphery" - } -} -build session not created after 15 seconds - still waiting -""" diff --git a/Tests/XcodeTests/XcodebuildListOutputs.swift b/Tests/XcodeTests/XcodebuildListOutputs.swift new file mode 100644 index 000000000..041ae7f96 --- /dev/null +++ b/Tests/XcodeTests/XcodebuildListOutputs.swift @@ -0,0 +1,129 @@ +let XcodebuildListOutputs = [ + XcodebuildListOutputA, + XcodebuildListOutputB, + XcodebuildListOutputC, + XcodebuildListOutputD, +] + +private let XcodebuildListOutputA = """ +{ + "project" : { + "schemes" : [ + "SchemeA", + "SchemeB", + ], + "name" : "Periphery" + } +} +""" + +private let XcodebuildListOutputB = """ +2018-06-02 20:49:14.055 xcodebuild[62679:970667] DTDeviceKit: deviceType from caf916135a63496e6af846cb8b73eeca8ba63dbd was NULL +2018-06-02 20:49:14.082 xcodebuild[62679:970671] DTDeviceKit: deviceType from caf916135a63496e6af846cb8b73eeca8ba63dbd was NULL +{ + "project" : { + "schemes" : [ + "SchemeA", + "SchemeB", + ], + "name" : "Periphery" + } +} +""" + +private let XcodebuildListOutputC = """ +2018-05-29 10:29:11.199 xcodebuild[82596:2040519] iPhoneConnect: ## Unable to mount developer disk image, (Error Domain=com.apple.dtdevicekit Code=-402652958 "Development cannot be enabled while your device is locked." UserInfo={NSLocalizedDescription=Development cannot be enabled while your device is locked., com.apple.dtdevicekit.stacktrace=( +0 DTDeviceKitBase 0x000000011722ff4f DTDKCreateNSError + 113 +1 DTDeviceKitBase 0x0000000117230793 DTDK_AMDErrorToNSError + 1135 +2 DTDeviceKitBase 0x000000011726fb1a -[DTDKMobileDeviceToken mountDeveloperDiskImage:withError:] + 774 +3 DTDeviceKitBase 0x00000001172703d0 -[DTDKMobileDeviceToken mountDeveloperDiskImageWithError:] + 479 +4 IDEiOSSupportCore 0x0000000115f15922 __37-[DVTiOSDevice(Connect) hasConnected]_block_invoke_2 + 133 +5 DVTFoundation 0x000000010c8b6f28 __DVTDispatchGroupAsync_block_invoke + 806 +6 libdispatch.dylib 0x00007fff5dca264a _dispatch_call_block_and_release + 12 +7 libdispatch.dylib 0x00007fff5dc9ae08 _dispatch_client_callout + 8 +8 libdispatch.dylib 0x00007fff5dcadf50 _dispatch_continuation_pop + 599 +9 libdispatch.dylib 0x00007fff5dca5783 _dispatch_async_redirect_invoke + 703 +10 libdispatch.dylib 0x00007fff5dc9c9f9 _dispatch_root_queue_drain + 515 +11 libdispatch.dylib 0x00007fff5dc9c7a5 _dispatch_worker_thread3 + 101 +12 libsystem_pthread.dylib 0x00007fff5dfec169 _pthread_wqthread + 1387 +13 libsystem_pthread.dylib 0x00007fff5dfebbe9 start_wqthread + 13 +), NSLocalizedRecoverySuggestion=Please unlock your device and reattach. (0xE80000E2)., NSLocalizedFailureReason=Please unlock your device and reattach. (0xE80000E2).}) { +NSLocalizedDescription = "Development cannot be enabled while your device is locked."; +NSLocalizedFailureReason = "Please unlock your device and reattach. (0xE80000E2)."; +NSLocalizedRecoverySuggestion = "Please unlock your device and reattach. (0xE80000E2)."; +"com.apple.dtdevicekit.stacktrace" = ( +0 DTDeviceKitBase 0x000000011722ff4f DTDKCreateNSError + 113 +1 DTDeviceKitBase 0x0000000117230793 DTDK_AMDErrorToNSError + 1135 +2 DTDeviceKitBase 0x000000011726fb1a -[DTDKMobileDeviceToken mountDeveloperDiskImage:withError:] + 774 +3 DTDeviceKitBase 0x00000001172703d0 -[DTDKMobileDeviceToken mountDeveloperDiskImageWithError:] + 479 +4 IDEiOSSupportCore 0x0000000115f15922 __37-[DVTiOSDevice(Connect) hasConnected]_block_invoke_2 + 133 +5 DVTFoundation 0x000000010c8b6f28 __DVTDispatchGroupAsync_block_invoke + 806 +6 libdispatch.dylib 0x00007fff5dca264a _dispatch_call_block_and_release + 12 +7 libdispatch.dylib 0x00007fff5dc9ae08 _dispatch_client_callout + 8 +8 libdispatch.dylib 0x00007fff5dcadf50 _dispatch_continuation_pop + 599 +9 libdispatch.dylib 0x00007fff5dca5783 _dispatch_async_redirect_invoke + 703 +10 libdispatch.dylib 0x00007fff5dc9c9f9 _dispatch_root_queue_drain + 515 +11 libdispatch.dylib 0x00007fff5dc9c7a5 _dispatch_worker_thread3 + 101 +12 libsystem_pthread.dylib 0x00007fff5dfec169 _pthread_wqthread + 1387 +13 libsystem_pthread.dylib 0x00007fff5dfebbe9 start_wqthread + 13 +); +} +2018-05-29 10:29:12.224 xcodebuild[82596:2040519] iPhoneConnect: ## Unable to mount developer disk image, (Error Domain=com.apple.dtdevicekit Code=-402652958 "Development cannot be enabled while your device is locked." UserInfo={NSLocalizedDescription=Development cannot be enabled while your device is locked., com.apple.dtdevicekit.stacktrace=( +0 DTDeviceKitBase 0x000000011722ff4f DTDKCreateNSError + 113 +1 DTDeviceKitBase 0x0000000117230793 DTDK_AMDErrorToNSError + 1135 +2 DTDeviceKitBase 0x000000011726fb1a -[DTDKMobileDeviceToken mountDeveloperDiskImage:withError:] + 774 +3 DTDeviceKitBase 0x00000001172703d0 -[DTDKMobileDeviceToken mountDeveloperDiskImageWithError:] + 479 +4 IDEiOSSupportCore 0x0000000115f15922 __37-[DVTiOSDevice(Connect) hasConnected]_block_invoke_2 + 133 +5 DVTFoundation 0x000000010c8b6f28 __DVTDispatchGroupAsync_block_invoke + 806 +6 libdispatch.dylib 0x00007fff5dca264a _dispatch_call_block_and_release + 12 +7 libdispatch.dylib 0x00007fff5dc9ae08 _dispatch_client_callout + 8 +8 libdispatch.dylib 0x00007fff5dcadf50 _dispatch_continuation_pop + 599 +9 libdispatch.dylib 0x00007fff5dca5783 _dispatch_async_redirect_invoke + 703 +10 libdispatch.dylib 0x00007fff5dc9c9f9 _dispatch_root_queue_drain + 515 +11 libdispatch.dylib 0x00007fff5dc9c7a5 _dispatch_worker_thread3 + 101 +12 libsystem_pthread.dylib 0x00007fff5dfec169 _pthread_wqthread + 1387 +13 libsystem_pthread.dylib 0x00007fff5dfebbe9 start_wqthread + 13 +), NSLocalizedRecoverySuggestion=Please unlock your device and reattach. (0xE80000E2)., NSLocalizedFailureReason=Please unlock your device and reattach. (0xE80000E2).}) { +NSLocalizedDescription = "Development cannot be enabled while your device is locked."; +NSLocalizedFailureReason = "Please unlock your device and reattach. (0xE80000E2)."; +NSLocalizedRecoverySuggestion = "Please unlock your device and reattach. (0xE80000E2)."; +"com.apple.dtdevicekit.stacktrace" = ( +0 DTDeviceKitBase 0x000000011722ff4f DTDKCreateNSError + 113 +1 DTDeviceKitBase 0x0000000117230793 DTDK_AMDErrorToNSError + 1135 +2 DTDeviceKitBase 0x000000011726fb1a -[DTDKMobileDeviceToken mountDeveloperDiskImage:withError:] + 774 +3 DTDeviceKitBase 0x00000001172703d0 -[DTDKMobileDeviceToken mountDeveloperDiskImageWithError:] + 479 +4 IDEiOSSupportCore 0x0000000115f15922 __37-[DVTiOSDevice(Connect) hasConnected]_block_invoke_2 + 133 +5 DVTFoundation 0x000000010c8b6f28 __DVTDispatchGroupAsync_block_invoke + 806 +6 libdispatch.dylib 0x00007fff5dca264a _dispatch_call_block_and_release + 12 +7 libdispatch.dylib 0x00007fff5dc9ae08 _dispatch_client_callout + 8 +8 libdispatch.dylib 0x00007fff5dcadf50 _dispatch_continuation_pop + 599 +9 libdispatch.dylib 0x00007fff5dca5783 _dispatch_async_redirect_invoke + 703 +10 libdispatch.dylib 0x00007fff5dc9c9f9 _dispatch_root_queue_drain + 515 +11 libdispatch.dylib 0x00007fff5dc9c7a5 _dispatch_worker_thread3 + 101 +12 libsystem_pthread.dylib 0x00007fff5dfec169 _pthread_wqthread + 1387 +13 libsystem_pthread.dylib 0x00007fff5dfebbe9 start_wqthread + 13 +); +} +{ + "project" : { + "schemes" : [ + "SchemeA", + "SchemeB", + ], + "name" : "Periphery" + } +} +""" + +private let XcodebuildListOutputD = """ +{ + "project" : { + "schemes" : [ + "SchemeA", + "SchemeB", + ], + "name" : "Periphery" + } +} +build session not created after 15 seconds - still waiting +""" diff --git a/Tests/XcodeTests/XcodebuildSchemesTest.swift b/Tests/XcodeTests/XcodebuildSchemesTest.swift new file mode 100644 index 000000000..72ce5927b --- /dev/null +++ b/Tests/XcodeTests/XcodebuildSchemesTest.swift @@ -0,0 +1,32 @@ +import Foundation +@testable import XcodeSupport +import XCTest + +final class XcodebuildSchemesTest: XCTestCase { + private var shell: ShellMock! + private var xcodebuild: Xcodebuild! + private var project: XcodeProject! + + override func setUp() { + super.setUp() + + shell = ShellMock() + xcodebuild = Xcodebuild(shell: shell) + project = try! XcodeProject(path: UIKitProjectPath) + } + + override func tearDown() { + shell = nil + xcodebuild = nil + project = nil + super.tearDown() + } + + func testParseSchemes() { + for output in XcodebuildListOutputs { + shell.output = output + let schemes = try! xcodebuild.schemes(project: project, additionalArguments: []) + XCTAssertEqual(schemes, ["SchemeA", "SchemeB"]) + } + } +} diff --git a/scripts/lint/swiftformat.sh b/scripts/lint/swiftformat.sh index c3014445c..848ba6890 100755 --- a/scripts/lint/swiftformat.sh +++ b/scripts/lint/swiftformat.sh @@ -8,4 +8,4 @@ if [[ "$INSTALLED_VERSION" != "$VERSION" ]]; then exit 1 fi -swiftformat . \ No newline at end of file +swiftformat --quiet . \ No newline at end of file diff --git a/scripts/lint/swiftlint.sh b/scripts/lint/swiftlint.sh new file mode 100755 index 000000000..7a47d0dc1 --- /dev/null +++ b/scripts/lint/swiftlint.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +VERSION="0.56.1" +INSTALLED_VERSION=$(swiftlint --version) + +if [[ "$INSTALLED_VERSION" != "$VERSION" ]]; then + echo "ERROR: SwiftLint ${VERSION} is required, installed version is ${INSTALLED_VERSION}." + exit 1 +fi + +swiftlint lint --quiet \ No newline at end of file