Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

t/op/try.t: one test fails during deparsing tests #22495

Open
jkeenan opened this issue Aug 10, 2024 · 3 comments
Open

t/op/try.t: one test fails during deparsing tests #22495

jkeenan opened this issue Aug 10, 2024 · 3 comments

Comments

@jkeenan
Copy link
Contributor

jkeenan commented Aug 10, 2024

In #22488 (comment), @iabyn noted that t/op/try.t was no longer passing when being run through TEST -deparse.

It turns out that the code which is failing has never passed when testing deparsing. It was added this past April in b8caf0c:

commit b8caf0c1f256ef2e52bae4109552667742ab2b2a
Author:     Paul Evans <[email protected]>
AuthorDate: Fri Apr 5 17:26:32 2024 +0000
Commit:     Paul Evans <[email protected]>
CommitDate: Thu Apr 11 16:07:33 2024 +0100

    Remove experimental warnings from basic try/catch syntax
    
    try/catch/finally remains experimental because of questions around
    double-exception

...

diff --git a/t/op/try.t b/t/op/try.t
index 79ee66a171..83d5565d21 100644
--- a/t/op/try.t
+++ b/t/op/try.t
...
+# experimental warnings
+{
+    my $warnings;
+    BEGIN { $SIG{__WARN__} = sub { $warnings .= shift; }; }
+
+    my ($lfinally) = (__LINE__+5);
+    try {
+    }
+    catch ($e) {
+    }
+    finally {
+    }
+
+    is($warnings, "try/catch/finally is experimental at $0 line $lfinally.\n",
+        'compiletime warnings');
+    BEGIN { undef $SIG{__WARN__}; }
+}
+
+no warnings 'experimental::try';
+
$ git checkout b8caf0c1f25; sh ./Configure -des -Dusedevel && make test_prep; cd t; ./TEST -deparse op/try.t; cd -

------------------------------------------------------------------------------
TESTING DEPARSER
------------------------------------------------------------------------------
t/op/try ... # Failed test 23 - compiletime warnings at op/try.t line 276
#      got "try/catch/finally is experimental at op/try.t line 275.\n"
# expected "try/catch/finally is experimental at op/try.t line 273.\n"
#  diff at 53
#    after "ally is experimental at op/try.t line 27"
#     have "5.\n"
#     want "3.\n"
FAILED at test 23
Failed 1 test out of 0, 0.00% okay.
	op/try.t
...

Since I've just begun to get familiar with TEST -deparse, I don't know whether this a bug or a nit. @leonerd, could you take a look? Thanks.

@iabyn
Copy link
Contributor

iabyn commented Aug 10, 2024 via email

@jkeenan
Copy link
Contributor Author

jkeenan commented Aug 10, 2024

The trick is to run 'TEST -deparse' with the KEEP_DEPARSE_FILES=1 env var set. This will leave the file t/op/try.t.dp, the round-cycle deparsed version of t/op/try.t. That file can then be inspected to see how the new code has been deparsed, and whether it's a bug in the deparser (B/Deparse.pm) or some sort of issue with the test code. Then either fix the test, the deparser, or if it can't be easily fixed, add the test file to Porting/deparse-skips.txt

@iabyn, thanks for that explanation. Is that in the docs somewhere, or can we incorporate it therein?

@iabyn
Copy link
Contributor

iabyn commented Aug 15, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants