Skip to content

Commit

Permalink
Remove unused functions
Browse files Browse the repository at this point in the history
  • Loading branch information
BobyMCbobs committed May 6, 2023
1 parent ce6b458 commit 190a4de
Showing 1 changed file with 0 additions and 66 deletions.
66 changes: 0 additions & 66 deletions pkg/suite/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"path"
"regexp"
"sort"
"strconv"
"strings"

"github.com/cucumber/godog"
Expand Down Expand Up @@ -647,46 +646,6 @@ func (s *PRSuite) GetMissingJunitTestsFromPRSuite() (missingTests []string, err
return missingTests, nil
}

func (s *PRSuite) determineSuccessfulTestsBelowv125() (success bool, passed int, err error) {
file := s.GetFileByFileName("e2e.log")
if file == nil {
return false, 0, fmt.Errorf("unable to find file e2e.log")
}
fileLines := strings.Split(file.Contents, "\n")
lastLinesAmount := len(fileLines) - 100
if lastLinesAmount < 0 {
lastLinesAmount = len(fileLines)
}
fileLast100Lines := fileLines[lastLinesAmount:]
var pattern *regexp.Regexp
patternComplete := regexp.MustCompile(`^(SUCCESS|FAIL)! -- ([1-9][0-9]+) Passed \| ([0-9]+) Failed \| ([0-9]+) Pending \| ([0-9]+) Skipped$`)
patternCompleteWithFlaked := regexp.MustCompile(`^(SUCCESS|FAIL)! -- ([1-9][0-9]+) Passed \| ([0-9]+) Failed \| ([0-9]+) Flaked \| ([0-9]+) Pending \| ([0-9]+) Skipped$`)
matchingLine := ""
for _, line := range fileLast100Lines {
if patternComplete.MatchString(line) {
matchingLine = line
pattern = patternComplete
} else if patternCompleteWithFlaked.MatchString(line) {
matchingLine = line
pattern = patternCompleteWithFlaked
}
}
if matchingLine == "" {
return false, 0, fmt.Errorf("unable to determine test results (passed, failed, flaked, pending, skipped) from e2e.log")
}
allIndexes := pattern.FindAllSubmatchIndex([]byte(matchingLine), -1)
for _, loc := range allIndexes {
passed, err = strconv.Atoi(matchingLine[loc[4]:loc[5]])
if err != nil {
return false, 0, fmt.Errorf("failed to parse successful tests")
}
// failed := string(file.Name[loc[4]:loc[5]])
// pending := string(file.Name[loc[6]:loc[7]])
// skipped := string(file.Name[loc[8]:loc[9]])
}
return true, passed, nil
}

func (s *PRSuite) determineSuccessfulTestsv125AndAbove() (success bool, passed int, tests []string, err error) {
junitTests, err := s.getJunitSubmittedConformanceTests()
if err != nil {
Expand Down Expand Up @@ -730,31 +689,6 @@ func (s *PRSuite) allRequiredTestsInJunitXmlArePresent() error {
return nil
}

func (s *PRSuite) collectPassedTestsFromE2elog() (tests []string, err error) {
file := s.GetFileByFileName("e2e.log")
if file == nil {
return []string{}, fmt.Errorf("unable to find file e2e.log")
}
fileLines := strings.Split(file.Contents, "\n")
for _, line := range fileLines {
if !strings.Contains(line, "msg") {
continue
}
line = strings.ReplaceAll(line, "•", "")
var e2eLogTestPass E2eLogTestPass
err = json.Unmarshal([]byte(line), &e2eLogTestPass)
if err != nil {
continue
}
if !(strings.Contains(e2eLogTestPass.Message, "PASSED") ||
strings.Contains(e2eLogTestPass.Message, "[Conformance]")) {
continue
}
tests = append(tests, strings.ReplaceAll(e2eLogTestPass.Message, "PASSED ", ""))
}
return tests, nil
}

func (s *PRSuite) theTestsPassAndAreSuccessful() error {
success, _, _, err := s.DetermineSuccessfulTests()
if err != nil {
Expand Down

0 comments on commit 190a4de

Please sign in to comment.