spf icon indicating copy to clipboard operation
spf copied to clipboard

Implement testing engine that utilizes pyspf YAML

Open zaccone opened this issue 9 years ago • 3 comments

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'.

zaccone avatar Jul 06 '16 15:07 zaccone

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.

zaccone avatar Dec 28 '16 10:12 zaccone

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)
}

tv42 avatar Oct 23 '18 15:10 tv42

Thanks TV. Would you consider creating a PR to prepare testbed to pyspf tests?

zaccone avatar Oct 24 '18 08:10 zaccone