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

Support multiple recipe search path arguments #1475

Merged
merged 13 commits into from
Jan 12, 2023

Conversation

neunenak
Copy link
Contributor

@neunenak neunenak commented Jan 4, 2023

Allow multiple search-path recipe arguments if the recipe search path is the same for all of them, and raise an error message if they have conflicting search paths.

This means that if you have a subdirectory subdir with a Justfile containing recipe_a and recipe_b, you can now invoke just as just subdir/recipe_a subdir/recipe_b, and have it correctly run recipe_a and recipe_b from that Justfile (the current behavior is that it will try to parse "subdir/recipe_b" as a recipe name in and of itself and fail).

If you try to specify multiple separate Justfiles using this syntax (e.g. just subdir1/recipe_a subdir2/recipe_b where subdir1 and subdir2 contain different Justfiles), just will fail with an error message.

Copy link
Owner

@casey casey left a comment

Choose a reason for hiding this comment

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

I think this is totally reasonable. See review for comments.

src/config_error.rs Outdated Show resolved Hide resolved
src/config_error.rs Outdated Show resolved Hide resolved
src/positional.rs Show resolved Hide resolved
src/positional.rs Outdated Show resolved Hide resolved
src/positional.rs Outdated Show resolved Hide resolved
src/positional.rs Outdated Show resolved Hide resolved
@@ -225,4 +252,35 @@ mod tests {
search_directory: None,
arguments: ["a", "a=b"],
}

test! {
Copy link
Owner

Choose a reason for hiding this comment

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

I think these would be better as integration tests. I'd also add one that tries other args, like ., ./foo, ../foo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, any reason in particular an integration test would be better? Seems to me like a unit test can exercise the new functionality here, and that it's better to use a unit test than an integration test all else being equal because unit tests are simpler to set up and modify.

Copy link
Owner

Choose a reason for hiding this comment

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

With unit tests, you have to think about whether or not the unit test captures all aspects of the feature or change. In this case, the error test doesn't check the formatting of the error message, which an integration test would. But, engaging my brain for a second, I think it's fine here.

@neunenak neunenak requested a review from casey January 5, 2023 01:02
@jpbochi
Copy link
Contributor

jpbochi commented Jan 5, 2023

@neunenak I'm not acquainted with the source code here, nor with rust, but I'm interested in this change. Would you mind writing a higher level example[s] of what this change does? 🥺

@neunenak
Copy link
Contributor Author

neunenak commented Jan 5, 2023

@neunenak I'm not acquainted with the source code here, nor with rust, but I'm interested in this change. Would you mind writing a higher level example[s] of what this change does? pleading_face

Updated the description to hopefully make the intent of this change clearer.

@jpbochi
Copy link
Contributor

jpbochi commented Jan 6, 2023

@neunenak Thanks! That makes sense to me. I really like the compromise you found.

Should you also update the README.md part about "Invoking justfiles in Other Directories"? Currently, it says that a / will only matter in the first argument. With your change, it will matter in other arguments, too.

Copy link
Owner

@casey casey left a comment

Choose a reason for hiding this comment

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

Looks good! I would:

  • Add an integration test that checks the formatting of the error message.
  • Update the readme

@@ -225,4 +252,35 @@ mod tests {
search_directory: None,
arguments: ["a", "a=b"],
}

test! {
Copy link
Owner

Choose a reason for hiding this comment

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

With unit tests, you have to think about whether or not the unit test captures all aspects of the feature or change. In this case, the error test doesn't check the formatting of the error message, which an integration test would. But, engaging my brain for a second, I think it's fine here.

neunenak and others added 9 commits January 11, 2023 10:37
Allow multiple search-path recipe arguments if the recipe search path is
the same for all of them, and raise an error message if they have
conflicting search paths.
Co-authored-by: Casey Rodarmor <casey@rodarmor.com>
Co-authored-by: Casey Rodarmor <casey@rodarmor.com>
Co-authored-by: Casey Rodarmor <casey@rodarmor.com>
Co-authored-by: Casey Rodarmor <casey@rodarmor.com>
Co-authored-by: Casey Rodarmor <casey@rodarmor.com>
@casey casey enabled auto-merge (squash) January 12, 2023 07:02
Copy link
Owner

@casey casey left a comment

Choose a reason for hiding this comment

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

Nice, reworded the readme a little, but otherwise LGTM!

@casey casey merged commit d499227 into casey:master Jan 12, 2023
@neunenak neunenak deleted the fix-multiple-positionals branch January 12, 2023 07:08
neunenak added a commit to neunenak/just that referenced this pull request Jan 25, 2023
casey pushed a commit that referenced this pull request Jan 25, 2023
- Revert #1475
- Add a test that arguments with different path  prefixes are allowed
casey pushed a commit that referenced this pull request Jan 25, 2023
- Revert #1475
- Add a test that arguments with different path  prefixes are allowed
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.

3 participants