Skip to content

Create RFC Simple Tests#57

Open
webdesus wants to merge 2 commits intomasterfrom
RFC-Simle-Test
Open

Create RFC Simple Tests#57
webdesus wants to merge 2 commits intomasterfrom
RFC-Simle-Test

Conversation

@webdesus
Copy link
Copy Markdown
Owner

@webdesus webdesus commented May 4, 2022

Submit for discussion

@pczarn
Copy link
Copy Markdown

pczarn commented May 4, 2022

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

Copy link
Copy Markdown

@pczarn pczarn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: {}

Comment thread rfc/simplify_tests.md
Comment thread rfc/simplify_tests.md Outdated
Comment thread rfc/simplify_tests.md Outdated
@webdesus
Copy link
Copy Markdown
Owner Author

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.
But we have problem to define what is it. This is file or directory.

My propose using slash

example:

file.txt: "data",
/dir,
/another_dir: {
    modified: "2022-05-10 14:45" 
}
another_file: "data"

@webdesus webdesus added the rfc label May 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants