assert-rs / snapbox

Snapshot testing for a herd of CLI tests
docs.rs/trycmd
Apache License 2.0
136 stars 18 forks source link

bin not found causes "ignored" not an error #105

Open sourcefrog opened 2 years ago

sourcefrog commented 2 years ago

In trying to set up trycmd I had this md file:

```trycmd
$ cargo mutants --help
```

This gives a result of ignored.

With --nocapture I could find out:

running 1 test
[              trycmd::runner]  Substitutions { vars: {"[CWD]": "/home/mbp/src/mutants"}, unused: {"[EXE]"} }
[              trycmd::runner]  bin="cargo" not found
[              trycmd::runner]  Case: Ok(
    Output {
        path: "trycmd/hello.trycmd",
        id: Some(
            "4",
        ),
        spawn: Spawn {
            exit: None,
            status: Skipped,
        },
        stdout: None,
        stderr: None,
        fs: Filesystem {
            context: [],
        },
    },
)
Testing trycmd/hello.trycmd:4 ... ignored
test trycmd_tests ... ok

It seems to me that "file not found" should probably be a test failure (by default?) not ignored?

epage commented 2 years ago

The idea was to gracefully allow mixing untestable examples with testable examples.

We do have the ignore tag and it is unlikely people will have testable and untestable examples within the same code block, so we could probably change this.

sourcefrog commented 2 years ago

Yep, having an option to ignore seems fine, but maybe it should be the wrong default....

Martin

On Wed, Jul 20, 2022 at 7:58 AM Ed Page @.***> wrote:

The idea was to gracefully allow mixing untestable examples with testable examples.

We do have the ignore tag and it is unlikely people will have testable and untestable examples within the same code block, so we could probably change this.

— Reply to this email directly, view it on GitHub https://github.com/assert-rs/trycmd/issues/105#issuecomment-1190394485, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACUR43O2DSIUXTPBVFN2ALVVAHZPANCNFSM5Z4NPIBQ . You are receiving this because you authored the thread.Message ID: @.***>

kleinesfilmroellchen commented 2 years ago

It seems like I had the exact error, just that I couldn't even access detailed error information via --nocapture. This is definitely confusing as I first believed it to be a platform-specific error.

epage commented 2 years ago

0.14.0 is released with this changed.

epage commented 1 year ago

I had forgotten: this is important for when examples are conditionally present: https://github.com/clap-rs/clap/pull/4439

kleinesfilmroellchen commented 1 year ago

Interesting; is there a better solution that covers both use cases?

AucaCoyan commented 8 months ago

Hi! I'm a bit new to the project. What do you thing about returning an error if a binary is either skipped or doesn't have a name? The ignored keyword tells my common sense that I wrote a #[skip] on purpose or I forgot to include in a glob path like tests/**/*.toml. Having a console output "test is ignored" but not telling me why was a hard thing to debug in my case

epage commented 8 months ago

I'd recommend reviewing the thread for what has been previously considered.