chore: get rid of github_issue_test file

This commit is contained in:
Amaan Qureshi 2024-02-21 03:33:29 -05:00
parent bf8e3bbc89
commit 58a4fcc792
3 changed files with 32 additions and 43 deletions

View file

@ -1,42 +0,0 @@
// 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 super::helpers::query_helpers::assert_query_matches;
use crate::tests::helpers::fixtures::get_language;
use indoc::indoc;
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());
}
#[test]
fn issue_2107_first_child_group_anchor_had_no_effect() {
let language = get_language("c");
let source_code = indoc! {r"
void fun(int a, char b, int c) { };
"};
let query = indoc! {r#"
(parameter_list
.
(
(parameter_declaration) @constant
(#match? @constant "^int")
)
)
"#};
let query = Query::new(&language, query).unwrap();
assert_query_matches(
&language,
&query,
source_code,
&[(0, vec![("constant", "int a")])],
);
}

View file

@ -1,7 +1,6 @@
mod async_context_test;
mod corpus_test;
mod detect_language;
mod github_issue_test;
mod helpers;
mod highlight_test;
mod language_test;

View file

@ -5072,3 +5072,35 @@ fn test_grammar_with_aliased_literal_query() {
assert!(query.is_ok());
}
#[test]
fn test_query_with_first_child_in_group_is_anchor() {
let language = get_language("c");
let source_code = r"void fun(int a, char b, int c) { };";
let query = r#"
(parameter_list
.
((parameter_declaration) @constant
(#match? @constant "^int")))"#;
let query = Query::new(&language, query).unwrap();
assert_query_matches(
&language,
&query,
source_code,
&[(0, vec![("constant", "int a")])],
);
}
// This test needs be executed with UBSAN enabled to check for regressions:
// ```
// UBSAN_OPTIONS="halt_on_error=1" \
// CFLAGS="-fsanitize=undefined" \
// RUSTFLAGS="-lubsan" \
// cargo test --target $(rustc -vV | sed -nr 's/^host: //p') -- --test-threads 1
// ```
#[test]
fn test_query_compiler_oob_access() {
let language = get_language("java");
// UBSAN should not report any OOB access
assert!(Query::new(&language, "(package_declaration _ (_) @name _)").is_ok());
}