Re: Replace (stat(<file>))[7] in TAP tests with -s

From: Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>
To: "Drouvot, Bertrand" <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Michael Paquier <michael(at)paquier(dot)xyz>
Subject: Re: Replace (stat(<file>))[7] in TAP tests with -s
Date: 2023-10-02 11:44:59
Message-ID: 87o7hhnt8k.fsf@wibble.ilmari.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Drouvot, Bertrand" <bertranddrouvot(dot)pg(at)gmail(dot)com> writes:

> Hi hackers,
>
> Please find attached a tiny patch to $SUBJECT.
>
> It:
>
> - provides more consistency to the way we get files size in TAP tests
> - seems more elegant that relying on a hardcoded result position

I approve of removing use of the list form of stat, it's a horrible API.

If we weren't already using -s everywhere else, I would prefer
File::stat, which makes stat (in scalar context) return an object with
methods for the fields, so you'd do stat($file)->size. It's included in
Perl core since 5.4, and we're already using it in several places for
other fields (mode and ino at least).

I see another use of stat array positions (for mtime) in
src/tools/msvc/Solution.pm, but that's on the chopping block, so not
much point in fixing.

- ilmari

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2023-10-02 12:37:31 Re: Remove ParallelReadyList and worker_spi_state from typedefs.list
Previous Message Hayato Kuroda (Fujitsu) 2023-10-02 10:59:06 RE: Synchronizing slots from primary to standby