mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 08:18:15 +03:00
1a78607026
Summary: This diff adds snapshot tests for most eden api wire types, while at the same time making the testing code much smaller, including tests for "wire" and "serialize" roundtrips. ## Context: The previous diff had added an easy way to add snapshot tests. This stack aims to simplify the wire protocol code needed to create/modify an endpoint. A good thing to do before that is to add snapshot tests to all wire types, so that if we change them in a refactor, we're confident they still work exactly the same. This will also be useful when a type is changed in the future. ## How this makes tests easier - In order to create snapshot tests, we need example objects to test with. Luckily we already use a framework for generating example objects (quickcheck::Arbitrary), so the idea here is to use that to make snapshot tests as automatic as possible. - At the same time, the "wire" and "serialize" roundtrip tests (which also used Arbitrary), can also be made more automatic. Now, using a simple helper, `auto_wire_tests!(WireObjectName)`, it is possible to derive all three types of tests automatically. This makes the current code smaller, and safer as we now have the additional safety provided by snapshot tests. ## Observations - Not all wire types had tests implemented for them (I assume because it was too much work doing so, and might have done that myself in the past), I only moved the ones that already had. I'll do another pass and add remaining objects on a following diff. - There are a couple actual non-refactor changes. I'll add comments explaining those. - quickcheck crate is using quite an old version. I tried updating but it snowballed into something much more complicated, so I kept using the old version. We'll need to get to it at some point, though. Reviewed By: markbt Differential Revision: D31019233 fbshipit-source-id: 30c4a90848d0a5dcaffb89b9a0cd1cebfe4ace55 |
||
---|---|---|
.. | ||
content-stores | ||
hook_manager_factory | ||
hooks-tests/src | ||
src | ||
Cargo.toml |