Skip to content

armgit / xerj

Public Imported from GitHub
0

AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.

test(autoindex): fix Windows unit test imports and spool drop (#2924)

Napat (Tan) Phasundhiae3b755f385258
diff --git a/engine/crates/xerj-autoindex/src/extract/pdf.rs b/engine/crates/xerj-autoindex/src/extract/pdf.rs
index 81ceda503..bd4a9bac1 100644
--- a/engine/crates/xerj-autoindex/src/extract/pdf.rs
+++ b/engine/crates/xerj-autoindex/src/extract/pdf.rs
@@ -1653,7 +1653,10 @@ mod tests {
.unwrap();
// The artifact exists only as an open handle; it adds no recoverable
- // path or stale-cache state under the journal directory.
+ // path or stale-cache state under the journal directory. On Windows
+ // (FILE_FLAG_DELETE_ON_CLOSE), the directory entry disappears when the
+ // handle is dropped after replay below.
+ #[cfg(unix)]
assert_eq!(std::fs::read_dir(state.path()).unwrap().count(), 0);
let mut replayed = Vec::new();
@@ -1673,6 +1676,7 @@ mod tests {
.replay(123, "axf2-generation-b", &mut |_| true)
.unwrap_err();
assert!(error.to_string().contains("different source generation"));
+ assert_eq!(std::fs::read_dir(state.path()).unwrap().count(), 0);
}
#[test]
@@ -1806,6 +1810,7 @@ mod tests {
assert_eq!(budget.report()["reservations_started"], 0);
}
+ #[cfg(unix)]
#[test]
fn worker_that_closes_its_pipes_but_keeps_running_still_times_out() {
// #1394: the supervisor now sleeps on pipe EOF instead of a fixed
diff --git a/engine/crates/xerj-autoindex/src/feedback.rs b/engine/crates/xerj-autoindex/src/feedback.rs
index 9061124a4..80706fa4e 100644
--- a/engine/crates/xerj-autoindex/src/feedback.rs
+++ b/engine/crates/xerj-autoindex/src/feedback.rs
@@ -1897,8 +1897,11 @@ mod tests {
fn write_executable(path: &Path, body: &str) {
std::fs::write(path, body).unwrap();
- use std::os::unix::fs::PermissionsExt;
- std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o755)).unwrap();
+ #[cfg(unix)]
+ {
+ use std::os::unix::fs::PermissionsExt;
+ std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o755)).unwrap();
+ }
}
fn xerj_origin(root: &Path) {
diff --git a/engine/crates/xerj-autoindex/src/walk.rs b/engine/crates/xerj-autoindex/src/walk.rs
index e9beda484..fc9a3e607 100644
--- a/engine/crates/xerj-autoindex/src/walk.rs
+++ b/engine/crates/xerj-autoindex/src/walk.rs
@@ -803,6 +803,7 @@ mod hidden_skip_tests {
/// while `open` on the walk path still succeeds. That asymmetry is what
/// made `.ok()?` a bypass — the guard was skipped for precisely the entries
/// it could not vet.
+ #[cfg(unix)]
#[test]
fn an_unresolvable_entry_is_refused_not_admitted() {
use std::ffi::OsStr;