1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Update some syslog tests to absurb the format change of FreeBSD syslog

FreeBSD

```
$ ruby -rsyslog -e 'Syslog.open("rubyspec", Syslog::LOG_PERROR) {|s| s.log(Syslog::LOG_ALERT, "Hello") }'
rubyspec 78462 - - Hello
```

Linux

```
$ ruby -rsyslog -e 'Syslog.open("rubyspec", Syslog::LOG_PERROR) {|s| s.log(Syslog::LOG_ALERT, "Hello") }'
rubyspec: Hello
```

591ef7c807
This commit is contained in:
Yusuke Endoh 2020-03-12 15:30:20 +09:00 committed by nagachika
parent 0c4d93e699
commit 17b088d1e5
3 changed files with 10 additions and 10 deletions

View file

@ -113,7 +113,7 @@ class TestSyslog < Test::Unit::TestCase
end
def syslog_line_regex(ident, message)
/(?:^| )#{Regexp.quote(ident)}(?:\[([1-9][0-9]*)\])?(?: |[: ].* )#{Regexp.quote(message)}$/
/(?:^| )#{Regexp.quote(ident)}(?:\[([1-9][0-9]*)\])?(?: | ([1-9][0-9]*) - - ||[: ].* )#{Regexp.quote(message)}$/
end
def test_log
@ -170,8 +170,9 @@ class TestSyslog < Test::Unit::TestCase
end
m = re.match(line)
assert_not_nil(m)
assert_not_nil(m[1])
assert_equal(pid, m[1].to_i)
output_pid = m[1] || m[2]
assert_not_nil(output_pid)
assert_equal(pid, output_pid.to_i)
}
}
end