|
|
|
@ -141,15 +141,15 @@ func (t *Test) parseEval(lines []string, i int) (int, *evalCmd, error) {
|
|
|
|
|
} |
|
|
|
|
parts := patEvalInstant.FindStringSubmatch(lines[i]) |
|
|
|
|
var ( |
|
|
|
|
mod = parts[1] |
|
|
|
|
at = parts[2] |
|
|
|
|
qry = parts[3] |
|
|
|
|
mod = parts[1] |
|
|
|
|
at = parts[2] |
|
|
|
|
expr = parts[3] |
|
|
|
|
) |
|
|
|
|
expr, err := ParseExpr(qry) |
|
|
|
|
_, err := ParseExpr(expr) |
|
|
|
|
if err != nil { |
|
|
|
|
if perr, ok := err.(*ParseErr); ok { |
|
|
|
|
perr.Line = i + 1 |
|
|
|
|
perr.Pos += strings.Index(lines[i], qry) |
|
|
|
|
perr.Pos += strings.Index(lines[i], expr) |
|
|
|
|
} |
|
|
|
|
return i, nil, err |
|
|
|
|
} |
|
|
|
@ -301,7 +301,7 @@ func (cmd *loadCmd) append(a storage.Appender) error {
|
|
|
|
|
// evalCmd is a command that evaluates an expression for the given time (range)
|
|
|
|
|
// and expects a specific result.
|
|
|
|
|
type evalCmd struct { |
|
|
|
|
expr Expr |
|
|
|
|
expr string |
|
|
|
|
start, end time.Time |
|
|
|
|
interval time.Duration |
|
|
|
|
|
|
|
|
@ -321,7 +321,7 @@ func (e entry) String() string {
|
|
|
|
|
return fmt.Sprintf("%d: %s", e.pos, e.vals) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func newEvalCmd(expr Expr, start, end time.Time, interval time.Duration) *evalCmd { |
|
|
|
|
func newEvalCmd(expr string, start, end time.Time, interval time.Duration) *evalCmd { |
|
|
|
|
return &evalCmd{ |
|
|
|
|
expr: expr, |
|
|
|
|
start: start, |
|
|
|
@ -465,7 +465,8 @@ func (t *Test) exec(tc testCommand) error {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
case *evalCmd: |
|
|
|
|
q := t.queryEngine.newQuery(t.storage, cmd.expr, cmd.start, cmd.end, cmd.interval) |
|
|
|
|
qry, _ := ParseExpr(cmd.expr) |
|
|
|
|
q := t.queryEngine.newQuery(t.storage, qry, cmd.start, cmd.end, cmd.interval) |
|
|
|
|
res := q.Exec(t.context) |
|
|
|
|
if res.Err != nil { |
|
|
|
|
if cmd.fail { |
|
|
|
|