<commit_before>//
//  IntegrationTests.swift
//  swiftcov
//
//  Created by <NAME> on 2015/05/31.
//  Copyright (c) 2015 Realm. All rights reserved.
//

import XCTest
import SwiftCovFramework

class CoverageReporterTests: XCTestCase {
    let reportFilename = "Calculator.swift.gcov"
    var fixtureFilePath: String {
        return "./Examples/ExampleFramework/results/" + reportFilename
    }

    override func setUp() {
        super.setUp()
    }

    override func tearDown() {
        super.tearDown()
    }

    func testGenerateCoverageReportIOS() {
        let temporaryDirectory = NSTemporaryDirectory().stringByAppendingPathComponent(NSProcessInfo().globallyUniqueString)
        NSFileManager().createDirectoryAtPath(temporaryDirectory, withIntermediateDirectories: true, attributes: nil, error: nil)

        let reporter = CoverageReporter(outputDirectory: temporaryDirectory)

        let xcodebuild = Xcodebuild(arguments: ["xcodebuild",
                                                "test",
                                                "-project", "./Examples/ExampleFramework/ExampleFramework.xcodeproj",
                                                "-scheme", "ExampleFramework-iOS",
                                                "-configuration", "Release",
                                                "-sdk", "iphonesimulator",
                                                "-derivedDataPath", temporaryDirectory])
        switch xcodebuild.showBuildSettings() {
        case let .Success(output):
            let buildSettings = BuildSettings(output: output.value)

            switch xcodebuild.buildExecutable() {
            case .Success:
                switch reporter.runCoverageReport(buildSettings: buildSettings) {
                case .Success:
                    let reportFilePath = temporaryDirectory.stringByAppendingPathComponent(reportFilename)

                    XCTAssertEqual(
                        NSString(contentsOfFile: reportFilePath, encoding: NSUTF8StringEncoding, error: nil)!,
                        NSString(contentsOfFile: fixtureFilePath, encoding: NSUTF8StringEncoding, error: nil)!)
                case let .Failure(error):
                    XCTAssertNotEqual(error.value, EXIT_SUCCESS)
                    XCTFail("Execution failure")
                }
            case let .Failure(error):
                XCTAssertNotEqual(error.value, EXIT_SUCCESS)
                XCTFail("Execution failure")
            }
        case let .Failure(error):
            XCTAssertNotEqual(error.value, EXIT_SUCCESS)
            XCTFail("Execution failure")
        }
    }

