Skip to content

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

Merged
daipom merged 1 commit into
fluent:masterfrom
Watson1978:fix-syntax-error-pattern
Sep 26, 2024
Merged

test_fluentd: fix assert pattern of syntax error for Ruby HEAD#4644
daipom merged 1 commit into
fluent:masterfrom
Watson1978:fix-syntax-error-pattern

Conversation

@Watson1978

@Watson1978 Watson1978 commented Sep 25, 2024

Copy link
Copy Markdown
Contributor

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 <fujita@clear-code.com>

@daipom daipom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Thanks!

@daipom daipom left a comment

Copy link
Copy Markdown
Contributor

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

daipom commented Sep 25, 2024

Copy link
Copy Markdown
Contributor

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
@Watson1978
Watson1978 deleted the fix-syntax-error-pattern branch September 26, 2024 01:30
@Watson1978 Watson1978 mentioned this pull request Dec 8, 2025
@Watson1978 Watson1978 added the backport to v1.16 We will backport this fix to the LTS branch label Dec 8, 2025
Watson1978 added a commit that referenced this pull request Dec 9, 2025
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 <fujita@clear-code.com>
@Watson1978 Watson1978 added CI Test/CI issues backported "backport to LTS" is done labels Dec 9, 2025
daipom pushed a commit that referenced this pull request Dec 9, 2025
… Ruby HEAD (#4644) (#5187)

Backport #4644

**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
```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...`.

**Docs Changes**:

**Release Note**:

Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport to v1.16 We will backport this fix to the LTS branch backported "backport to LTS" is done CI Test/CI issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants