-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathscanner_test.go
62 lines (52 loc) · 1.19 KB
/
scanner_test.go
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package candiedyaml
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"io/ioutil"
"os"
"path/filepath"
)
var scan = func(filename string) {
It("scan "+filename, func() {
file, err := os.Open(filename)
Ω(err).To(BeNil())
parser := yaml_parser_t{}
yaml_parser_initialize(&parser)
yaml_parser_set_input_reader(&parser, file)
failed := false
token := yaml_token_t{}
for {
if !yaml_parser_scan(&parser, &token) {
failed = true
break
}
if token.token_type == yaml_STREAM_END_TOKEN {
break
}
}
file.Close()
// msg := "SUCCESS"
// if failed {
// msg = "FAILED"
// if parser.error != yaml_NO_ERROR {
// m := parser.problem_mark
// fmt.Printf("ERROR: (%s) %s @ line: %d col: %d\n",
// parser.context, parser.problem, m.line, m.column)
// }
// }
Ω(failed).To(BeFalse())
})
}
var scanYamls = func(dirname string) {
fileInfos, err := ioutil.ReadDir(dirname)
Ω(err).To(BeNil())
for _, fileInfo := range fileInfos {
if !fileInfo.IsDir() {
scan(filepath.Join(dirname, fileInfo.Name()))
}
}
}
var _ = Describe("Scanner", func() {
scanYamls("fixtures/specification")
scanYamls("fixtures/specification/types")
})