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

Refactor directory paths #39

Merged
merged 14 commits into from
Jan 24, 2022
Merged

Refactor directory paths #39

merged 14 commits into from
Jan 24, 2022

Conversation

oltrep
Copy link
Contributor

@oltrep oltrep commented Jan 21, 2022

I refactored how the paths for the different files and directories are obtained, so that it's possible to specify the root from an environment variable. This made it simple to write to integration tests on the CLI that snapshots the content of file generated by foreman.

I don't want to go too deep in the test cases for this PR, but this sets up the pattern.

Closes #17

@github-actions
Copy link

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

Comment on lines +7 to +8
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { inner: ErrorInner { kind: Custom, line: None, col: 0, at: None, message: "missing field `tools`", key: [] } }', src/config.rs:97:69
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A note on this test (and tests/snapshots/install_invalid_tool_configuration.snap): I've let these in even if they're not great just to document the current behavior. I have some changes locally that I'll put up once this merges that refactor the error handling to get better output.

Copy link
Contributor

@ZoteTheMighty ZoteTheMighty 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, just had one comment on error messaging. Could be addressed in your followup if you like

.args(args)
.status()
.map_err(|e| {
format!(
"an error happened trying to run `{}` at `{}`: {}",
Copy link
Contributor

Choose a reason for hiding this comment

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

When does this error occur? If there's any chance it could happen for end users, we should make sure the error is very clear about it being foreman's problem, so they don't chase ghosts in whatever tool they were trying to use

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes you're right, I'll precise that in the message!

@oltrep oltrep merged commit 9e2384d into master Jan 24, 2022
@oltrep oltrep deleted the directory-paths branch January 24, 2022 19:19
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FOREMAN_HOME environment variable
2 participants