Skip to content

Commit

Permalink
Enable multiline matching for runtime test regex
Browse files Browse the repository at this point in the history
Currently the output is treated as one line with newline characters in
it, which breaks the typical use of the `^` and `$` character. E.g.

```
RUN bpftrace -e 'i:ms:1 { printf("%d\n", 1); exit(); }'
EXPECT ^[0-9]$
```

Will not work as the output contains "attaching 1 probe"

A test like:

```
RUN bpftrace -e 'i:ms:1 { printf("fff\n"); exit(); }'
EXPECT [0-9]
```

Doesn't fail, due to the probe count output.

With the `multiline` option set each the `^` and `$` will also match the
beginning and end of each line. Making the expect behave more like
expected.
  • Loading branch information
fbs committed May 20, 2019
1 parent 543513e commit c8763e4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/utils.py
Expand Up @@ -115,7 +115,7 @@ def run_test(test):
output += p.communicate()[0].decode()

signal.alarm(0)
result = re.search(test.expect, output)
result = re.search(test.expect, output, re.M)

except (TimeoutError):
# Give it a last chance, the test might have worked but the
Expand Down

0 comments on commit c8763e4

Please sign in to comment.