    func testGenerateCoverageReportOSX() {
        let temporaryDirectory = NSTemporaryDirectory().stringByAppendingPathComponent(NSProcessInfo().globallyUniqueString)
        NSFileManager().createDirectoryAtPath(temporaryDirectory, withIntermediateDirectories: true, attributes: nil, error: nil)

        let reporter = CoverageReporter(outputDirectory: temporaryDirectory)

        let xcodebuild = Xcodebuild(arguments: ["xcodebuild",
                                                "test",
                                                "-project", "./Examples/ExampleFramework/ExampleFramework.xcodeproj",
                                                "-scheme", "ExampleFramework-Mac",
                                                "-configuration", "Release",
                                                "-sdk", "macosx",
                                                "-derivedDataPath", temporaryDirectory])
        switch xcodebuild.showBuildSettings() {
        case let .Success(output):
            let buildSettings = BuildSettings(output: output.value)
            
            switch xcodebuild.buildExecutable() {
            case .Success:
                switch reporter.runCoverageReport(buildSettings: buildSettings) {
                case .Success:
                    let reportFilePath = temporaryDirectory.stringByAppendingPathComponent(reportFilename)
                    
                    XCTAssertEqual(
                        NSString(contentsOfFile: reportFilePath, encoding: NSUTF8StringEncoding, error: nil)!,
                        NSString(contentsOfFile: fixtureFilePath, encoding: NSUTF8StringEncoding, error: nil)!)
                case let .Failure(error):
                    XCTAssertNotEqual(error.value, EXIT_SUCCESS)
                    XCTFail("Execution failure")
                }
            case let .Failure(error):
                XCTAssertNotEqual(error.value, EXIT_SUCCESS)
                XCTFail("Execution failure")
            }
        case let .Failure(error):
            XCTAssertNotEqual(error.value, EXIT_SUCCESS)
            XCTFail("Execution failure")<commit_msg>Ignore first line of resuts to compare<commit_after>//
//  IntegrationTests.swift
//  swiftcov
//
//  Created by <NAME> on 2015/05/31.
//  Copyright (c) 2015 Realm. All rights reserved.
//

import XCTest
import SwiftCovFramework

class CoverageReporterTests: XCTestCase {
    let reportFilename = "Calculator.swift.gcov"
    var fixtureFilePath: String {
        return "./Examples/ExampleFramework/results/" + reportFilename
    }

    override func setUp() {
        super.setUp()
    }

    override func tearDown() {
        super.tearDown()
    }

    func testGenerateCoverageReportIOS() {
        let temporaryDirectory = NSTemporaryDirectory().stringByAppendingPathComponent(NSProcessInfo().globallyUniqueString)
        NSFileManager().createDirectoryAtPath(temporaryDirectory, withIntermediateDirectories: true, attributes: nil, error: nil)

        let reporter = CoverageReporter(outputDirectory: temporaryDirectory)

        let xcodebuild = Xcodebuild(arguments: ["xcodebuild",
                                                "test",
                                                "-project", "./Examples/ExampleFramework/ExampleFramework.xcodeproj",
                                                "-scheme", "ExampleFramework-iOS",
                                                "-configuration", "Release",
                                                "-sdk", "iphonesimulator",
                                                "-derivedDataPath", temporaryDirectory])
        switch xcodebuild.showBuildSettings() {
        case let .Success(output):
            let buildSettings = BuildSettings(output: output.value)

            switch xcodebuild.buildExecutable() {
            case .Success:
                switch reporter.runCoverageReport(buildSettings: buildSettings) {
                case .Success:
                    let reportFilePath = temporaryDirectory.stringByAppendingPathComponent(reportFilename)

                    XCTAssertEqual(
                        dropFirst(split(NSString(contentsOfFile: reportFilePath, encoding: NSUTF8StringEncoding, error: nil) as! String) { $0 == "\n" }),
                        dropFirst(split(NSString(contentsOfFile: fixtureFilePath, encoding: NSUTF8StringEncoding, error: nil) as! String) { $0 == "\n" }))
                case let .Failure(error):
                    XCTAssertNotEqual(error.value, EXIT_SUCCESS)
                    XCTFail("Execution failure")
                }
            case let .Failure(error):
                XCTAssertNotEqual(error.value, EXIT_SUCCESS)
                XCTFail("Execution failure")
            }
        case let .Failure(error):
            XCTAssertNotEqual(error.value, EXIT_SUCCESS)
            XCTFail("Execution failure")
        }
    }

    func testGenerateCoverageReportOSX() {
        let temporaryDirectory = NSTemporaryDirectory().stringByAppendingPathComponent(NSProcessInfo().globallyUniqueString)
        NSFileManager().createDirectoryAtPath(temporaryDirectory, withIntermediateDirectories: true, attributes: nil, error: nil)

        let reporter = CoverageReporter(outputDirectory: temporaryDirectory)

        let xcodebuild = Xcodebuild(arguments: ["xcodebuild",
                                                "test",
                                                "-project", "./Examples/ExampleFramework/ExampleFramework.xcodeproj",
                                                "-scheme", "ExampleFramework-Mac",
                                                "-configuration", "Release",
                                                "-sdk", "macosx",
                                                "-derivedDataPath", temporaryDirectory])
        switch xcodebuild.showBuildSettings() {
        case let .Success(output):
            let buildSettings = BuildSettings(output: output.value)
            
            switch xcodebuild.buildExecutable() {
            case .Success:
                switch reporter.runCoverageReport(buildSettings: buildSettings) {
                case .Success:
                    let reportFilePath = temporaryDirectory.stringByAppendingPathComponent(reportFilename)
                    
                    XCTAssertEqual(
                        dropFirst(split(NSString(contentsOfFile: reportFilePath, encoding: NSUTF8StringEncoding, error: nil) as! String) { $0 == "\n" }),
                        dropFirst(split(NSString(contentsOfFile: fixtureFilePath, encoding: NSUTF8StringEncoding, error: nil) as! String) { $0 == "\n" }))
                case let .Failure(error):
                    XCTAssertNotEqual(error.value, EXIT_SUCCESS)
                    XCTFail("Execution failure")
                }
            case let .Failure(error):
                XCTAssertNotEqual(error.value, EXIT_SUCCESS)
                XCTFail("Execution failure")
            }
        case let .Failure(error):
            XCTAssertNotEqual(error.value, EXIT_SUCCESS)
            XCTFail("Execution failure")
{'fraction_non_alphanumeric': 0.08453587145635043, 'fraction_numerical': 0.00368437212158428, 'mean_word_length': 1.745715088508008, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 48, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3629612', 'n_tokens_mistral': 2234, 'n_tokens_neox': 2111, 'n_words': 443}