Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Added [Facet](https://facet.rs/) support to `UpdateEvent`

## [4.0.1] - 2025-10-09

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ toml = "0.5"
tikv-jemallocator = "0.5"

[dev-dependencies]
assert_cmd = "2.0.12"
assert_cmd = "2.1"
insta = { version = "1.34.0", features = ["filters"] }
insta-cmd = "0.5"
serial_test = "2"
Expand Down
55 changes: 42 additions & 13 deletions cli/tests/cli.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use assert_cmd::prelude::*;
use assert_cmd::cargo;
use insta::Settings;
use insta_cmd::assert_cmd_snapshot;
use insta::assert_snapshot;
use serial_test::serial;
use std::{path::Path, process::Command};
use std::path::Path;

fn standard_filter() -> Settings {
let mut settings = insta::Settings::clone_current();
Expand All @@ -19,10 +19,29 @@ fn standard_filter() -> Settings {
settings
}

fn mimic_insta_snapshot(
output: std::process::Output,
) -> Result<String, Box<dyn std::error::Error>> {
let success = output.status.success();
let exit_code = output.status.code().unwrap();
let stdout = str::from_utf8(&output.stdout)?;
let stderr = str::from_utf8(&output.stderr)?;
Ok(format!(
r#"
success: {success}
exit_code: {exit_code}
----- stdout -----
{stdout}
----- stderr -----
{stderr}
"#
))
}

#[test]
#[serial]
fn show_corpus_info() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin("annis")?;
let mut cmd = cargo::cargo_bin_cmd!("annis");

cmd.arg("../graphannis/tests/data/")
.arg("-c")
Expand All @@ -32,29 +51,33 @@ fn show_corpus_info() -> Result<(), Box<dyn std::error::Error>> {
.arg("-c")
.arg("info");

let output = cmd.output().unwrap();
let actual = mimic_insta_snapshot(output)?;
let settings = standard_filter();
settings.bind(|| assert_cmd_snapshot!(cmd));
settings.bind(|| assert_snapshot!(actual));

Ok(())
}

#[test]
#[serial]
fn list_corpora_not_loaded() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin("annis")?;
let mut cmd = cargo::cargo_bin_cmd!("annis");

cmd.arg("../graphannis/tests/data/").arg("-c").arg("list");

let output = cmd.output().unwrap();
let actual = mimic_insta_snapshot(output)?;
let settings = standard_filter();
settings.bind(|| assert_cmd_snapshot!(cmd));
settings.bind(|| assert_snapshot!(actual));

Ok(())
}

#[test]
#[serial]
fn list_corpora_fully_loaded() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin("annis")?;
let mut cmd = cargo::cargo_bin_cmd!("annis");

cmd.arg("../graphannis/tests/data/")
.arg("-c")
Expand All @@ -64,16 +87,18 @@ fn list_corpora_fully_loaded() -> Result<(), Box<dyn std::error::Error>> {
.arg("-c")
.arg("list");

let output = cmd.output().unwrap();
let actual = mimic_insta_snapshot(output)?;
let settings = standard_filter();
settings.bind(|| assert_cmd_snapshot!(cmd));
settings.bind(|| assert_snapshot!(actual));

Ok(())
}

#[test]
#[serial]
fn list_corpora_partially_loaded() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin("annis")?;
let mut cmd = cargo::cargo_bin_cmd!("annis");

cmd.arg("../graphannis/tests/data/")
.arg("-c")
Expand All @@ -83,25 +108,29 @@ fn list_corpora_partially_loaded() -> Result<(), Box<dyn std::error::Error>> {
.arg("-c")
.arg("list");

let output = cmd.output().unwrap();
let actual = mimic_insta_snapshot(output)?;
let settings = standard_filter();
settings.bind(|| assert_cmd_snapshot!(cmd));
settings.bind(|| assert_snapshot!(actual));

Ok(())
}

#[test]
#[serial]
fn export_to_zip_file() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin("annis")?;
let mut cmd = cargo::cargo_bin_cmd!("annis");

cmd.arg("../graphannis/tests/data/")
.arg("-c")
.arg("corpus sample-disk-based-3.3")
.arg("-c")
.arg("export sample-disk-based-3.3.zip");

let output = cmd.output().unwrap();
let actual = mimic_insta_snapshot(output)?;
let settings = standard_filter();
settings.bind(|| assert_cmd_snapshot!(cmd));
settings.bind(|| assert_snapshot!(actual));

// Check that the file has been created
let p = Path::new("sample-disk-based-3.3.zip");
Expand Down
4 changes: 3 additions & 1 deletion core/src/graph/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::sync::Mutex;
use crate::errors::{GraphAnnisCoreError, Result};
use crate::serializer::KeySerializer;
use bincode::Options;
use facet::Facet;
use serde::de::Error as DeserializeError;
use serde::de::{MapAccess, Visitor};
use serde::ser::{Error as SerializeError, SerializeMap};
Expand All @@ -15,7 +16,8 @@ use sstable::{SSIterator, Table, TableBuilder, TableIterator};
use tempfile::NamedTempFile;

/// Describes a single update on the graph.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Clone, Debug, Facet, PartialEq)]
#[repr(u8)]
pub enum UpdateEvent {
/// Add a node with a name and type.
AddNode {
Expand Down
1 change: 1 addition & 0 deletions graphannis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ strum_macros = "0.21"
sys-info = "0.9"
tempfile = "3"
thiserror = "1"
time = "0.3.44"
toml = "0.8"
transient-btree-index = "0.5"
zip = "0.6.4"
Expand Down
2 changes: 1 addition & 1 deletion graphannis/src/annis/db/aql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use boolean_expression::Expr;
use graphannis_core::annostorage::MatchGroup;
use itertools::Itertools;
lalrpop_mod!(
#[allow(clippy::all)]
#[allow(clippy::all, clippy::pedantic, clippy::restriction, clippy::nursery)]
#[allow(clippy::panic)]
parser,
"/annis/db/aql/parser.rs"
Expand Down
2 changes: 1 addition & 1 deletion graphannis/src/annis/db/corpusstorage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2726,7 +2726,7 @@ fn extract_subgraph_by_query(
) -> Result<AnnotationGraph> {
let t_before = std::time::SystemTime::now();
// acquire read-only lock and create query that finds the context nodes
let lock = db_entry.read().unwrap();
let lock = db_entry.read()?;
let orig_db = get_read_or_error(&lock)?;

let plan = ExecutionPlan::from_disjunction(query, orig_db, query_config, timeout)?;
Expand Down
1 change: 1 addition & 0 deletions webservice/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ serde_derive = "1.0"
simplelog = "0.12"
tempfile = "3"
thiserror = "1"
time = "0.3.44"
uuid = { version = "0.8", features = ["v4"] }
walkdir = "2"
zip = "0.6.4"
Expand Down
Loading