Conversation
|
I recommend that you link directly to rich format like Rust contributors do: https://github.com/webdesus/fs_extra/blob/RFC-Simle-Test/rfc/simplify_tests.md |
There was a problem hiding this comment.
Nice RFC. I agree, this is the right solution for testing. My first idea was about using macros, but YAML works even better. I do not see any downsides for this approach. YAML is a heavy dependency, but acceptable here as a dev dependency.
I'm thinking about YAML data format. The RFC should explain a little the test format with more than examples.
I propose another data format. I did not like type: FILE / DIRECTORY. Example:
NAME: it_copies_work
FILES:
test.txt: test_data
out:
test.txt: test_data
empty_file: ""
empty_directory: {}Formal description:
The declarative approach uses the YAML format to declare filesystem trees.
The TestFS struct has two methods, new and check, that accept one argument, a string in the YAML format that parses to a hash. Argument to method new must parse to a hash with two entries, a string under the NAME key, and a filesystem tree description under the FILES key. Argument to method check must parse to a filesystem tree description.
A filesystem tree description is a hash. Each value in this hash is either a string or a hash. If a string, the corresponding key is a file name and the value is the file's content. If a hash, the key is a directory name and the value is the directory's tree in the same format as filesystem tree description.
A filesystem tree description may be empty. Example:
NAME: it_does_something
FILES: {}|
In personal conversation @pczarn proposed additional changes for format: file.txt: {
content:"data",
modified: "2022-05-10 14:45"
},
simple_file.txt: "data"This format allows using meta information for file and directory. My propose using slash example: file.txt: "data",
/dir,
/another_dir: {
modified: "2022-05-10 14:45"
}
another_file: "data" |
Submit for discussion