Skip to content

Commit

Permalink
[BINS-246] Add skipped field parsing to the xc converter (#150)
Browse files Browse the repository at this point in the history
* initial skipped added

* fix lint error

* fix
  • Loading branch information
trapacska authored Jan 18, 2022
1 parent 2e314cd commit a5dd08d
Show file tree
Hide file tree
Showing 17 changed files with 3,506 additions and 30 deletions.
32 changes: 17 additions & 15 deletions bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,10 @@ workflows:
ci:
before_run:
- audit-this-step
- test
after_run:
- _zero_length_file_upload
steps:
- script:
inputs:
- content: |-
#!/bin/bash
set -e
set -v
rm -rf ./_tmp
- script:
inputs:
- content: git clone $SAMPLE_ARTIFACTS_GIT_CLONE_URL ./_tmp
- go-list:
- golint:
- errcheck:
- go-test:
- change-workdir:
run_if: true
inputs:
Expand Down Expand Up @@ -184,7 +171,22 @@ workflows:
echo "-> BITRISE_PUBLIC_INSTALL_PAGE_URL: ${BITRISE_PUBLIC_INSTALL_PAGE_URL}"
echo "-> BITRISE_PUBLIC_INSTALL_PAGE_URL_MAP: ${BITRISE_PUBLIC_INSTALL_PAGE_URL_MAP}"
echo "-> BITRISE_PERMANENT_DOWNLOAD_URL_MAP: ${BITRISE_PERMANENT_DOWNLOAD_URL_MAP}"
test:
steps:
- script:
inputs:
- content: |-
#!/bin/bash
set -e
set -v
rm -rf ./_tmp
- script:
inputs:
- content: git clone --depth 1 $SAMPLE_ARTIFACTS_GIT_CLONE_URL ./_tmp
- go-list:
- golint:
- errcheck:
- go-test:
_zero_length_file_upload:
steps:
- script:
Expand Down
15 changes: 15 additions & 0 deletions test/converters/xcresult/testsummariesplist.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ func (st Subtest) Failure() (message string) {
return
}

// Skipped ...
func (st Subtest) Skipped() bool {
return st.TestStatus == "Skipped"
}

// Subtests ...
type Subtests []Subtest

Expand All @@ -96,6 +101,16 @@ func (sts Subtests) FailuresCount() (count int) {
return count
}

// SkippedCount ...
func (sts Subtests) SkippedCount() (count int) {
for _, test := range sts {
if test.Skipped() {
count++
}
}
return count
}

// TotalTime ...
func (sts Subtests) TotalTime() (time float64) {
for _, test := range sts {
Expand Down
7 changes: 7 additions & 0 deletions test/converters/xcresult/xcresult.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func (h *Converter) XML() (junit.XML, error) {
Name: testID,
Tests: len(tests),
Failures: tests.FailuresCount(),
Skipped: tests.SkippedCount(),
Time: tests.TotalTime(),
}

Expand All @@ -94,10 +95,16 @@ func (h *Converter) XML() (junit.XML, error) {
}
}

var skipped *junit.Skipped
if test.Skipped() {
skipped = &junit.Skipped{}
}

testSuite.TestCases = append(testSuite.TestCases, junit.TestCase{
Name: test.TestName,
ClassName: testID,
Failure: failure,
Skipped: skipped,
Time: test.Duration,
})
}
Expand Down
11 changes: 11 additions & 0 deletions test/converters/xcresult3/action_test_plan_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ func (s ActionTestPlanRunSummaries) failuresCount(testableSummaryName string) (f
return
}

func (s ActionTestPlanRunSummaries) skippedCount(testableSummaryName string) (skipped int) {
testsByCase := s.tests()
tests := testsByCase[testableSummaryName]
for _, test := range tests {
if test.TestStatus.Value == "Skipped" {
skipped++
}
}
return
}

func (s ActionTestPlanRunSummaries) totalTime(testableSummaryName string) (time float64) {
testsByCase := s.tests()
tests := testsByCase[testableSummaryName]
Expand Down
1 change: 1 addition & 0 deletions test/converters/xcresult3/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func (c *Converter) XML() (junit.XML, error) {
Name: name,
Tests: len(tests),
Failures: summary.failuresCount(name),
Skipped: summary.skippedCount(name),
Time: summary.totalTime(name),
}

Expand Down
7 changes: 7 additions & 0 deletions test/junit/xml.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type TestSuite struct {
Name string `xml:"name,attr"`
Tests int `xml:"tests,attr"`
Failures int `xml:"failures,attr"`
Skipped int `xml:"skipped,attr"`
Errors int `xml:"errors,attr"`
Time float64 `xml:"time,attr"`
TestCases []TestCase `xml:"testcase"`
Expand All @@ -28,6 +29,7 @@ type TestCase struct {
ClassName string `xml:"classname,attr"`
Time float64 `xml:"time,attr"`
Failure *Failure `xml:"failure,omitempty"`
Skipped *Skipped `xml:"skipped,omitempty"`
Error *Error `xml:"error,omitempty"`
SystemErr string `xml:"system-err,omitempty"`
}
Expand All @@ -39,6 +41,11 @@ type Failure struct {
Value string `xml:",chardata"`
}

// Skipped ...
type Skipped struct {
XMLName xml.Name `xml:"skipped,omitempty"`
}

// Error ...
type Error struct {
XMLName xml.Name `xml:"error,omitempty"`
Expand Down
10 changes: 3 additions & 7 deletions test/test_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package test

import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
Expand All @@ -15,6 +14,7 @@ import (
"github.com/bitrise-io/go-utils/pathutil"
"github.com/gorilla/mux"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
)

func createDummyFilesInDirWithContent(dir, content string, fileNames []string) error {
Expand Down Expand Up @@ -228,9 +228,7 @@ func Test_ParseTestResults(t *testing.T) {
t.Fatalf("should be 1 test asset pack: %#v", bundle)
}

if len(bundle[0].XMLContent) != len(sampleIOSXmlOutput) {
t.Fatal(fmt.Sprintf("wrong xml content: %s", bundle[0].XMLContent))
}
assert.Equal(t, sampleIOSXmlOutput, string(bundle[0].XMLContent))
}

// creating ios test results
Expand Down Expand Up @@ -269,8 +267,6 @@ func Test_ParseTestResults(t *testing.T) {
t.Fatal("should be 1 test asset pack")
}

if len(string(bundle[0].XMLContent)) != len(sampleIOSXmlOutput) {
t.Fatal("wrong xml content\n" + string(bundle[0].XMLContent) + "\n\n" + sampleIOSXmlOutput)
}
assert.Equal(t, sampleIOSXmlOutput, string(bundle[0].XMLContent))
}
}
2 changes: 1 addition & 1 deletion test/testdata/ios_testsummaries_plist.golden
Original file line number Diff line number Diff line change
Expand Up @@ -4593,7 +4593,7 @@
<key>TestObjectClass</key>
<string>IDESchemeActionTestSummary</string>
<key>TestStatus</key>
<string>Success</string>
<string>Skipped</string>
<key>TestSummaryGUID</key>
<string>564D74F8-E1D7-41EA-A629-0ED0B79E6A39</string>
</dict>
Expand Down
16 changes: 9 additions & 7 deletions test/testdata/ios_xml_output.golden
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="BitriseBasicUITest" tests="4" failures="0" errors="0" time="77.06086790561676">
<testsuite name="BitriseBasicUITest" tests="4" failures="0" skipped="0" errors="0" time="77.06086790561676">
<testcase name="testCollectionView()" classname="BitriseBasicUITest" time="23.776288986206055"></testcase>
<testcase name="testInReadTopView()" classname="BitriseBasicUITest" time="34.97628891468048"></testcase>
<testcase name="testInterstitialView()" classname="BitriseBasicUITest" time="10.270301938056946"></testcase>
<testcase name="testRewardView()" classname="BitriseBasicUITest" time="8.037988066673279"></testcase>
</testsuite>
<testsuite name="BitriseCommanderUITests" tests="1" failures="0" errors="0" time="40.58690905570984">
<testcase name="testCommanderUpdate()" classname="BitriseCommanderUITests" time="40.58690905570984"></testcase>
<testsuite name="BitriseCommanderUITests" tests="1" failures="0" skipped="1" errors="0" time="40.58690905570984">
<testcase name="testCommanderUpdate()" classname="BitriseCommanderUITests" time="40.58690905570984">
<skipped></skipped>
</testcase>
</testsuite>
<testsuite name="BitriseComponentUITest" tests="2" failures="0" errors="0" time="33.92029893398285">
<testsuite name="BitriseComponentUITest" tests="2" failures="0" skipped="0" errors="0" time="33.92029893398285">
<testcase name="testAdChoiceIcon()" classname="BitriseComponentUITest" time="15.12886095046997"></testcase>
<testcase name="testFullScreenReplay()" classname="BitriseComponentUITest" time="18.79143798351288"></testcase>
</testsuite>
<testsuite name="BitriseOMUITests" tests="3" failures="1" errors="0" time="80.687903881073">
<testsuite name="BitriseOMUITests" tests="3" failures="1" skipped="0" errors="0" time="80.687903881073">
<testcase name="testOMBanner()" classname="BitriseOMUITests" time="15.550718903541565">
<failure>/Users/vagrant/git/BitriseApp/BitriseAppUITests/BitriseOMUITests.swift:70 - XCTAssertTrue failed - No session found</failure>
</testcase>
<testcase name="testOMInterstitial()" classname="BitriseOMUITests" time="26.03164303302765"></testcase>
<testcase name="testOMScrollView()" classname="BitriseOMUITests" time="39.105541944503784"></testcase>
</testsuite>
<testsuite name="BitriseTrackingsUITest" tests="2" failures="0" errors="0" time="28.362125039100647">
<testsuite name="BitriseTrackingsUITest" tests="2" failures="0" skipped="0" errors="0" time="28.362125039100647">
<testcase name="testTrackingsWithAd()" classname="BitriseTrackingsUITest" time="16.5611629486084"></testcase>
<testcase name="testTrackingsWithNoAd()" classname="BitriseTrackingsUITest" time="11.800962090492249"></testcase>
</testsuite>
<testsuite name="bitrErrorUITest" tests="9" failures="0" errors="0" time="152.8058191537857">
<testsuite name="bitrErrorUITest" tests="9" failures="0" skipped="0" errors="0" time="152.8058191537857">
<testcase name="testbitrError403()" classname="bitrErrorUITest" time="16.062182068824768"></testcase>
<testcase name="testbitrError405()" classname="bitrErrorUITest" time="16.12081003189087"></testcase>
<testcase name="testbitrError901()" classname="bitrErrorUITest" time="16.46643900871277"></testcase>
Expand Down
28 changes: 28 additions & 0 deletions vendor/github.com/stretchr/testify/require/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions vendor/github.com/stretchr/testify/require/forward_requirements.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a5dd08d

Please sign in to comment.