Commit a1b5c985 authored by Xavier Thompson's avatar Xavier Thompson Committed by Kirill Smelkov

amari.xlog: Fix parsing of logspec options

Fix off-by-one error in `amari.xlog.LogSpec.parse` which truncated the last
character of options, e.g. `stats[rf]/60s` would parse option `r` instead of `rf`.

/reviewed-by @kirr
/reviewed-on !1
parent 58b17ada
...@@ -108,7 +108,7 @@ class LogSpec: ...@@ -108,7 +108,7 @@ class LogSpec:
_ = tail.find(']') _ = tail.find(']')
if _ == -1: if _ == -1:
bad("missing closing ]") bad("missing closing ]")
optv = tail[1:_-1].split(',') optv = tail[1:_].split(',')
tail = tail[_+1:] tail = tail[_+1:]
for c in '[]/ ': for c in '[]/ ':
......
...@@ -78,3 +78,12 @@ zzzqqqrrrr ...@@ -78,3 +78,12 @@ zzzqqqrrrr
# EOF # EOF
_ = xr.read() _ = xr.read()
assert _ is None assert _ is None
def test_LogSpec():
logspec = "stats[samples,rf]/60s"
spec = xlog.LogSpec.parse(logspec)
assert spec.query == "stats"
assert spec.optv == ["samples", "rf"]
assert spec.period == 60.0
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment