Closed Tux closed 1 year ago
Good catch!
More simply, this passes on prove and fails on yath
$>cat t/test.t
#!/usr/bin/perl
use Test::More;
is ($., undef, '$. starts out undefined');
done_testing;
I can confirm this is happening. I cannot figure out how it is happening.
When yath preloads+forks it uses goto::file to switch execution over to the test file.
https://metacpan.org/dist/goto-file/source/lib/goto/file.pm#L59
If I add a debug statement to that line to print $.
, it is set to undef the first call, and then it is 0 by the next call and all following calls.
If I set $. to a Scope::Guard it says it is destroyed by scripts/yath line 260, which is the end of the BEGIN block, a BEGIN block that has local $.
at the very top.
I am reaching the end of my ability to debug this, and no workaround of manually setting $. = undef at ANY pount fixes this.
ah, well it looks like setting $. = undef
results in $. being 0. So that explains why I cannot reset it. But I am also at a loss as to what is setting it.
I created a .t file:
BEGIN { $. = undef }
$. = undef;
my $val = $.;
print STDERR "|$.|$val|\n";
When run via yath I get this output:
( LAUNCH ) job 1 xxx.t
( STDERR ) job 1 |0|0|
( FAILED ) job 1 xxx.t
( TIME ) job 1 Total: 0.02369s
< REASON > job 1 No plan was declared, and no assertions were made.
So it seems once $. is set to 0, even the test file cannot change it back. And apparently wrapping EVERYTHING that is done with a local $.
can also not protect it.
ok, found it by chance, and part of the problem is that goto::file::filter was being monkeypatched. I will have a fix shortly.
When running a
.t
file withyath
,$.
is set (to0
) where it should still beundef