about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlexander_Kabui <alexanderkabua@gmail.com>2026-10-07 23:53:44 +0300
committerAlexander_Kabui <alexanderkabua@gmail.com>2026-10-07 23:53:44 +0300
commita109c78a6bebf21fac89bad0740767675810d4e6 (patch)
tree2c172d7aabba7388c380b3bf177e5601c9b12bb2 /src
parent775ad48f0c2db905b692ce7fc481f1101424ab63 (diff)
downloadgenenetwork4-a109c78a6bebf21fac89bad0740767675810d4e6.tar.gz
src/search/native.rs (tests): drop the guard unit test's env mutation (P3 review F1)
The C3.6 guard test set XAPIAN_DB_PATH="" to "prove" the guard fires
before the index is opened — but the error VARIANT is already that
proof (an unset path would surface Internal, an unopenable one
Unreachable, if the query ever reached the index), and the mutation
raced the config tests that set the same key on their own parallel
threads in the lib test binary (a scheduler-dependent flake of the
config assertions, found in the mandatory P3 hostile re-read).
The test now touches no environment at all.

Gate: hermetic lib gate green after the change
(logs/p3-f1-fix-lib.log: LIB_EXIT=0, LIB_FMT_EXIT=0).
Diffstat (limited to 'src')
-rw-r--r--src/search/native.rs15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/search/native.rs b/src/search/native.rs
index 76acbc2..6e5dab4 100644
--- a/src/search/native.rs
+++ b/src/search/native.rs
@@ -911,18 +911,15 @@ mod tests {
     /// The C3.6 engine guard: the sentinel anywhere in the parsed query
     /// surfaces as InvalidQuery BEFORE the index is opened — so the
     /// invalid-location class reports as a query fault (the blessed 422)
-    /// even with no index configured, mirroring gn3's parse-before-open
-    /// order (search.py:291 vs :296).
+    /// whatever `XAPIAN_DB_PATH` holds, mirroring gn3's parse-before-open
+    /// order (search.py:291 vs :296). The error VARIANT is the proof:
+    /// an unset path would surface as Internal and an unopenable one as
+    /// Unreachable if the query ever reached the index. No environment
+    /// is touched: this test runs in the lib binary next to the config
+    /// tests, which mutate `XAPIAN_DB_PATH` on their own threads.
     #[test]
     fn hs_mm_engine_guard_fires_before_the_index() {
-        let prior = std::env::var("XAPIAN_DB_PATH").ok();
-        // SAFETY: hermetic single-threaded unit test; restored below.
-        unsafe { std::env::set_var("XAPIAN_DB_PATH", "") };
         let outcome = futures_of_native_guard("Hs:foo:1M");
-        match prior {
-            Some(value) => unsafe { std::env::set_var("XAPIAN_DB_PATH", value) },
-            None => unsafe { std::env::remove_var("XAPIAN_DB_PATH") },
-        }
         assert!(
             matches!(outcome, Err(SearchError::InvalidQuery { .. })),
             "the guard must report InvalidQuery before the index is touched"