-
Notifications
You must be signed in to change notification settings - Fork 19
Testing binary output #80
Comments
I think its fully reasonable that we support this. We'll just need to make sure we work to keep the API simple for those that don't need this.
I think noting other relevant crates is really valuable for the ecosystem. Right now, My initial reaction is to keep this directionality.
If we find a good way for our crates to interoperate, then I think it'd make sense for your crate to mention assert_cli and maybe even include examples.
We'll probably want to brainstorm what color/format assertions make sense and what is the best way to expose them in the API. One approach is just to make helper functions that can easily be boxed into |
Hi! @epage already answered very thoughtfully! I just wanted to confirm that the only reason we take Another note: |
I think we need I agree with everything else said. It would be great to get this feature! |
Huh, I assumed |
Huh, I don't think OsString is specific to paths. To me, it was always just a wrapper around Vec<u8> that 'guarantees' WTF-8 encoding.
But well, I can live with Vec<u8>.
Does your crate support windows terminal colors, btw? (People told me to use termcolor if I cared about that.)
… Am 10.01.2018 um 17:20 schrieb Garrett Berg ***@***.***>:
I think we need Vec<u8>, not OsString. OsString is for representing any OS's path. I don't think you can use escape codes (i.e. color, bold, etc) in file names!
I agree with everything else said. It would be great to get this feature!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
My crate currently "supports" windows terminal colors by ignoring all styles. Accoridng to @BurntSushi "you don't" test windows terminal colors anyway I would like to send the right signals (or whatever is required, I haven't looked into it yet) to support windows colors for the end users though, even if it isn't testable. I think it should be pretty simple too hook in burntsushi's library to do so. In order to diff better, I recommend:
This makes it much easier to see what the differences are. Honestly though, if Edit: you said it "guarantees WTF-8 encoding" -- so that would not be arbitrary and so wouldn't work. |
Let me also say a little about what I intend to do when I unify these libraries. This feels like the same rough goal as I would like to be able to specify the assertions to do for any given project through a simple yaml file. So let's say that I had a project
where foo.txt contains:
You could then write
It doesn't look that cool at first glance, until you realize that
Edit: forgot to add the API
Edits: I added |
If you are interested I can open a separate ticket. If not, I totally understand wanting to keep things simple. I can start my own project! I wish I could call it |
Just a heads up: I'm very wary of adding a YAML-based DSL to this crate.
It'd like to keep assert_cli focused on doing *just* CLI output assertions.
We talked about doing more things (like dealing with tempdirs and offering
tools to write fluid test builders) but that should live in another crate
that depends on assert_cli. (At least I hope this was my stance on this
before; it's been a while and I might have changed my mind without
noticing!)
You are of course free to publish a crate that transforms YAML to
assert_cli calls as a proc macro or build step.
Garrett Berg <[email protected]> schrieb am Mi. 10. Jan. 2018 um
18:22:
… Let me also say a little about what I intend to do when I unify these
libraries. This *feels* like the same rough goal as assert_cli so I
thought you might be interested in joining forces (with a feature flag)
instead of a separate crate.
I would like to be able to specify the assertions to do for any given
*project* through a simple yaml file. So let's say that I had a project
project/
foo.txt
assert_cli.yaml
where foo.txt contains:
This is foo
It has multiple lines
You could then write assert_cli.yaml:
- commands:
- cmd: echo foo.txt
- expect:
- |
This is foo
It has multiple lines
- {t: "this line is red\n", c: red}
- ["this line has ", {t: "mixed styles ", b: true}, {t: "like bold and blue\n", c: blue}]
It doesn't look that cool at first glance, until you realize that expect
field is just a Vec<termstyle::El>. So you can specify style and
formatting as well!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#80 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABOXz4TIy3KBkT5WSLoXR4PMjDT_pMeks5tJPHUgaJpZM4RZc56>
.
|
Sounds good! I was also wary of including so much extra functionality in a crate like this. Do note that As soon as this bug get's resolved, I'll get working on that 😄 |
@killercup that is also what I remember us deciding to do. |
@BurntSushi made an excellent point in a recent reddit thread that most ANSI escape codes are actually valid unicode! So while this is still an issue (since technically the terminal can output non-UTF8 bytes) it can probably be worked around by most people. Just thought I would let anyone know that they probably can use assert_cli to test a terminal application with color today! I'm changing the title to reflect the actual state of things. |
If you pass a `&str` into the predicates, the programs output is assumed to be UTF-8 and will be converted accordingly. If you pass `&[u8]` into the predicates, the program output is treated as raw binary. Fixes assert-rs#80
Hello!
I just released the termstyle crate which makes it easier to build and test terminal applications that use color and tables (horray!).
I was hoping to use it with
assert_cli
to test my crate, however theis()
method seems to requre that the input can be coerced into aString
, which terminal output with color certainly cannot.Separate question: is there any interest in combining forces here? We could recommend
termstyle
as a possible crate to build your cli with (probably behind a feature flag) and we could add ahas_els()
method (or something) to make it more convinient to build assertions.The text was updated successfully, but these errors were encountered: