Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix matching on $ (fixes #9) #31

Merged
merged 3 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Here's an overview of all FileCheck features and their implementation status.
- [X] `--allow-empty`
- [ ] `--color` Colored output is supported and automatically detected. No support for the flag.
- **Base Features:**
- [X] Regex patterns (Bugs: [#7](https://github.com/AntonLydike/filecheck/issues/7), [#9](https://github.com/AntonLydike/filecheck/issues/9))
- [X] Regex patterns
- [X] Captures and Capture Matches (Bug: [#11](https://github.com/AntonLydike/filecheck/issues/11))
- [X] Numeric Captures
- [ ] Numeric Substitutions (jesus christ, wtf man) (Tracked: [#21](https://github.com/AntonLydike/filecheck/issues/21))
Expand Down
3 changes: 2 additions & 1 deletion filecheck/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def compile_uops(
# we don't do numerical substitutions yet
raise NotImplementedError("Numerical substitutions not supported!")
try:
return re.compile("".join(expr)), captures
# compile with MULTILINE flag, so that `^` and `$` can match start/end of line correctly
return re.compile("".join(expr), flags=re.MULTILINE), captures
except re.error:
raise CheckError(f"Malformed regex expression: '{''.join(expr)}'", check)
30 changes: 20 additions & 10 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions tests/filecheck/regex.test
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ test 123, 123

test a b
// CHECK: test {{a|b}} {{b|c}}

test something
// CHECK: test something {{$}}

test another thing
// CHECK-NOT: test another{{$}}
Loading