refactor(tvix/store): remove use of lazy_static
This is now supported in the standard library via std::sync::LazyLock, but requires some manual shuffling around of code. Change-Id: Ifca792f4d2dbc36b703de4a4dfa406015ab86da7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12614 Autosubmit: flokli <flokli@flokli.de> Reviewed-by: flokli <flokli@flokli.de> Reviewed-by: edef <edef@edef.eu> Tested-by: BuildkiteCI
This commit is contained in:
parent
f0d594789e
commit
1c80bc4b5b
9 changed files with 118 additions and 122 deletions
|
|
@ -57,16 +57,14 @@ pub async fn from_addr(
|
|||
mod tests {
|
||||
use super::from_addr;
|
||||
use crate::composition::{Composition, DeserializeWithRegistry, ServiceBuilder, REG};
|
||||
use lazy_static::lazy_static;
|
||||
use rstest::rstest;
|
||||
use std::sync::LazyLock;
|
||||
use tempfile::TempDir;
|
||||
use tvix_castore::blobservice::{BlobService, MemoryBlobServiceConfig};
|
||||
use tvix_castore::directoryservice::{DirectoryService, MemoryDirectoryServiceConfig};
|
||||
|
||||
lazy_static! {
|
||||
static ref TMPDIR_REDB_1: TempDir = TempDir::new().unwrap();
|
||||
static ref TMPDIR_REDB_2: TempDir = TempDir::new().unwrap();
|
||||
}
|
||||
static TMPDIR_REDB_1: LazyLock<TempDir> = LazyLock::new(|| TempDir::new().unwrap());
|
||||
static TMPDIR_REDB_2: LazyLock<TempDir> = LazyLock::new(|| TempDir::new().unwrap());
|
||||
|
||||
// the gRPC tests below don't fail, because we connect lazily.
|
||||
|
||||
|
|
|
|||
|
|
@ -86,22 +86,20 @@ impl ServiceBuilder for LruPathInfoServiceConfig {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use nix_compat::store_path::StorePath;
|
||||
use std::num::NonZeroUsize;
|
||||
use std::{num::NonZeroUsize, sync::LazyLock};
|
||||
|
||||
use crate::{
|
||||
pathinfoservice::{LruPathInfoService, PathInfo, PathInfoService},
|
||||
tests::fixtures::PATH_INFO,
|
||||
};
|
||||
use lazy_static::lazy_static;
|
||||
static PATHINFO_2: LazyLock<PathInfo> = LazyLock::new(|| {
|
||||
let mut p = PATH_INFO.clone();
|
||||
p.store_path = StorePath::from_name_and_digest_fixed("dummy", [1; 20]).unwrap();
|
||||
p
|
||||
});
|
||||
|
||||
lazy_static! {
|
||||
static ref PATHINFO_2: PathInfo = {
|
||||
let mut p = PATH_INFO.clone();
|
||||
p.store_path = StorePath::from_name_and_digest_fixed("dummy", [1; 20]).unwrap();
|
||||
p
|
||||
};
|
||||
static ref PATHINFO_2_DIGEST: [u8; 20] = *PATHINFO_2.store_path.digest();
|
||||
}
|
||||
static PATHINFO_2_DIGEST: LazyLock<[u8; 20]> =
|
||||
LazyLock::new(|| *PATHINFO_2.store_path.digest());
|
||||
|
||||
#[tokio::test]
|
||||
async fn evict() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue