Hi, I am repeatedly encountering an annoying failing test during 'make check-world' execution on the macOS platform: pg_resetwal with the result:
Failed test 'check PGDATA permissions' It happens because a filesystem object .DS_Store exists in the directory. AFAIK, MacOS manages it on its own. Given that I almost never touch this module, it seems the OS handles it automatically. A quick dive into the mailing list history shows that this problem has been discovered [1] and partly fixed [2] before. It looks like this approach might be extended to TAP tests too. In the attachment, see the sketch of the code and a minor test to prove that it works. [1] pg_basebackup: errors on macOS on directories with ".DS_Store" files https://www.postgresql.org/message-id/flat/E258CE50-AB0E-455D-8AAD-BB4FE8F882FB%40gmail.com [2] Commit d3fdfdcd1c7 'Skip .DS_Store files in server side utils' -- regards, Andrei Lepikhov, pgEdge
From d12271efd27b9e8c850cdfdd6811d2d220bcb304 Mon Sep 17 00:00:00 2001 From: "Andrei V. Lepikhov" <[email protected]> Date: Tue, 28 Jul 2026 10:35:48 +0200 Subject: [PATCH v0] Skip .DS_Store files in check_mode_recursive The macOS Finder application creates .DS_Store files in directories when opened. These files do not carry PostgreSQL's permissions, so a data directory that happens to contain one makes check_mode_recursive() report a spurious failure. This may break the "check PGDATA permissions" tests in initdb, pg_resetwal, pg_rewind, pg_ctl, pg_basebackup and pg_receivewal on macOS development trees. Commit d3fdfdcd1c7 taught the server-side utilities (pg_basebackup, pg_checksums and pg_rewind) to skip .DS_Store files. Apply the same treatment to the shared TAP test helper so the test suite is equally tolerant of them. A regression test is added to the initdb TAP suite, guarded to run only on non-macOS systems since creating bogus .DS_Store files where the Finder can see them may have unintended side effects, matching the convention established by that commit. --- src/bin/initdb/t/001_initdb.pl | 11 +++++++++++ src/test/perl/PostgreSQL/Test/Utils.pm | 9 ++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/bin/initdb/t/001_initdb.pl b/src/bin/initdb/t/001_initdb.pl index 081535a22e4..45ba73dd58f 100644 --- a/src/bin/initdb/t/001_initdb.pl +++ b/src/bin/initdb/t/001_initdb.pl @@ -64,6 +64,17 @@ mkdir $datadir; skip "unix-style permissions not supported on Windows", 1 if ($windows_os); + # A .DS_Store file created by the macOS Finder has permissions that + # do not conform to the expected data directory mode. Make sure the + # permission check ignores it. Only create it on non-macOS systems, + # since writing bogus .DS_Store files where the Finder might see them + # could have unintended side effects. + if ($Config::Config{osname} ne 'darwin') + { + append_to_file("$datadir/.DS_Store", "macOS system file"); + chmod(0644, "$datadir/.DS_Store"); + } + ok(check_mode_recursive($datadir, 0700, 0600), "check PGDATA permissions"); } diff --git a/src/test/perl/PostgreSQL/Test/Utils.pm b/src/test/perl/PostgreSQL/Test/Utils.pm index d3e6abf7a68..f140b4bd976 100644 --- a/src/test/perl/PostgreSQL/Test/Utils.pm +++ b/src/test/perl/PostgreSQL/Test/Utils.pm @@ -669,7 +669,8 @@ sub read_head_tail =item check_mode_recursive(dir, expected_dir_mode, expected_file_mode, ignore_list) Check that all file/dir modes in a directory match the expected values, -ignoring files in C<ignore_list> (basename only). +ignoring files in C<ignore_list> (basename only). Files created by the +macOS Finder (F<.DS_Store>) are always ignored. =cut @@ -684,6 +685,12 @@ sub check_mode_recursive { follow_fast => 1, wanted => sub { + # Skip macOS system files. The Finder application creates + # .DS_Store files, which are not PostgreSQL files and would + # otherwise trip the permission check below; always ignore + # them. + return if basename($File::Find::name) eq '.DS_Store'; + # Is file in the ignore list? foreach my $ignore ($ignore_list ? @{$ignore_list} : []) { -- 2.55.0
