Skip to content

Commit

Permalink
Merge pull request #347 from moonbitlang/force-use-dunce-canonicalize
Browse files Browse the repository at this point in the history
internal: force use dunce canonicalize
  • Loading branch information
lijunchen authored Sep 26, 2024
2 parents b214601 + 0bbc677 commit ab6f59e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ install:
cargo install --path ./crates/moon --debug --offline --root ~/.moon --force --locked

clippy:
cargo clippy --all-targets --all-features -- -D warnings
cargo clippy --all-targets --all-features --locked -- -D warnings

add-header:
hawkeye format
Expand Down
21 changes: 21 additions & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# moon: The build system and package manager for MoonBit.
# Copyright (C) 2024 International Digital Economy Academy
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# For inquiries, you can contact us via e-mail at jichuruanjian@idea.edu.cn.

disallowed-methods = [
{ path = "std::path::Path::canonicalize", reason = "Please use dunce::canonicalize" },
]
2 changes: 1 addition & 1 deletion crates/moon/tests/test_cases/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2391,7 +2391,7 @@ fn test_mbti() {
#[test]
fn test_dummy_core() {
let test_dir = TestDir::new("dummy-core.in");
let dir = test_dir.as_ref().canonicalize().unwrap();
let dir = dunce::canonicalize(test_dir.as_ref()).unwrap();

snapbox::cmd::Command::new(moon_bin())
.current_dir(&dir)
Expand Down
9 changes: 3 additions & 6 deletions crates/moonbuild/src/expect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ pub struct ExpectFailedRaw {

pub fn expect_failed_to_snapshot_result(efr: ExpectFailedRaw) -> SnapshotResult {
let filename = parse_filename(&efr.loc).unwrap();
let expect_file = PathBuf::from(&filename)
.canonicalize()
let expect_file = dunce::canonicalize(PathBuf::from(&filename))
.unwrap()
.parent()
.unwrap()
Expand Down Expand Up @@ -589,8 +588,7 @@ pub fn apply_snapshot(messages: &[String]) -> anyhow::Result<()> {
let filename = parse_filename(&snapshot.loc)?;
let actual = snapshot.actual.clone();
let expect_file = &snapshot.expect_file;
let expect_file = PathBuf::from(&filename)
.canonicalize()
let expect_file = dunce::canonicalize(PathBuf::from(&filename))
.unwrap()
.parent()
.unwrap()
Expand Down Expand Up @@ -698,8 +696,7 @@ pub fn render_snapshot_fail(msg: &str) -> anyhow::Result<(bool, String, String)>
let loc = parse_loc(&snapshot.loc)?;
let actual = snapshot.actual.clone();
let expect_file = &snapshot.expect_file;
let expect_file = PathBuf::from(&filename)
.canonicalize()
let expect_file = dunce::canonicalize(PathBuf::from(&filename))
.unwrap()
.parent()
.unwrap()
Expand Down

0 comments on commit ab6f59e

Please sign in to comment.