ChargePoint / xcparse

Command line tool & Swift framework for parsing Xcode 11+ xcresult
MIT License
392 stars 47 forks source link

ActionTestPerformanceMetricSummary parse incorrectly measurements field #51

Closed OdNairy closed 4 years ago

OdNairy commented 4 years ago

Describe the bug Measurements has no elements in ActionTestPerformanceMetricSummary class.

Desktop (please complete the following information):

To Reproduce

Steps to reproduce the behavior: Run sample code over XCResult with performance metrics (sample.xcresult):

func perfomanceMetrics(xcresultPath: String) throws {
    var xcresult = XCResult(path: xcresultPath, console: self.console)
    guard let invocationRecord = xcresult.invocationRecord else { return }

    guard let action = invocationRecord.actions.filter({ $0.actionResult.testsRef != nil }).first else { return }

    guard let testPlanRunSummaries: ActionTestPlanRunSummaries = action.actionResult.testsRef!.modelFromReference(withXCResult: xcresult) else { return }

    let testableSummaries = testPlanRunSummaries.summaries[0].testableSummaries

    for testSummaries in testableSummaries[0].flattenedTestSummaryMap(withXCResult: xcresult).map({ $0.testSummary }) {
        let perfMetricsCount = testSummaries.performanceMetrics[0].measurements.count
        assert(perfMetricsCount != 0) // Fails!
    }
}

Expected behavior A clear and concise description of what you expected to happen.

Additional context During debugging I've noted that the following code uses XCResultObject class instead of XCResultValueType in this place: https://github.com/ChargePoint/xcparse/blob/7918fc648c79e86e01d6469e75b7098d8f77763c/Sources/XCParseCore/XCPResultDecoding.swift#L340-L356

abotkin-cpi commented 4 years ago

@OdNairy Thanks for the detailed report! Would you be alright with this sample xcresult being included in our test suite?

I've got a possible fix & added your test for this in the branch origin/performance_metrics. Please feel free to take a look; I'll likely add a few more tests around that xcresult if you're fine with it's inclusion in the morning when I'm a little more awake.

OdNairy commented 4 years ago

Would you be alright with this sample xcresult being included in our test suite?

Yeah, no problem

abotkin-cpi commented 4 years ago

This should now be addressed in 2.1.2. Thanks for the feedback @OdNairy!