0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ローカルで通るのにCIで落ちる?それ、ファイル名の大文字小文字かも

Posted at

問題

Spring Bootで resources/public 配下の静的ファイルを配信するテストを書いていました。

src/test/resources/public/
└── sample.mp4   ← 実際のファイル名

テストコードではこう参照:

// テストコード内
mockMvc.perform(get("/public/sample.MP4"))  // ← 大文字で参照
    .andExpect(status().isOk());

ローカル(mac):テスト通る

CI/CD(Linux):テスト落ちる

原因

macOSとLinuxでファイルシステムの仕様が違います。

OS ファイルシステム 大文字小文字
macOS APFS / HFS+ 区別しない(case-insensitive)
Linux ext4 など 区別する(case-sensitive)

つまり、macでは sample.mp4sample.MP4 は同じファイルとして扱われますが、Linuxでは別ファイル扱いになります。

公式ドキュメントにも明記されている

これはAppleの公式ドキュメント Apple File System Guide に明記されています。

APFS, like HFS+, is case-sensitive on iOS and is available in case-sensitive and case-insensitive variants on macOS, with case-insensitive being the default.

macOSでは case-insensitive(大文字小文字を区別しない)がデフォルトです。

教訓

  • macの「優しさ」に甘えない
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?