-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix inconsistent trailing slash in remappings (#49)
Fix #47. One corresponding test is added. ## Fix strategy - Remove the code that blindly add trailing `/` when serializing `Remapping` and `RelativeRemapping`. - Preserve the trailing `/` in the `strip_prefix` method of `Remapping`. ## Rationale There are roughly two sources where `Remapping` comes from: - Generated in `find_many` function. - Loaded from configuration like `foundry.toml`. When generating `Remapping` in `find_many` function, the algorithm makes sure that the `name` and `path` of every remapping are valid folders in the file system. Then, trailing `/`s are added to both `name` and `path` in the `impl From<RelativeRemapping> for Remapping` implementation. https://github.com/Troublor/compilers/blob/93c5f46a7dd0c0d387dd94c8ea756812e2907d92/src/remappings.rs#L360-L365 When loading `Remapping` from user-provided configurations, the `name` and `path` of remappings should be set as it is, and do not add any trailing `/`s. Either way, the field `name` and `path` of `Remapping` contains intended values and should not be changed in the serialization (the implementation for `Display` trait). PS: About coding style, I tried to use `TempProject` to write the test case but it seems the `project.compile()` method **does not respect** the `remapping` I give it via `project.with_settings(settings_with_remapping)`. The remapping just does not take effect in the compilation. Not sure whether it's I don't know how to use it or `TempProject` has some bugs.
- Loading branch information
Showing
3 changed files
with
45 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters