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:
Andrew Hlynskyi 2023-04-06 04:57:25 +03:00 committed by GitHub
commit bbcf1e3746
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 0 deletions

View file

@ -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

View 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());
}

View file

@ -1,4 +1,5 @@
mod corpus_test;
mod github_issue_test;
mod helpers;
mod highlight_test;
mod node_test;