forked from johnnye/test-run
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcircle.go
More file actions
44 lines (34 loc) · 736 Bytes
/
circle.go
File metadata and controls
44 lines (34 loc) · 736 Bytes
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
package main
import (
"gopkg.in/yaml.v2"
"errors"
"strings"
)
type Circle struct {
Filename string
Test struct{ Override []string }
}
func (c *Circle) filename() string {
if c.Filename == "" {
c.Filename = "circle.yml"
}
return c.Filename
}
func (c *Circle) runTests() error {
err := errors.New("")
if !doesFileExist(c.filename()) {
s := []string{c.filename(), "file does not exist"};
err = errors.New(strings.Join(s, " "))
return err
}
raw := readFile(c.filename())
err = c.getCommandsFromYAML([]byte(raw))
for _, cmd := range c.Test.Override {
err = executeCommands(cmd)
}
return err
}
func (c *Circle) getCommandsFromYAML(raw []byte) error {
err := yaml.Unmarshal(raw, &c)
return err
}