basho / cuttlefish

never lose your childlike sense of wonder baby cuttlefish, promise me?
Apache License 2.0
205 stars 124 forks source link

Refactor and fix cuttlefish_duration parsing. #112

Closed seancribbs closed 10 years ago

seancribbs commented 10 years ago

The main fix here is that cuttlefish_duration:parse/1,2 will now properly return {error, Reason} instead of just error when an invalid duration is parsed. Previously, this caused error to be emitted in the generated config files as seen in basho/riak_kv#809.

Also, in some cases badarith exceptions might be raised when calling parse/2 because it assumed the parse result was correct and not an error.

This adds another neotoma parser to the project because the original code was too difficult to understand and verify, IMO. The new parser returns a number when it successfully consumes the entire input, any other result (incomplete parse, parse failure) is treated as an erroneous duration value.

There are two tests that verify the fix for basho/riak_kv#809, one uses a schema fixture in cuttlefish_integration_test, the other adds another case to the extended types test in cuttlefish_generator.

hazen commented 10 years ago

Tests have been added and they pass :+1: