Files
codeql/shared/tree-sitter-extractor/tests/integration_test.rs
Harry Maclean 7e2abf20c6 Shared: Support glob patterns in shared extractor
Replace the `file_extensions` field with `file_globs`, which supports
UNIX style glob patterns powered by the `globset` crate.

This allows files with no extension (e.g. Dockerfiles) to be extracted,
by specifying a glob such as `*Dockerfile`.

One surprising aspect of this change is that the globs match against the
whole path, rather than just the file name.

This is a breaking change.
2023-08-23 14:11:21 +01:00

41 lines
1.1 KiB
Rust

use codeql_extractor::extractor::simple;
use codeql_extractor::trap;
use tree_sitter_ql;
mod common;
use common::{create_source_dir, expect_trap_file, SourceArchive};
/// A very simple happy-path test.
/// We run the extractor using the tree-sitter-ql grammar and a single source file,
/// and check that we get a reasonable-looking trap file in the expected location.
#[test]
fn simple_extractor() {
let language = simple::LanguageSpec {
prefix: "ql",
ts_language: tree_sitter_ql::language(),
node_types: tree_sitter_ql::NODE_TYPES,
file_globs: vec!["*.qll".into()],
};
let SourceArchive {
root_dir,
file_list,
source_archive_dir,
trap_dir,
} = create_source_dir(vec![("foo.qll", "predicate p(int a) { a = 1 }")]);
let extractor = simple::Extractor {
prefix: "ql".to_string(),
languages: vec![language],
trap_dir,
source_archive_dir,
file_list,
trap_compression: Ok(trap::Compression::Gzip),
};
extractor.run().unwrap();
expect_trap_file(&root_dir, "foo.qll");
}