Currently when implementing SWHID in a new language, you need to either:
- Extract test cases from the Python swh-model implementation
- Manually verify against known hashes
- Hope your implementation matches the spec correctly
A language-agnostic test format (JSON, YAML, or similar) with input data and expected SWHID hashes for all object types would make it much
easier to:
- Verify new implementations produce correct hashes
- Catch edge cases during development
- Ensure consistency across implementations
This came up while working on the Ruby implementation (https://github.com/andrew/swhid) where I had to manually extract test cases from the
Python library to validate correctness.
Example test cases could include:
{
"type": "content",
"data": "Hello, World!",
"expected_hash": "96898574d1b88e619be24fd90bb4cd399acbc5ca"
}
{
"type": "directory",
"entries": [
{
"name": "README.md",
"type": "file",
"perms": "100644",
"target": "37ec8ea2110c0b7a32fbb0e872f6e7debbf95e21"
}
],
"expected_hash": "d7ed3d2c31d608823be58b1cbe57605310615231"
}
{
"type": "revision",
"directory": "85a74718d377195e1efd0843ba4f3260bad4fe07",
"parents": ["01e2d0627a9a6edb24c37db45db5ecb31e9de808"],
"author": "Linus Torvalds <torvalds@linux-foundation.org>",
"author_timestamp": 1436739030,
"author_timezone": "-0700",
"committer": "Linus Torvalds <torvalds@linux-foundation.org>",
"committer_timestamp": 1436739030,
"committer_timezone": "-0700",
"message": "Linux 4.2-rc2\n",
"expected_hash": "bc0195aad0daa2ad5b0d76cce22b167bc3435590"
}
Would be happy to help contribute test cases if this sounds useful.
Currently when implementing SWHID in a new language, you need to either:
A language-agnostic test format (JSON, YAML, or similar) with input data and expected SWHID hashes for all object types would make it much
easier to:
This came up while working on the Ruby implementation (https://github.com/andrew/swhid) where I had to manually extract test cases from the
Python library to validate correctness.
Example test cases could include:
{ "type": "content", "data": "Hello, World!", "expected_hash": "96898574d1b88e619be24fd90bb4cd399acbc5ca" } { "type": "directory", "entries": [ { "name": "README.md", "type": "file", "perms": "100644", "target": "37ec8ea2110c0b7a32fbb0e872f6e7debbf95e21" } ], "expected_hash": "d7ed3d2c31d608823be58b1cbe57605310615231" } { "type": "revision", "directory": "85a74718d377195e1efd0843ba4f3260bad4fe07", "parents": ["01e2d0627a9a6edb24c37db45db5ecb31e9de808"], "author": "Linus Torvalds <torvalds@linux-foundation.org>", "author_timestamp": 1436739030, "author_timezone": "-0700", "committer": "Linus Torvalds <torvalds@linux-foundation.org>", "committer_timestamp": 1436739030, "committer_timezone": "-0700", "message": "Linux 4.2-rc2\n", "expected_hash": "bc0195aad0daa2ad5b0d76cce22b167bc3435590" }Would be happy to help contribute test cases if this sounds useful.