From fef4c0ff98492e54eab07c49514283128abd9e24 Mon Sep 17 00:00:00 2001 From: Chris Darroch Date: Wed, 10 Jan 2024 20:29:43 -0800 Subject: [PATCH] t: pipe data to base64 to be compatible with macOS The base64(1) binary provided with macOS does not accept a bare input file name, unlike any of the GNU coreutils implementations of base64(1) or either the older Fourmilab or newer bintrans(1) BSD implementations. Instead, it appears to be a version unique to OS X which requires an -i option before a file name to be used for input. See, for reference: https://www.unix.com/man-page/osx/1/base64/ https://man7.org/linux/man-pages/man1/base64.1.html https://www.fourmilab.ch/webtools/base64/ https://man.freebsd.org/cgi/man.cgi?query=base64&manpath=FreeBSD+15.0-CURRENT With the Xcode developer tools for macOS installed, along with Go, Git, etc., our test suite mostly succeeds, but several tests fail because they expect to call base64(1) and pass the bare /dev/urandom file name. We can resolve this inconvenience for developers by adjusting those tests to use the technique we already use in the t/t-migrate-*.sh test suites where we redirect /dev/urandom into base64 as its standard input. This allows the test suites to function on both macOS as well as Linux systems which use one of the other base64(1) implementations. --- t/t-clean.sh | 4 ++-- t/t-fsck.sh | 2 +- t/t-malformed-pointers.sh | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/t/t-clean.sh b/t/t-clean.sh index 806778e6ed..2e34f2bd39 100755 --- a/t/t-clean.sh +++ b/t/t-clean.sh @@ -67,8 +67,8 @@ begin_test "clean stdin" git init "$reponame" cd "$reponame" - base64 /dev/urandom | head -c 1024 > small.dat - base64 /dev/urandom | head -c 2048 > large.dat + base64 < /dev/urandom | head -c 1024 > small.dat + base64 < /dev/urandom | head -c 2048 > large.dat expected_small="$(calc_oid_file "small.dat")" expected_large="$(calc_oid_file "large.dat")" diff --git a/t/t-fsck.sh b/t/t-fsck.sh index 24278da439..1e594d32ac 100755 --- a/t/t-fsck.sh +++ b/t/t-fsck.sh @@ -142,7 +142,7 @@ create_invalid_pointers() { ext="${2:-dat}" git cat-file blob ":$valid" | awk '{ sub(/$/, "\r"); print }' >"crlf.$ext" - base64 /dev/urandom | head -c 1025 >"large.$ext" + base64 < /dev/urandom | head -c 1025 >"large.$ext" git \ -c "filter.lfs.process=" \ -c "filter.lfs.clean=cat" \ diff --git a/t/t-malformed-pointers.sh b/t/t-malformed-pointers.sh index fe80e25a6b..c40e38288d 100755 --- a/t/t-malformed-pointers.sh +++ b/t/t-malformed-pointers.sh @@ -14,10 +14,10 @@ begin_test "malformed pointers" git add .gitattributes git commit -m "initial commit" - base64 /dev/urandom | head -c 1023 > malformed_small.dat - base64 /dev/urandom | head -c 1024 > malformed_exact.dat - base64 /dev/urandom | head -c 1025 > malformed_large.dat - base64 /dev/urandom | head -c 1048576 > malformed_xxl.dat + base64 < /dev/urandom | head -c 1023 > malformed_small.dat + base64 < /dev/urandom | head -c 1024 > malformed_exact.dat + base64 < /dev/urandom | head -c 1025 > malformed_large.dat + base64 < /dev/urandom | head -c 1048576 > malformed_xxl.dat git \ -c "filter.lfs.process=" \