Description
#105 has gotten us off to a good start to make sure that our JSON files are syntactically correct, but does nothing to check the contents.
I have historically concerned myself (maybe to an unreasonable degree, even) about this second aspect:
- Add sum-of-multiples.json #206 (comment)
- dominoes: Add JSON test data #221 (comment)
- tournament: Add JSON file #287 (comment)
- react: Add JSON test data #358 (comment)
- pov: Add canonical data #390 (comment)
- forth: Add canonical data #394 (comment)
- minesweeper: remove number from input, add mines #456 (comment)
- https://github.com/petertseng/x-common/tree/verify and https://github.com/petertseng/x-common/commits/verify
Since it has now been asked in #456, now is the time to ask what y'all think: Should we have such a thing in our CI?
The current implementation in my verify
branch is as follows:
- Each exercise directory may optionally have a
verify.rb
file. - The idea is that Travis could run this file if it is present.
- Some
verify.rb
are more detailed than others (e.g.minesweeper
only checks that the inputs are indeed the cleaned version of the outputs but doesn't check that the output is a correct annotation,pov
actually has a full solution to the exercise to make sure the input/output pairs are correct)
- Pro: Automatic verification helps avoid incorrect data, and after all we are but human.
- Con: We necessarily have to pick some language in which to write the verification scripts, and perhaps such a choice unnecessarily biases this repo toward that language.
- But at least it's better than nothing, right?
- And I suppose we could support multiple languages...
- Con: Does this mean we have to reimplement an example solution for each exercise and maintain it in this repo?
- What's the alternative? Pull in an existing example solution from a language track that has the exercise? Then Travis CI starts to depend on not just this repo but the presence of some other repo as well.
I am happy to clean up my verify
branch and submit it as a PR if we decide the pros outweigh the cons, with discussion to find any pros and cons I missed.
Aside: As an argument for standardisation (as proposed by #336), if all the JSON had a standardised structure you could imagine that we could remove some of the logic that has to be implemented separately in each verify.rb script.