Re: Should Test2 maintain $! and $@?

2016-01-18 Thread Chad Granum
So, new problem I have found based on the change to restoring $@, $!, and $?. perl-bleads ext/XS-APItest/t/svpeek.t has 2 test failures. One tests $! and it *looks like* it assumes something recently looked at $! from a string context: like (DPeek ($!), qr'^PVMG\("', '$!'); I can fix the test

Re: Should Test2 maintain $! and $@?

2016-01-18 Thread Chad Granum
Been talking about this in #p5p, so far it seems the problem is the test is fragile, and patching the test is fine. On Mon, Jan 18, 2016 at 1:13 PM, Chad Granum wrote: > So, new problem I have found based on the change to restoring $@, $!, and > $?. > > perl-bleads

Re: Should Test2 maintain $! and $@?

2016-01-17 Thread Chad Granum
I can add a complex mechanism, or someone can just do this: sub modifies_err { > my $ctx = context(); > ... > my $err = $@; > $ctx->release(); > $@ = $err; > return ...; > } It is unlikely anyone would want to have $@, $!, and $?, all at once, but just as easy to

Re: Should Test2 maintain $! and $@?

2016-01-17 Thread Chad Granum
Just realized my response may not have been clear. My response assumes that context() DOES store $!, $@ and $?. And that release() restores them. I was saying that it is easy to get around this magic in the very rare case you want to. Most cases will not have any need to work around it as it is a

Re: Should Test2 maintain $! and $@?

2016-01-17 Thread Aristotle Pagaltzis
* Chad Granum [2016-01-12 04:20]: > That said, it just occured to me that this can possibly be > accomplished by having a context store $! And $@ when it is obtained, > then restore them when it is released, which would avoid needing to > use local everywhere, and still

Re: Should Test2 maintain $! and $@?

2016-01-17 Thread Kent Fredric
On 18 January 2016 at 18:53, Chad Granum wrote: > Then again, if you /really/ want the mechanism in $ctx, I can add > $ctx->release_preserving (naming is hard, give me a better one) which does > have the behavior... but at that point, which behavior do you want, preserve >

Re: Should Test2 maintain $! and $@?

2016-01-13 Thread Chad Granum
yeah, I am really not worried about the performance on this one, just noted it for completeness. What is nagging at me is what kentnl mentioned where something nested catches an exception from something that failed to release it's context due to the exception. Not because of these vars, but

Re: Should Test2 maintain $! and $@?

2016-01-13 Thread Chad Granum
One remaining question. Should the context maintain a stack, where each time context() is called (nested) it pushes the vars to the stack, and each call to release pops it, or should it just store them on creation, do nothing on retrieval, and only restore them on the final release? Right now

Re: Should Test2 maintain $! and $@?

2016-01-13 Thread Sawyer X
[Top-posted] The extra cost would be: 1. Array storage 2. Push 3. Pop At the cost of supporting any level of nesting, I think it's a negligible cost, but I would profile it. On Wed, Jan 13, 2016 at 7:50 PM, Kent Fredric wrote: > On 14 January 2016 at 07:39, Chad Granum

Re: Should Test2 maintain $! and $@?

