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

filter::parse_spec() ignore bogon empty, blank (sub)strings #188

Merged
merged 2 commits into from Dec 7, 2020

Conversation

salewski
Copy link
Contributor

@salewski salewski commented Dec 4, 2020

This PR fixes an issue with filter::parse_spec() accepting as legit some empty and blank spec (sub)strings that it should be ignoring.

There are two commits:

  1. The first adds five unit tests that demonstrate the issue (three of them fail).

  2. The second commit contains the simple fix, which basically extends the intent of the existing code (ignore invalid spec strings) to cover these additional scenarios. With this change, all of the tests pass.

@salewski salewski force-pushed the ads/parse-spec-ignore-blank-spec branch from 954267a to 96e3e84 Compare December 5, 2020 00:04
@salewski
Copy link
Contributor Author

salewski commented Dec 5, 2020

Just a heads-up that the "Check formatting" CI test is flagging an issue unrelated to this changeset[0].

I would fix that up in a separate PR, but since it wants to remove a trailing comma I'm not even sure if that change is wanted. Leaving the trailing commas seems to be more idiomatic, so maybe the lint needs tuning instead?

FWIW, this is what it is saying:

    Run actions-rs/cargo@v1
    /usr/share/rust/.cargo/bin/cargo fmt -- --check
    Diff in /home/runner/work/env_logger/env_logger/src/lib.rs at line 231:
     
     #![doc(
         html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
    -    html_favicon_url = "https://www.rust-lang.org/static/images/favicon.ico",
    +    html_favicon_url = "https://www.rust-lang.org/static/images/favicon.ico"
     )]
     #![cfg_attr(test, deny(warnings))]
     // When compiled for the rustc compiler itself we want to make sure that this is
    Error: The process '/usr/share/rust/.cargo/bin/cargo' failed with exit code 1

[0]: It did flag some whitespace changes in my original push, but I fixed those up and rebased. Now the above item is the only thing it is complaining about.

These unit tests demonstrate filter::parse_spec() accepting as legit
empty and blank spec strings that it should be ignoring:

    $ cargo test 'filter::tests::'
    ...
    failures:
        filter::tests::parse_spec_blank_level_isolated
        filter::tests::parse_spec_blank_level_isolated_blank_comma
        filter::tests::parse_spec_blank_level_isolated_comma_blank

    test result: FAILED. 21 passed; 3 failed; 0 ignored; 0 measured; 11 filtered out

Fix to come in follow-up commit.
Fix issue demonstrated by unit tests in commit 2ff2bf1.

While parsing comma-separated substrings, parse_spec() now trims the
values to ensure empty and blank substrings (which are invalid) are
ignored.

Previously, only-comma-separated empty substrings were being
ignored. This change extends that intent to also ignore the empty
string (no comma), stand-alone blank strings (no comma), and comma-
separated variations of empty and/or blank substrings.
@salewski salewski force-pushed the ads/parse-spec-ignore-blank-spec branch from 96e3e84 to 780e7c5 Compare December 7, 2020 02:49
@salewski
Copy link
Contributor Author

salewski commented Dec 7, 2020

I just rebased this and force pushed, just to pull in the rustfmt fix and re-trigger the CI checks. I'm expecting them to all go now.

Copy link
Contributor

@jplatte jplatte left a comment

Choose a reason for hiding this comment

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

Thanks!

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

Successfully merging this pull request may close these issues.

None yet

2 participants