// ParseGocheck parses output of "go test -gocheck.vv", returns a list of tests
// See data/gocheck.out for an example
// TODO: Refactor to shorter ones
559199
func ParseGocheck(rd io.Reader, suitePrefix string) (Suites, error) {
	findStart := gcStartRE.FindStringSubmatch
	findEnd := gcEndRE.FindStringSubmatch
	findSuite := gcSuiteRE.FindStringSubmatch

	scanner := NewLineScanner(rd)
	var suites = make([]*Suite, 0)
	var suiteName string
	var suite *Suite

	var testName string
	var out []string

	for scanner.Scan() {
		line := scanner.Text()

		tokens := findStart(line)
		if len(tokens) > 0 {
			if tokens[2] == "SetUpTest" || tokens[2] == "TearDownTest" {
				continue
			}
			if testName != "" {
				return nil, fmt.Errorf("%d: start in middle of test", scanner.Line())
			}
			suiteName = tokens[1]
			testName = tokens[2]
			out = []string{}
			continue
		}

		tokens = findEnd(line)
		if len(tokens) > 0 {
			if tokens[3] == "SetUpTest" || tokens[3] == "TearDownTest" {
				continue
			}
			if testName == "" {
				return nil, fmt.Errorf("%d: orphan end", scanner.Line())
			}
			if (tokens[2] != suiteName) || (tokens[3] != testName) {
				return nil, fmt.Errorf("%d: suite/name mismatch", scanner.Line())
			}
			test := &Test{Name: testName}
			test.Message = strings.Join(out, "\n")
			test.Time = tokens[4]
			test.Status = Token2Status(tokens[1])
			if test.Status == UnknownStatus {
				return nil, fmt.Errorf("%d: unknown status %s", scanner.Line(), tokens[1])
			}

			if suite == nil || suite.Name != suiteName {
				suite = &Suite{Name: suitePrefix + suiteName}
				suites = append(suites, suite)
			}
			suite.Tests = append(suite.Tests, test)

			testName = ""
			suiteName = ""
			out = []string{}

			continue
		}

		// last "suite" is test summary
		tokens = findSuite(line)
		if tokens != nil {
			if suite == nil {
				suite = &Suite{Name: tokens[2], Status: tokens[1], Time: tokens[3]}
				suites = append(suites, suite)
			} else {
				suite.Status = tokens[1]
				suite.Time = tokens[3]
			}

			testName = ""
			suiteName = ""
			out = []string{}

			continue
		}

		if testName != "" {
			out = append(out, line)
		}
	}

	if err := scanner.Err(); err != nil {
		return nil, err
	}

	return Suites(suites), nil
}
1361331
func goroutineCountCheck(threshold int) error {
	count := runtime.NumGoroutine()
	if count > threshold {
		return fmt.Errorf("too many goroutines (%d > %d)", count, threshold)
	}
	return nil
}
1042335
func (j *Jobs) ParseHCL(jobHCL string, canonicalize bool) (*Job, error) {
	var job Job
	req := &JobsParseRequest{
		JobHCL:       jobHCL,
		Canonicalize: canonicalize,
	}
	_, err := j.client.write("/v1/jobs/parse", req, &job, nil)
	return &job, err
}
510578
func ParseGoMod(dir string) (result []Module, err error) {
	cmd := exec.Command("go", "list", "-m", "-json", "all")
	cmd.Dir = dir
	goModData, err := cmd.Output()
	if err != nil {
		return
	}

	modsData := reJSONObj.FindAll(goModData, -1)

	result = make([]Module, len(modsData))
	for i, d := range modsData {
		mod := Module{}
		if err = json.Unmarshal(d, &mod); err != nil {
			return []Module{}, err
		}
		result[i] = mod
	}

	return
}
1365562
func (check StatusChecker) RunCheck() Status {
	statusChannel := make(chan Status, 1)
	go func() {
		status := check()
		if status.GoodToGo {
			status.Message = "OK"
		}
		statusChannel <- status
	}()
	select {
	case status := <-statusChannel:
		return status
	case <-time.After(time.Second * time.Duration(timeout)):
		return Status{GoodToGo: false, Message: timeoutMessage}
	}
}
1280446
func dataCheck(dataVal []string) bool {
	var checkOk bool

	if len(dataVal) == 2 {
		_, checkOk = data.Data[dataVal[0]]
		if checkOk {
			_, checkOk = data.Data[dataVal[0]][dataVal[1]]
		}
	}

	return checkOk
}
212065
func ParseAST(r io.Reader) ([]AST, error) {
	lexer := iniLexer{}
	tokens, err := lexer.Tokenize(r)
	if err != nil {
		return []AST{}, err
	}

	return parse(tokens)
}
520102
func parseGWParts(gwMetaBuf []byte) []minio.ObjectPartInfo {
	// Parse the GW Parts.
	partsResult := gjson.GetBytes(gwMetaBuf, "parts").Array()
	partInfo := make([]minio.ObjectPartInfo, len(partsResult))
	for i, p := range partsResult {
		info := minio.ObjectPartInfo{}
		info.Number = int(p.Get("number").Int())
		info.Name = p.Get("name").String()
		info.ETag = p.Get("etag").String()
		info.Size = p.Get("size").Int()
		partInfo[i] = info
	}
	return partInfo
}
1092573
func parseGMT(value string) int {
	value = value[3:]
	if len(value) == 0 {
		return 3
	}

	return 3 + parseSignedOffset(value)
}
1101375
func (p *parser) parseRegex() (rx *regexp.Regexp, err error) {
	i := p.i
	if len(p.s) < i+2 {
		return nil, errors.New("expected regular expression, found EOF instead")
	}

	// number of open parens or brackets;
	// when it becomes negative, finished parsing regex
	open := 0

loop:
	for i < len(p.s) {
		switch p.s[i] {
		case '(', '[':
			open++
		case ')', ']':
			open--
			if open < 0 {
				break loop
			}
		}
		i++
	}

	if i >= len(p.s) {
		return nil, errors.New("EOF in regular expression")
	}
	rx, err = regexp.Compile(p.s[p.i:i])
	p.i = i
	return rx, err
}
1040795
func (_m *State) GetChecks() []types.CheckSpec {
	ret := _m.Called()

	var r0 []types.CheckSpec
	if rf, ok := ret.Get(0).(func() []types.CheckSpec); ok {
		r0 = rf()
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).([]types.CheckSpec)
		}
	}

	return r0
}
17243
func (extr *ContentExtractor) nodesToCheck(doc *goquery.Document) []*goquery.Selection {
	var output []*goquery.Selection
	tags := []string{"p", "pre", "td"}
	for _, tag := range tags {
		selections := doc.Children().Find(tag)
		if selections != nil {
			selections.Each(func(i int, s *goquery.Selection) {
				output = append(output, s)
			})
		}
	}
	return output
}
430966
func (p *gc_parser) parse_int() {
	switch p.tok {
	case '-', '+':
		p.next()
	}
	p.expect(scanner.Int)
}
601919
func ParseGeometry(gi interface{}) (geom Geometry, err error) {
	switch g := gi.(type) {
	case map[string]interface{}:
		coord := g["coordinates"]
		switch typ := g["type"]; typ {
		case "Point":
			return parsePoint(coord)
		case "LineString":
			return parseLineString(coord)
		case "MultiPoint":
			return parseMultiPoint(coord)
		case "MultiLineString":
			return parseMultiLineString(coord)
		case "Polygon":
			return parsePolygon(coord)
		case "MultiPolygon":
			return parseMultiPolygon(coord)
		case "GeometryCollection":
			return parseGeometryCollection(g["geometries"])
		default:
			err = errors.New(fmt.Sprintf("ParseError: Unknown geometry type %s", typ))
			break
		}
	}
	return geom, err
}
806083
func FormatCheck(i Info) bool {
	return (C.sf_format_check((*C.SF_INFO)(unsafe.Pointer(&i))) == C.SF_TRUE)
}
684030
func OptionCheck(args []string) (err error) {
	opt := newOption(ioutil.Discard, flag.ContinueOnError)
	if e := opt.parse(args); e != nil {
		return fmt.Errorf("%v, %v", CommandName, e)
	}
	return nil
}
308669
func (p *responseParser) parseOk() error {
	line, err := p.readLine()
	if err != nil {
		return err
	}

	if len(line) < 3 {
		return ErrMalformed
	}

	sign := string(line[0])
	if sign == "+" && string(line[1:3]) == "OK" && len(line) == 3 {
		return nil
	}

	if sign != "-" {
		return ErrMalformed
	}

	err, _ = p.errorFromLine(line)
	return err
}