Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: ERR_RETURN ignored in 'if' in a source'd file [FIXED]
- X-seq: zsh-users 30262
- From: "Daniel Shahaf" <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: ERR_RETURN ignored in 'if' in a source'd file [FIXED]
- Date: Fri, 16 May 2025 10:45:46 +0000
- Archived-at: <https://zsh.org/users/30262>
- Feedback-id: i425e4195:Fastmail
- In-reply-to: <CAH+w=7b=Eam8A=KoyqHg+PbkdGu=ZaoA_8Qh8W=-37AJ85UDNQ@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <sympa.1746612880.448786.2610.427@zsh.org> <9c8f7a4d-dda6-4900-a535-4088c723800b@app.fastmail.com> <CAH+w=7b=Eam8A=KoyqHg+PbkdGu=ZaoA_8Qh8W=-37AJ85UDNQ@mail.gmail.com>
Bart Schaefer wrote on Wed, 14 May 2025 17:14 +00:00:
> On Wed, May 14, 2025 at 9:53 AM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
>>
>> The test runs inside a «$ZTST_testdir/../Src/zsh -f» because, otherwise,
>> the ERR_RETURN would cause early returns not only in the test case's
>> code, but also in the test harness code executing the test code¹. (Yes,
>> it's rather odd that it's possible for code being tested to affect the
>> test harness' control flow this way.)
>
> Is a full new shell needed for this specific instance, or would a
> subshell suffice?
A subshell would indeed suffice, since that would make ERR_RETURN not be
in effect by the time the anonymous function in ZTST_execchunk() returns.
Shall I make the change? (I haven't yet verified that the test fails on 5.9
when changed to use a subshell; only that it passes on current master
with that change.)
> Maybe it's possible to add a flag (like the xfail flag) to the test
> definition to say "put this in it's own shell"? That would make it
> easier than having to explicitly reference $ZTST_testdir etc. (There
> are a few exceptions that would still require that reference, I
> think.)
It's definitely possible: the flags are available in a local variable
in ZTST_execchunk()'s caller.
I think allowing test chunks to be run independently of the harness
would be a step in the right direction.
How about reversing the sense of the flag, so test chunks would run
isolated from the harness by default, unless they opt-in to the current
"don't subshell me, but eval me" behaviour?
On the one hand, on the day we flip the default we'll have to go through
all tests that expect the current behaviour and add the flag to them.
On the other hand, all existing and future tests would be isolated from
the harness, and from each other, by default.
Tests might rely on the current behaviour in at least two different
ways:
- By depending on each other; e.g., Test/B01cd.ztst:21 documents that
«setopt»s carry over from one test chunk to another.
- By depending on the harness' state; e.g., a test that does «echo
${#funcstack}» would get a value that includes the harness' part of
the callstack.
Cheers,
Daniel
(who suspects the thread should continue on -workers@)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author