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

Issue #8664 | Bug 🐛: --match-path does not work with watch mode: cannot be used multiple times #8664 #8709

Merged
merged 5 commits into from
Aug 21, 2024

Conversation

PabloVillaplana
Copy link
Contributor

Issue Link -> #8664

Pull Request Description

Currently the following command was being attempted to be executed:

forge test --match-path test/Counter.t.sol -w

But by default it can be done without the --math-path, since the command adds it by itself

--match-path does not work with watch mode: cannot be used multiple times

`error: the argument '--match-path ' cannot be used multiple times

Usage: forge test [OPTIONS]

For more information, try '--help'.
[Command exited with 2, lasted 10.7375ms]`

Motivation

My motivation is to continue contributing to tools like Foundry, to learn from them and how they work in Open Source environments. I really like to always be in constant practice and what better way to do it than by practicing and helping the community.

Solution

Currently when running the command:

forge test --match-path test/Counter.t.sol --watch

It is not necessary to add the ---match-path because by default the --watch is added by code, now what I did was add a validation that if it already has it in the arguments, do not add it to avoid redundancy and errors like the reported issue


// Check if any of the filters are present
let path_pattern_exists = filter.args().path_pattern.is_some();

// Marker to check whether to override the command.
let _no_reconfigure = filter.args().test_pattern.is_some() ||
Copy link
Member

Choose a reason for hiding this comment

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

I think we should just use no_reconfigure here, looks like this was used earlier to avoid updating the command if any filters were set

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done ✅, thank you for the review 👍🏾

Copy link
Member

Choose a reason for hiding this comment

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

please remove newlines and I think there's no need for underscore in var name name

crates/forge/bin/cmd/watch.rs Outdated Show resolved Hide resolved

// Check if any of the filters are present
let path_pattern_exists = filter.args().path_pattern.is_some();

// Marker to check whether to override the command.
let _no_reconfigure = filter.args().test_pattern.is_some() ||
Copy link
Member

Choose a reason for hiding this comment

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

please remove newlines and I think there's no need for underscore in var name name

@klkvr klkvr enabled auto-merge (squash) August 21, 2024 20:49
@klkvr klkvr merged commit fa0e0c2 into foundry-rs:master Aug 21, 2024
20 checks passed
@PabloVillaplana PabloVillaplana deleted the bug-8664-watch-mode branch August 22, 2024 00:40
benwjhack pushed a commit to CompassLabs/foundry-test that referenced this pull request Sep 11, 2024
…mode: cannot be used multiple times foundry-rs#8664 (foundry-rs#8709)

* Issue foundry-rs#8664 | Bug 🐛: --match-path does not work with watch mode: cannot be used multiple times foundry-rs#8664

* reuse _no_reconfigure var

* Remove undescore var name and also remove no needed extra lines

* fmt

---------

Co-authored-by: Arsenii Kulikov <[email protected]>
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.

2 participants