Merge pull request #2176 from tree-sitter/ci-ubsan
cicd: additional tests running job with enabled UBSAN + repro test for #2162
This commit is contained in:
commit
bbcf1e3746
3 changed files with 48 additions and 0 deletions
31
.github/workflows/build.yml
vendored
31
.github/workflows/build.yml
vendored
|
|
@ -169,3 +169,34 @@ jobs:
|
|||
lib/binding_web/tree-sitter.wasm
|
||||
if-no-files-found: error
|
||||
retention-days: 7
|
||||
|
||||
check_undefined_behaviour:
|
||||
name: Undefined behaviour checks
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
TREE_SITTER: ${{ github.workspace }}/target/release/tree-sitter
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install UBSAN library
|
||||
run: sudo apt-get install -y libubsan1
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Build CLI
|
||||
run: cargo build --release
|
||||
|
||||
- name: Fetch fixtures
|
||||
run: script/fetch-fixtures
|
||||
|
||||
- name: Generate fixtures
|
||||
run: script/generate-fixtures
|
||||
|
||||
- name: Run main tests with undefined behaviour sanitizer (UBSAN)
|
||||
env:
|
||||
UBSAN_OPTIONS: halt_on_error=1
|
||||
CFLAGS: -fsanitize=undefined
|
||||
RUSTFLAGS: -lubsan
|
||||
run: cargo test -- --test-threads 1
|
||||
|
|
|
|||
16
cli/src/tests/github_issue_test.rs
Normal file
16
cli/src/tests/github_issue_test.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// Tests in this mod need be executed with enabled UBSAN library:
|
||||
// ```
|
||||
// UBSAN_OPTIONS="halt_on_error=1" \
|
||||
// CFLAGS="-fsanitize=undefined" \
|
||||
// RUSTFLAGS="-lubsan" \
|
||||
// cargo test --target $(rustc -vV | sed -nr 's/^host: //p') -- --test-threads 1
|
||||
// ```
|
||||
|
||||
use crate::tests::helpers::fixtures::get_language;
|
||||
use tree_sitter::Query;
|
||||
|
||||
#[test]
|
||||
fn issue_2162_out_of_bound() {
|
||||
let language = get_language("java");
|
||||
assert!(Query::new(language, "(package_declaration _ (_) @name _)").is_ok());
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
mod corpus_test;
|
||||
mod github_issue_test;
|
||||
mod helpers;
|
||||
mod highlight_test;
|
||||
mod node_test;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue