From 262d272f2959142ef0c5f77b21bea502d749a001 Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Wed, 24 Jul 2019 03:00:52 -0400 Subject: [PATCH] t/103-unicode: workaround unicode normalization on newer macOS. As named, the file would be extracted by git on macOS, then (un)helpfully normalized by the macOS filesystem. After that, "git clean -fdx" would delete the file, since it no longer had the expected name, so git thought it wasn't part of its repo. I considered pre-normalizing the filename, but a) that would break on any future OS that normalizes differently; and b) that means we won't test denormalized filenames. Instead, we'll remove the directory from git, and create it from sh instead, then figure out what name it got really created as, and then pass the "real" name to redo. --- t/103-unicode/clean.do | 1 + .../test1.do" | 0 t/103-unicode/unicode.do | 16 +++++++++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 t/103-unicode/clean.do delete mode 100644 "t/103-unicode/test-unic\314\247\303\270\303\260e\314\210/test1.do" diff --git a/t/103-unicode/clean.do b/t/103-unicode/clean.do new file mode 100644 index 0000000..25762fa --- /dev/null +++ b/t/103-unicode/clean.do @@ -0,0 +1 @@ +rm -rf *.tmp diff --git "a/t/103-unicode/test-unic\314\247\303\270\303\260e\314\210/test1.do" "b/t/103-unicode/test-unic\314\247\303\270\303\260e\314\210/test1.do" deleted file mode 100644 index e69de29..0000000 diff --git a/t/103-unicode/unicode.do b/t/103-unicode/unicode.do index 309ed02..9297114 100644 --- a/t/103-unicode/unicode.do +++ b/t/103-unicode/unicode.do @@ -1,2 +1,16 @@ # Test that redo can handle a script whose path contains non-ASCII characters. -redo test-uniçøðë/test1 +# Note: the test directory is intentionally *not* a normalized unicode +# string, ie. filesystems like macOS will convert it to a different string +# at creation time. This tests weird normalization edge cases. +# +# Unfortunately, on macOS with APFS, it may helpfully normalize the path at +# *create* time, but not on future *open* attempts. Thus, we let the shell +# figure out what directory name actually got created, then pass that to redo. +# Hence the weird wildcard expansion loop. +rm -rf test-uni*.tmp +mkdir "test-uniçøðë.tmp" +for p in test-uni*.tmp; do + : >$p/test1.do + redo "$p/test1" +done +