Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create RFC Simple Tests #57

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Create RFC Simple Tests #57

wants to merge 2 commits into from

Conversation

webdesus
Copy link
Owner

@webdesus webdesus commented May 4, 2022

Submit for discussion

@pczarn
Copy link

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

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

rfc/simplify_tests.md Show resolved Hide resolved
rfc/simplify_tests.md Outdated Show resolved Hide resolved
rfc/simplify_tests.md Outdated Show resolved Hide resolved
@webdesus
Copy link
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