mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Test fixed scratch capacity during preference setup
This commit is contained in:
1 parent
c1d92c8859
commit
098612bdb9
2 files changed
+28
No files matched your search
@@ -112,6 +112,28 @@ mod native {
|
||||
assert!(private.upgrade().is_none());
|
||||
drop(weak);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn preferences_use_fixed_scratch_capacity_in_an_isolated_process() {
|
||||
const CHILD: &str = "PHOTOCRAFT_SCRATCH_CAPACITY_TEST_CHILD";
|
||||
if std::env::var_os(CHILD).is_none() {
|
||||
let status = std::process::Command::new(std::env::current_exe().unwrap())
|
||||
.args(["--exact", "scratch::native::tests::preferences_use_fixed_scratch_capacity_in_an_isolated_process"])
|
||||
.env(CHILD, "1")
|
||||
.status()
|
||||
.unwrap();
|
||||
assert!(status.success(), "isolated scratch test failed: {status}");
|
||||
return;
|
||||
}
|
||||
|
||||
// If configure uses this query even once, it pauses for lack of room. This catches an
|
||||
// override that is missing or is installed after configuring the scratch directory.
|
||||
photocraft_raster::spill::set_volume_space_for_tests(|_| Some((0, 64 << 30)));
|
||||
super::super::configure(&crate::prefs::Preferences::default());
|
||||
assert!(!photocraft_raster::spill::paused());
|
||||
let room = (32_u64 << 30) - (64_u64 << 30) / 20;
|
||||
assert_eq!(photocraft_raster::spill::scratch_capacity(), Some(room - room / 64));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1143,6 +1143,12 @@ pub fn use_test_volume_space() {
|
||||
M.config().query_space = |dir| dir.is_dir().then_some((32 << 30, 64 << 30));
|
||||
}
|
||||
|
||||
/// Substitute a volume-space query in an isolated test process.
|
||||
#[doc(hidden)]
|
||||
pub fn set_volume_space_for_tests(query: fn(&Path) -> Option<(u64, u64)>) {
|
||||
M.config().query_space = query;
|
||||
}
|
||||
|
||||
/// Runs at the start of every folder query, off every lock: tests stall it to simulate a dead mount.
|
||||
#[doc(hidden)]
|
||||
pub fn set_query_hook_for_tests(hook: Option<fn(&Path)>) {
|
||||
|
||||
Reference in new issue
Block a user