Skip to content

Commit 21c27ed

Browse files
committed
fix: exit test gracefully on case insensitive file system
1 parent d6b6148 commit 21c27ed

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/builtin_hooks.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ use crate::common::{TestContext, cmd_snapshot};
77

88
mod common;
99

10+
fn is_case_sensitive_filesystem(context: &TestContext) -> Result<bool> {
11+
let test_lower = context.work_dir().child("case_test_file.txt");
12+
test_lower.write_str("test")?;
13+
let test_upper = context.work_dir().child("CASE_TEST_FILE.txt");
14+
let is_sensitive = !test_upper.exists();
15+
fs_err::remove_file(test_lower.path())?;
16+
Ok(is_sensitive)
17+
}
18+
1019
#[test]
1120
fn end_of_file_fixer_hook() -> Result<()> {
1221
let context = TestContext::new();
@@ -765,6 +774,11 @@ fn check_case_conflict_hook() -> Result<()> {
765774
context.init_project();
766775
context.configure_git_author();
767776

777+
if !is_case_sensitive_filesystem(&context)? {
778+
eprintln!("Skipping test on case-insensitive filesystem");
779+
return Ok(());
780+
}
781+
768782
// Create initial files and commit
769783
let cwd = context.work_dir();
770784
cwd.child("README.md").write_str("Initial commit")?;
@@ -824,6 +838,11 @@ fn check_case_conflict_directory() -> Result<()> {
824838
context.init_project();
825839
context.configure_git_author();
826840

841+
if !is_case_sensitive_filesystem(&context)? {
842+
eprintln!("Skipping test on case-insensitive filesystem");
843+
return Ok(());
844+
}
845+
827846
// Create directory with file
828847
let cwd = context.work_dir();
829848
cwd.child("src/utils/helper.py").write_str("helper")?;
@@ -864,6 +883,11 @@ fn check_case_conflict_among_new_files() -> Result<()> {
864883
context.init_project();
865884
context.configure_git_author();
866885

886+
if !is_case_sensitive_filesystem(&context)? {
887+
eprintln!("Skipping test on case-insensitive filesystem");
888+
return Ok(());
889+
}
890+
867891
let cwd = context.work_dir();
868892
cwd.child("README.md").write_str("Initial")?;
869893
context.git_add(".");

0 commit comments

Comments
 (0)