File: serial_spec_iterator.go

package info (click to toggle)
golang-ginkgo 1.16.5-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,004 kB
  • sloc: sh: 14; makefile: 7
file content (45 lines) | stat: -rw-r--r-- 814 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package spec_iterator

import (
	"github.com/onsi/ginkgo/internal/spec"
)

type SerialIterator struct {
	specs []*spec.Spec
	index int
}

func NewSerialIterator(specs []*spec.Spec) *SerialIterator {
	return &SerialIterator{
		specs: specs,
		index: 0,
	}
}

func (s *SerialIterator) Next() (*spec.Spec, error) {
	if s.index >= len(s.specs) {
		return nil, ErrClosed
	}

	spec := s.specs[s.index]
	s.index += 1
	return spec, nil
}

func (s *SerialIterator) NumberOfSpecsPriorToIteration() int {
	return len(s.specs)
}

func (s *SerialIterator) NumberOfSpecsToProcessIfKnown() (int, bool) {
	return len(s.specs), true
}

func (s *SerialIterator) NumberOfSpecsThatWillBeRunIfKnown() (int, bool) {
	count := 0
	for _, s := range s.specs {
		if !s.Skipped() && !s.Pending() {
			count += 1
		}
	}
	return count, true
}