Open zaccone opened 8 years ago
SPF testsuite is an invaluable source of tests, but the .yml files are super hard to read and parse: a) most popular yaml parsers for Go are not able to process multiple records separaed by '---' b) Structure of the YAML records is not identical, i.e sometimes a records is a string, sometimes it may be a list of strings. It's all fine in Python, but fails in languages like Go etc.
Current plan is evaluation of reusing Python code to parse and interpret tests but somehow utilize out's spf library to parse tests.
a) most popular yaml parsers for Go are not able to process multiple records separaed by '---'
https://godoc.org/gopkg.in/yaml.v2 just repeat calls to Decoder.Decode.
b) Structure of the YAML records is not identical, i.e sometimes a records is a string, sometimes it may be a list of strings. It's all fine in Python, but fails in languages like Go etc.
Untested code, but you want something like this:
type Strings []string
func (s *Strings) UnmarshalYAML(unmarshal func(interface{}) error) error {
var ss string
if err := unmarshal(&ss); err == nil {
*s = []string{ss}
return nil
}
return unmarshal(s)
}
Thanks TV. Would you consider creating a PR to prepare testbed to pyspf tests?
Package pySPF is a reference implementation and we can assume it's correct. It also provides great testsuite that we would like to utilize and see if the code behaves correctly. As schema is defined in YAML we need a way to read/use those tests. Task: Implement such 'engine'.