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

1703: Introducing MapExtensionToUnknown MappingTarget #1889

Merged
merged 25 commits into from
Oct 25, 2021

Conversation

cbolgiano
Copy link
Contributor

Resolves #1703

cbolgiano added a commit to cbolgiano/bat that referenced this pull request Oct 6, 2021
@cbolgiano cbolgiano mentioned this pull request Oct 6, 2021
@cbolgiano
Copy link
Contributor Author

Please I need guidance on what to do with the failing regression test for resolv.conf. Is the test valid anymore without the explicit mapping, can it be remove, or what can we do to fix the failing test?

@Enselic
Copy link
Collaborator

Enselic commented Oct 7, 2021

The failing test is a real failure. You can reproduce it locally like this:

Step-by-step:
cargo run -- tests/syntax-tests/source/resolv.conf/resolv.conf

Expected:
Colors

Actual:
No colors

Not sure why, you'll have to debug it :)

But, I would expect us to have to split up get_extension_syntax() into two different helper functions, that each call try_with_stripped_suffix, so that we would have the following order when finding a syntax:

  1. MapToUnknown (can still be first to minimize risk of regressions)
  2. MapToSyntax (can still be second to minimize risk of regressions)
  3. Call self.find_syntax_by_extension with the file name
  4. MapToUnknownUnlessExactFileNameMatch
  5. Call self.find_syntax_by_extension with the file extension
  6. First line match

Something like that. Thanks again for taking a shot at solving this in a generic way!

@Enselic
Copy link
Collaborator

Enselic commented Oct 7, 2021

After thinking about it some more, MapExtensionToUnknown is probably a better name

@cbolgiano
Copy link
Contributor Author

Thank you for the guidance and patience. I look forward to giving this another shot.

@cbolgiano
Copy link
Contributor Author

I found out where the issue was in the regression tests. Pushing up a fix now.

@cbolgiano cbolgiano changed the title 1703: Introducing MapToUnknownUnlessExactFileNameMatch MappingTarget 1703: Introducing MapExtensionToUnknown MappingTarget Oct 8, 2021
@cbolgiano
Copy link
Contributor Author

Not quite there yet. Will continue to investigate.

@Enselic
Copy link
Collaborator

Enselic commented Oct 8, 2021

In case it helps, here are the commands I personally use to simulate our CI pipeline. Regular tests:

% echo bat ci && cargo fmt -- --check && cargo doc --locked --no-deps --document-private-items --all-features && cargo clippy --all-targets --all-features && cargo test --doc && cargo test && PATH="./target/debug:$PATH" tests/syntax-tests/test_custom_assets.sh && echo ci pass

Syntax regression tests:

cargo build --no-default-features --features minimal-application,build-assets && PATH="./target/debug:$PATH" assets/create.sh && cargo build --release --no-default-features --features minimal-application,build-assets && PATH="./target/release:$PATH" tests/syntax-tests/regression_test.sh

If the above commands pass locally, you can be pretty sure that our CI pipeline in GitHub Actions will also pass.

@cbolgiano
Copy link
Contributor Author

That helps greatly. Thank you.

Going to take some time to better understand the code and attempt again this weekend.

…c *.conf support using MapExtensionToUnknown
@cbolgiano
Copy link
Contributor Author

The comments for the get_syntax_for_path, the guidance on the desired order, and the knowledge on how to run the regression tests like the CI locally really helped. Thank you.

Copy link
Collaborator

@Enselic Enselic left a comment

Choose a reason for hiding this comment

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

Thanks for your continued work on this! Getting better and better each time.

CHANGELOG.md Outdated Show resolved Hide resolved
src/syntax_mapping.rs Show resolved Hide resolved
src/syntax_mapping.rs Outdated Show resolved Hide resolved
src/assets.rs Outdated Show resolved Hide resolved
src/assets.rs Outdated Show resolved Hide resolved
@cbolgiano
Copy link
Contributor Author

Pushed.

@cbolgiano
Copy link
Contributor Author

I ran regression tests but not integration tests locally this pass. Need to resolve the single failing integration test.

@cbolgiano
Copy link
Contributor Author

cbolgiano commented Oct 14, 2021

I have the integration tests passing locally but now a different set of regression tests are failing. The Ignored suffixes regression tests are failing. I am going to push what I have so far. To get more eyes on where I am at.

@cbolgiano
Copy link
Contributor Author

I have good news. I was able to get the regression and integration tests to pass locally. Now I will be pushing up the latest changes.

@Enselic
Copy link
Collaborator

Enselic commented Oct 14, 2021

Thanks for the updates. Just wanted to let you know that I have noticed your review request. Might take a while before I find the time to do a detailed review, however.

I glanced it over, and on a high level it looks good. But I think we can polish the new if-case code some more. While waiting for review, feel free to fix the lint warnings that clippy (the Rust linter) finds. You can see the lints in the "Files changed" tab in the PR.

@cbolgiano
Copy link
Contributor Author

Thanks for the updates. Just wanted to let you know that I have noticed your review request. Might take a while before I find the time to do a detailed review, however.

I glanced it over, and on a high level it looks good. But I think we can polish the new if-case code some more. While waiting for review, feel free to fix the lint warnings that clippy (the Rust linter) finds. You can see the lints in the "Files changed" tab in the PR.

Pushed changes to address issues found by linter.

src/assets.rs Outdated Show resolved Hide resolved
src/assets.rs Outdated Show resolved Hide resolved
src/assets.rs Outdated Show resolved Hide resolved
src/assets.rs Outdated Show resolved Hide resolved
@cbolgiano
Copy link
Contributor Author

Regression and integration tests pass locally. Pushing up now.

src/assets.rs Show resolved Hide resolved
src/assets.rs Show resolved Hide resolved
src/syntax_mapping.rs Show resolved Hide resolved
@cbolgiano
Copy link
Contributor Author

Pushed latest changes. Please feel free to update documentation, test, or changelog as needed. This was a fun problem to work on. Thank you for all the time! Please do not forget PR #1882 I'd be happy to make any changes needed there after this PR has been merged.

Copy link
Collaborator

@Enselic Enselic left a comment

Choose a reason for hiding this comment

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

I made some final adjustments in a commit of my own since I figured that would be easier than commenting. Do you think the changes look ok?

In any case, I consider this code Approved now! 🎉 Thanks a lot for all the help!

I will let this PR remain open for some time to give other maintainers a chance to look at it before it is merged.

@Enselic
Copy link
Collaborator

Enselic commented Oct 24, 2021

@sharkdp @keith-hall I plan to (squash and) merge this early next week. Let me know if you would like more time to look at it.

Copy link
Owner

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

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

Excellent work - thank you very much to everyone involved.

src/syntax_mapping.rs Outdated Show resolved Hide resolved
@Enselic Enselic merged commit 7fe4fdf into sharkdp:master Oct 25, 2021
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.

Some *.conf files not highlighted
4 participants