Skip to content

テスト用 write_file() ヘルパーが5ファイルに重複している #87

Description

@TwoSquirrels

症状

同一内容のテストヘルパー

fn write_file(root: &Path, relative: &str, content: &str) {
    let path = root.join(relative);
    fs::create_dir_all(path.parent().unwrap()).unwrap();
    fs::write(path, content).unwrap();
}

(または &[u8] 版) が src/library/hash.rssrc/library/dummy.rssrc/library/identifiers.rssrc/fs/walk.rssrc/fs/source.rs の5ファイルにそれぞれ個別定義されている。

ファイル配置規則やエラーハンドリングを変えたいとき (例: 書き込み失敗時のメッセージ改善)、5箇所を同時に直す必要があり、1つ直し忘れると挙動が食い違う。

対処案

library/testutil.rs (または新設する fs 用テストユーティリティ) へ集約し、各テストモジュールから呼ぶ。

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    Kind/TestingIssue or pull request related to testingModule: FilesystemFilesystem traversal utilitiesModule: LibraryThe library registration domainPriority/MediumThe priority is medium

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions