Skip to content

Commit

Permalink
Merge pull request #254 from czechboy0/hd/mixed_warnings
Browse files Browse the repository at this point in the history
Include Analyzer Warning count when result is Warnings
  • Loading branch information
czechboy0 committed Mar 29, 2016
2 parents b005008 + debad3b commit 5376fc1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
27 changes: 22 additions & 5 deletions BuildaKit/SummaryBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,21 @@ class SummaryBuilder {
let status = self.createStatus(.Success, description: "Build passed!", targetUrl: linkToIntegration)

let buildResultSummary = integration.buildResultSummary!
if integration.result == .Succeeded {
switch integration.result {
case .Succeeded?:
self.appendTestsPassed(buildResultSummary)
} else if integration.result == .Warnings {
self.appendWarnings(buildResultSummary)
} else if integration.result == .AnalyzerWarnings {
self.appendAnalyzerWarnings(buildResultSummary)
case .Warnings?, .AnalyzerWarnings?:

switch (buildResultSummary.warningCount, buildResultSummary.analyzerWarningCount) {
case (_, 0):
self.appendWarnings(buildResultSummary)
case (0, _):
self.appendAnalyzerWarnings(buildResultSummary)
default:
self.appendWarningsAndAnalyzerWarnings(buildResultSummary)
}

default: break
}

//and code coverage
Expand Down Expand Up @@ -132,6 +141,14 @@ class SummaryBuilder {
self.lines.append(self.resultString + "All \(testsCount) tests passed, but please **fix \(analyzerWarningCount) " + "analyzer warning".pluralizeStringIfNecessary(analyzerWarningCount) + "**.")
}

func appendWarningsAndAnalyzerWarnings(buildResultSummary: BuildResultSummary) {

let warningCount = buildResultSummary.warningCount
let analyzerWarningCount = buildResultSummary.analyzerWarningCount
let testsCount = buildResultSummary.testsCount
self.lines.append(self.resultString + "All \(testsCount) tests passed, but please **fix \(warningCount) " + "warning".pluralizeStringIfNecessary(warningCount) + "** and **\(analyzerWarningCount) " + "analyzer warning".pluralizeStringIfNecessary(analyzerWarningCount) + "**.")
}

func appendCodeCoverage(buildResultSummary: BuildResultSummary) {

let codeCoveragePercentage = buildResultSummary.codeCoveragePercentage
Expand Down
16 changes: 16 additions & 0 deletions BuildaKitTests/GitHubSummaryBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,22 @@ class GitHubSummaryBuilderTests: XCTestCase {
expect(result.status.state) == exp_state
}

func testPassing_withTests_withWarningsAndAnalyzerWarnings() {

let buildResultSummary = MockBuildResultSummary(analyzerWarningCount: 10, testsCount: 99, warningCount: 2, codeCoveragePercentage: 12)
let integration = self.integration(.Warnings, buildResultSummary: buildResultSummary)
let summary = SummaryBuilder()
summary.statusCreator = MockGitHubServer()
let result = summary.buildPassing(integration)

let exp_comment = "Result of Integration 15\n---\n*Duration*: 28 seconds\n*Result*: All 99 tests passed, but please **fix 2 warnings** and **10 analyzer warnings**.\n*Test Coverage*: 12%"
let exp_status = "Build passed!"
let exp_state = BuildState.Success
expect(result.comment) == exp_comment
expect(result.status.description) == exp_status
expect(result.status.state) == exp_state
}

func testFailingTests() {

//got 99 tests but failing's just one
Expand Down

0 comments on commit 5376fc1

Please sign in to comment.