2016-01-13 Thread Kent Fredric
On 14 January 2016 at 07:39, Chad Granum wrote: > Right now the version I have up on cpan just stores them on creation, and > restores them on final release. Nothing happens for nested calls to > context()/release(), all my downstream testing shows no breakages (not a > full

Re: Should Test2 maintain $! and $@?

2016-01-12 Thread Michael G Schwern
On 1/11/16 4:53 PM, Chad Granum wrote: > Test::More/Test::Builder work VERY hard to ensure nothing inside them alters > $! or $@. This is for > thing like this: > > ok(do_something_scary()); > is($!, 0, "expected $! val"); > is($@, undef, '$@ not changed'); > > Without

Re: Should Test2 maintain $! and $@?

2016-01-12 Thread Sawyer X
[Top-posting] Chad, I think I understand what you mean now. You were referring to whether the underlying pinnings should take care of it (Test2) or whether the chrome (testing functions) around that should do so. Yes? If so, I think you should probably clarify what Test2 *does* do. It doesn't

Re: Should Test2 maintain $! and $@?

2016-01-12 Thread Kent Fredric
On 13 January 2016 at 10:48, Sawyer X wrote: > > If so, I think you should probably clarify what Test2 *does* do. It > doesn't provide the functions - alright. What *does* it provide then? Oh, and thought: It may help to consider what testing /testing tools/ looks like here,

Re: Should Test2 maintain $! and $@?

2016-01-12 Thread Sawyer X
On Tue, Jan 12, 2016 at 10:55 PM, Kent Fredric wrote: > On 13 January 2016 at 10:48, Sawyer X wrote: >> >> If so, I think you should probably clarify what Test2 *does* do. It >> doesn't provide the functions - alright. What *does* it provide then? > > >

Re: Should Test2 maintain $! and $@?

2016-01-12 Thread Sawyer X
[Top-posted] Chad, thank you for the detailed response. I think I now understand the scope of the problem and your solutions. I think it makes sense to put this in the guts inside the construction of a new context (or retrieval of current context) and in the release of that context. Kent, am I

Re: Should Test2 maintain $! and $@?

2016-01-11 Thread Kent Fredric
On 12 January 2016 at 13:53, Chad Granum wrote: > $! and $@ are altered by many many things, adding { local ... } around all > of them is a pain As much as I agree, and as much as this is a "thing in all perl, so we should expect this problem from every module" If I was to

Should Test2 maintain $! and $@?

2016-01-11 Thread Chad Granum
Test::More/Test::Builder work VERY hard to ensure nothing inside them alters $! or $@. This is for thing like this: ok(do_something_scary()); > is($!, 0, "expected $! val"); > is($@, undef, '$@ not changed'); Without Test::More/Builder being careful to support this, the second 2

Re: Should Test2 maintain $! and $@?

2016-01-11 Thread Ricardo Signes
* Chad Granum [2016-01-11T19:53:15] > However. It is easy enough to have Test::Builder/More protect $! and $@ > without requiring Test2 to do so. I don't have really strong feelings here, but the general reaction on p5p over the years to "some core library changes $!

Re: Should Test2 maintain $! and $@?

2016-01-11 Thread Karen Etheridge
> Test2, the dist, is just internals. It provides no tools. It does not have ok(), is(), etc. Um, so... what *is* Test2 then? (And the second question would be: and what does it have to do with Test::More?) Without context, your first question is equivalent to "should Foo::Bar maintain $! and

Re: Should Test2 maintain $! and $@?

2016-01-11 Thread Chad Granum
The magic is already there, but it is there by localizing the vars in a ton of non obvious places. Between that and having it done in one obvious and documented place seems like a Much better option. On Jan 11, 2016 7:21 PM, "Kent Fredric" wrote: > On 12 January 2016 at

Re: Should Test2 maintain $! and $@?

2016-01-11 Thread Chad Granum
Some things I forgot to mention: Test2, the dist, is just internals. It provides no tools. It does not have ok(), is(), etc. What I am talking about is not thr simple task of putting local $! In some exports. This is localizing $! Around any call to use, require, open, close, etc. Anything that

Re: Should Test2 maintain $! and $@?

2016-01-11 Thread Chad Granum
https://github.com/Test-More/Test2/issues/9 Issue created to do this the easy/efficient way. On Jan 11, 2016 7:14 PM, "Chad Granum" wrote: > Some things I forgot to mention: > > Test2, the dist, is just internals. It provides no tools. It does not have > ok(), is(), etc.

Re: Should Test2 maintain $! and $@?

2016-01-11 Thread Kent Fredric
On 12 January 2016 at 16:14, Chad Granum wrote: > That said, it just occured to me that this can possibly be accomplished by > having a context store $! And $@ when it is obtained, then restore them when > it is released, which would avoid needing to use local everywhere, and

Re: Should Test2 maintain $! and $@?

2016-01-11 Thread Chris Nandor
I agree, Kent. Shouldn't it be simple to wrap ok() and is() accordingly, to simply save-and-restore $! and $@, without going deep into anything? There's already a working example of how to do that right here. sub ok { my($err, $exception) = ($!, $@); # ... ($!, $@) = ($err, $exception);