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

test_fluentd: fix assert pattern of syntax error for Ruby HEAD #4644

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

Watson1978
Copy link
Contributor

@Watson1978 Watson1978 commented Sep 25, 2024

Which issue(s) this PR fixes:
Fixes #

Related to #4584

What this PR does / why we need it:
Ruby parser will be replaced new parser in Ruby 3.4. ruby/ruby@ea2af57

The new parser might not have a fully compatible of Syntax error messages.

So I modified the assert pattern to succeed in the Ruby HEAD.

example

module Foo
  class Bar
    def say
      puts "hello"
    end
  end

result with Ruby 3.3.5

$ ruby -v test.rb
ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [x86_64-linux]
test.rb: --> test.rb
Unmatched keyword, missing `end' ?
> 1  module Foo

test.rb:6: syntax error, unexpected end-of-input, expecting `end' or dummy end (SyntaxError)
  end
     ^

result with Ruby 3.4-dev

ruby -v test.rb
ruby 3.4.0dev (2024-09-25T02:45:33Z master 76543a34ab) +PRISM [x86_64-linux]
test.rb: --> test.rb
Unmatched keyword, missing `end' ?
> 1  module Foo

test.rb:7: syntax errors found (SyntaxError)
  5 |     end
  6 |   end
> 7 | 
    | ^ expected an `end` to close the `module` statement

    | ^ unexpected end-of-input, assuming it is closing the parent top level context

Ruby 3.3.5 has test.rb:6: syntax error,.., but Ruby 3.4-dev has test.rb:7: syntax errors....

Docs Changes:

Release Note:

Ruby parser will be replaced new parser in Ruby 3.4.
ruby/ruby@ea2af57

The new parser might not have a fully compatible of Syntax error messages.

So I modified the assert pattern to succeed in the Ruby HEAD.

### example
```ruby
module Foo
  class Bar
    def say
      puts "hello"
    end
  end
```

### result with Ruby 3.3.5
```
$ ruby -v test.rb
ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [x86_64-linux]
test.rb: --> test.rb
Unmatched keyword, missing `end' ?
> 1  module Foo

test.rb:6: syntax error, unexpected end-of-input, expecting `end' or dummy end (SyntaxError)
  end
     ^

```

### result with Ruby 3.4-dev
```ruby
ruby -v test.rb
ruby 3.4.0dev (2024-09-25T02:45:33Z master 76543a34ab) +PRISM [x86_64-linux]
test.rb: --> test.rb
Unmatched keyword, missing `end' ?
> 1  module Foo

test.rb:7: syntax errors found (SyntaxError)
  5 |     end
  6 |   end
> 7 | 
    | ^ expected an `end` to close the `module` statement

    | ^ unexpected end-of-input, assuming it is closing the parent top level context

```

Ruby 3.3.5 has `test.rb:6: syntax error,..`, but Ruby 3.4-dev has `test.rb:7: syntax errors...`.

Signed-off-by: Shizuo Fujita <[email protected]>
Copy link
Contributor

@daipom daipom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

Copy link
Contributor

@daipom daipom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm? Sorry. Dose this pattern match the current log?

@daipom
Copy link
Contributor

daipom commented Sep 25, 2024

Oh, I understand. It matches both of the current and Ruby HEAD. Thanks.

@daipom daipom added this to the v1.18.0 milestone Sep 26, 2024
@daipom daipom merged commit 7e39526 into fluent:master Sep 26, 2024
15 of 16 checks passed
@Watson1978 Watson1978 deleted the fix-syntax-error-pattern branch September 26, 2024 01:30
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

Successfully merging this pull request may close these issues.

2 participants