Fix reconciliation expectations and strict Clippy checks
This commit is contained in:
1 parent
feec06bc41
commit
a85a4e1184
4 files changed
+49
-21
No files matched your search
@@ -104,7 +104,7 @@ fn directory_events_reconcile_only_subtree_and_prune_exclusions() -> Result<()>
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_batches_and_failed_reads_roll_back_all_changes() -> Result<()> {
|
||||
fn invalid_batches_and_unreadable_sources_preserve_records() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
let root = temp.path().join("root");
|
||||
fs::create_dir(&root)?;
|
||||
@@ -126,10 +126,14 @@ fn invalid_batches_and_failed_reads_roll_back_all_changes() -> Result<()> {
|
||||
let permissions = {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let previous = fs::metadata(root.join("z.txt"))?.permissions();
|
||||
fs::set_permissions(root.join("z.txt"), fs::Permissions::from_mode(0))?;
|
||||
fs::set_permissions(root.join("z.txt"), fs::Permissions::from_mode(0o000))?;
|
||||
previous
|
||||
};
|
||||
let failed = index.index_paths_with_options(
|
||||
let denied = fs::File::open(root.join("z.txt"))
|
||||
.expect_err("fixture must prevent reading the indexed source")
|
||||
.kind()
|
||||
== std::io::ErrorKind::PermissionDenied;
|
||||
let result = index.index_paths_with_options(
|
||||
&root,
|
||||
&[root.join("a.txt"), root.join("z.txt")],
|
||||
&IndexOptions::default(),
|
||||
@@ -138,9 +142,19 @@ fn invalid_batches_and_failed_reads_roll_back_all_changes() -> Result<()> {
|
||||
drop(locked);
|
||||
#[cfg(unix)]
|
||||
fs::set_permissions(root.join("z.txt"), permissions)?;
|
||||
assert!(failed.is_err());
|
||||
assert_eq!(index.search("beforetransaction", 10)?.len(), 1);
|
||||
assert!(index.search("aftertransaction", 10)?.is_empty());
|
||||
if denied {
|
||||
// Permission denial preserves that file while readable changes commit.
|
||||
let report = result?;
|
||||
assert_eq!(report.skipped, 1);
|
||||
assert_eq!(index.search("aftertransaction", 10)?.len(), 1);
|
||||
assert!(index.search("beforetransaction", 10)?.is_empty());
|
||||
} else {
|
||||
// Other I/O errors, including platform-specific sharing failures, abort.
|
||||
assert!(result.is_err());
|
||||
assert_eq!(index.search("beforetransaction", 10)?.len(), 1);
|
||||
assert!(index.search("aftertransaction", 10)?.is_empty());
|
||||
}
|
||||
assert_eq!(index.search("validlast", 10)?.len(), 1);
|
||||
assert!(index
|
||||
.index_paths_with_options(
|
||||
&root,
|
||||
|
||||
@@ -40,11 +40,7 @@ pub fn apply() -> Result<()> {
|
||||
pub fn apply() -> Result<()> {
|
||||
// Darwin rejects finite AS/DATA limits. The parent enforces a sampled RSS
|
||||
// budget there; retain the CPU limit and bounded path-free transport here.
|
||||
for (resource, maximum) in [
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
(libc::RLIMIT_AS, MEMORY_BYTES as libc::rlim_t),
|
||||
(libc::RLIMIT_CPU, 30 as libc::rlim_t),
|
||||
] {
|
||||
let set_limit = |resource, maximum| -> Result<()> {
|
||||
let value = libc::rlimit {
|
||||
rlim_cur: maximum,
|
||||
rlim_max: maximum,
|
||||
@@ -55,8 +51,11 @@ pub fn apply() -> Result<()> {
|
||||
unsafe { libc::setrlimit(resource, &value) } == 0,
|
||||
"Cannot install extraction resource limit"
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
Ok(())
|
||||
};
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
set_limit(libc::RLIMIT_AS, MEMORY_BYTES as libc::rlim_t)?;
|
||||
set_limit(libc::RLIMIT_CPU, 30 as libc::rlim_t)
|
||||
}
|
||||
|
||||
#[cfg(not(any(windows, unix)))]
|
||||
|
||||
@@ -787,10 +787,10 @@ impl Store {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
trace.end(generation_span, Default::default());
|
||||
if !self
|
||||
if self
|
||||
.ann_cache
|
||||
.as_ref()
|
||||
.is_some_and(|(generation, _)| *generation == active)
|
||||
.is_none_or(|(generation, _)| *generation != active)
|
||||
{
|
||||
let prepared = trace.timed("semantic.prepared_graph_lookup", parent, |_, _| {
|
||||
let checksum: String = snapshot.query_row(
|
||||
@@ -815,10 +815,10 @@ impl Store {
|
||||
.is_some_and(|(generation, _)| *generation == active),
|
||||
),
|
||||
);
|
||||
if !self
|
||||
if self
|
||||
.ann_cache
|
||||
.as_ref()
|
||||
.is_some_and(|(generation, _)| *generation == active)
|
||||
.is_none_or(|(generation, _)| *generation != active)
|
||||
{
|
||||
let blob_span = trace.begin("semantic.ann_blob_read", ann_load);
|
||||
let length: Option<usize> = snapshot.query_row(
|
||||
|
||||
Reference in new issue
Block a user