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

Feature request: fixture file as input to pipe (with_stdin) #24

Closed
mssun opened this issue Jul 14, 2018 · 11 comments
Closed

Feature request: fixture file as input to pipe (with_stdin) #24

mssun opened this issue Jul 14, 2018 · 11 comments
Labels
enhancement Improve the expected

Comments

@mssun
Copy link
Contributor

mssun commented Jul 14, 2018

It will be very useful if I can use a fixture file as input

@epage
Copy link
Contributor

epage commented Jul 14, 2018

Thats a really great idea!

For stdin, its just a matter of coming up with the name.

For stdout, stderr, the challenge is we won't know if its intended to be binary or str (this matters for the new feature I'm writing). I wonder if its best to l leave it as stdout(predicte::path::eq_file(path))

@epage epage added the enhancement Improve the expected label Jul 14, 2018
@epage
Copy link
Contributor

epage commented Jul 14, 2018

Also, something else for us to consider with stdin is we might want to support chunking in case someone is testing a really large file.

@mssun
Copy link
Contributor Author

mssun commented Jul 15, 2018

Thanks @epage, I didn't notice the usage of stdout(predicte::path::eq_file(path)) actually. I think it's OK for me to use predicates.

In terms of the name, how about with_fixture_stdin?

@epage epage changed the title Feature request: fixture file as input to pipe (with_stdin), stdout and stderr Feature request: fixture file as input to pipe (with_stdin) Jul 16, 2018
@epage
Copy link
Contributor

epage commented Jul 16, 2018

Thanks @epage, I didn't notice the usage of stdout(predicte::path::eq_file(path)) actually. I think it's OK for me to use predicates.

I've gone ahead and removed stdout/stderr from this to make our narrowed focus clear.

In terms of the name, how about with_fixture_stdin?

imo whether you use a file or in-memory string, both would be considered fixtures, right?

So one option is with_stdin_file? Another options is with_stdin().from_bytes("Hello World") / with_stdin().from_path("./hello.txt").

@mssun
Copy link
Contributor Author

mssun commented Jul 16, 2018

I've gone ahead and removed stdout/stderr from this to make our narrowed focus clear.

Yes, you are right.

I think with_stdin().from_bytes("Hello World") / with_stdin().from_path("./hello.txt") are more readable.

epage added a commit to epage/assert_cmd that referenced this issue Jul 19, 2018
There is just enough overlap between how people expect paths and strings
to be used, I felt we couldn't just have an `IntoStdIn`.

Long term, we should consider streaming the content from file / reader
to stdin.

Fixes assert-rs#24

BREAKING CHANGE: `with_stdin(buffer)` is now
`with_stdin().buffer(buffer)`.
epage added a commit to epage/assert_cmd that referenced this issue Jul 19, 2018
There is just enough overlap between how people expect paths and strings
to be used, I felt we couldn't just have an `IntoStdIn`.

Long term, we should consider streaming the content from file / reader
to stdin.

Fixes assert-rs#24

BREAKING CHANGE: `with_stdin(buffer)` is now
`with_stdin().buffer(buffer)`.
@epage epage closed this as completed in #26 Jul 19, 2018
@epage
Copy link
Contributor

epage commented Jul 19, 2018

Publishing v0.6.0 with this fix. Sorry for the delay.

@mssun
Copy link
Contributor Author

mssun commented Jul 19, 2018

I guess I cannot use .stdout(predicate::path::eq_file(Path::new("filename")) right now?

I'm a little confused about FileContentPredicate, BinaryFilePredicate, and StrFilePredicate. Anyway, can you give me an example of how to compare content in a fixture file with the stdout (in binary or in str). Thank you so much!

@epage
Copy link
Contributor

epage commented Jul 19, 2018

Yeah, I realized that on closer inspection and opened assert-rs/predicates-rs#56

My plan has been to finish assert-rs/predicates-rs#7 first because I've started it and it is more invasive but it is larger and controversial, so it might take longer to get in.

@mssun
Copy link
Contributor Author

mssun commented Jul 19, 2018

I see. Thank you @epage. Can you ping me if it's ready to use?

@epage
Copy link
Contributor

epage commented Jul 19, 2018

Just to check, is that another blocking issue for you?

I see. Thank you @epage. Can you ping me if it's ready to use?

Alternatively, you could subscribe to the issue?

@mssun
Copy link
Contributor Author

mssun commented Jul 19, 2018

Yes, my expectation is to pipe in fixture files and compare stdout with fixture files. I have subscribed these issues you mentioned. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve the expected
Projects
None yet
Development

No branches or pull requests

2 participants