Files
SwiftLint/Source/SwiftLintFrameworkTests/IntegrationTests.swift
T
JP Simard 98fe6c4c81 fix Xcode 7.3 compilation
XCTest APIs now use StaticString instead of String for file names
and we can't create a StaticString for violation file names, so just revert
to the old XCTest check
2016-01-26 16:51:30 -08:00

40 lines
1.4 KiB
Swift

//
// IntegrationTests.swift
// SwiftLint
//
// Created by JP Simard on 5/28/15.
// Copyright (c) 2015 Realm. All rights reserved.
//
import Foundation
import SourceKittenFramework
import SwiftLintFramework
import XCTest
class IntegrationTests: XCTestCase {
func testSwiftLintLints() {
// This is as close as we're ever going to get to a self-hosting linter.
let directory = (((__FILE__ as NSString)
.stringByDeletingLastPathComponent as NSString)
.stringByDeletingLastPathComponent as NSString)
.stringByDeletingLastPathComponent
NSFileManager.defaultManager().changeCurrentDirectoryPath(directory)
let config = Configuration(path: Configuration.fileName)
let swiftFiles = config.lintableFilesForPath("")
XCTAssert(swiftFiles.map({$0.path!}).contains(__FILE__), "current file should be included")
#if SWIFTLINT_XCODE_VERSION_0730
XCTAssertEqual(swiftFiles.flatMap({
Linter(file: $0, configuration: config).styleViolations
}), [])
#else
let violations = swiftFiles.flatMap {
Linter(file: $0, configuration: config).styleViolations
}
violations.forEach {
XCTFail($0.reason, file: $0.location.file!, line: UInt($0.location.line!))
}
#endif
}
}