Skip to content

Commit

Permalink
ci: use miri to test the parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Jan 15, 2024
1 parent 21909fa commit 7a89315
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/miri.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ jobs:

- name: Install Miri
run: |
rustup component add miri
rustup toolchain install nightly --component miri
rustup override set nightly
cargo miri setup
- name: Test with Miri
run: MIRIFLAGS="-Zmiri-disable-isolation" cargo miri test
run: cargo miri test -p oxc_parser -p oxc_ast -p oxc_allocator -p oxc_semantic
11 changes: 11 additions & 0 deletions crates/oxc_parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,17 @@ mod test {
}
}

#[test]
fn memory_leak() {
let allocator = Allocator::default();
let source_type = SourceType::default();
let sources = ["2n", ";'1234567890123456789012345678901234567890'"];
for source in sources {
let ret = Parser::new(&allocator, source, source_type).parse();
assert!(!ret.program.body.is_empty());
}
}

// Source with length u32::MAX + 1 fails to parse
#[test]
fn overlong_source() {
Expand Down

0 comments on commit 7a89315

Please sign in to comment.