MCPcopy
hub / github.com/expr-lang/expr / parseLabeledOutput

Function parseLabeledOutput

internal/testify/assert/assertions_test.go:2928–2961  ·  view source on GitHub ↗

parseLabeledOutput does the inverse of labeledOutput - it takes a formatted output string and turns it back into a slice of labeledContent.

(output string)

Source from the content-addressed store, hash-verified

2926// parseLabeledOutput does the inverse of labeledOutput - it takes a formatted
2927// output string and turns it back into a slice of labeledContent.
2928func parseLabeledOutput(output string) []labeledContent {
2929 labelPattern := regexp.MustCompile(`^\t([^\t]*): *\t(.*)$`)
2930 contentPattern := regexp.MustCompile(`^\t *\t(.*)$`)
2931 var contents []labeledContent
2932 lines := strings.Split(output, "\n")
2933 i := -1
2934 for _, line := range lines {
2935 if line == "" {
2936 // skip blank lines
2937 continue
2938 }
2939 matches := labelPattern.FindStringSubmatch(line)
2940 if len(matches) == 3 {
2941 // a label
2942 contents = append(contents, labeledContent{
2943 label: matches[1],
2944 content: matches[2] + "\n",
2945 })
2946 i++
2947 continue
2948 }
2949 matches = contentPattern.FindStringSubmatch(line)
2950 if len(matches) == 2 {
2951 // just content
2952 if i >= 0 {
2953 contents[i].content += matches[1] + "\n"
2954 continue
2955 }
2956 }
2957 // Couldn't parse output
2958 return nil
2959 }
2960 return contents
2961}
2962
2963type captureTestingT struct {
2964 msg string

Callers 1

checkResultAndErrMsgMethod · 0.85

Calls 1

SplitMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…