refactor(tvix/castore): 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: Ia0370ca46cb1c6122a452b1d117160536b632c7e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12612
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
Florian Klink 2024-10-13 18:31:28 +03:00 committed by clbot
parent a94414e7ff
commit cdbdd2d04e
5 changed files with 145 additions and 126 deletions

View file

@ -276,23 +276,21 @@ impl ValidatedDirectoryGraph {
mod tests {
use crate::fixtures::{DIRECTORY_A, DIRECTORY_B, DIRECTORY_C};
use crate::{Directory, Node};
use lazy_static::lazy_static;
use rstest::rstest;
use std::sync::LazyLock;
use super::{DirectoryGraph, LeavesToRootValidator, RootToLeavesValidator};
lazy_static! {
pub static ref BROKEN_PARENT_DIRECTORY: Directory =
Directory::try_from_iter([
(
"foo".try_into().unwrap(),
Node::Directory{
digest: DIRECTORY_A.digest(),
size: DIRECTORY_A.size() + 42, // wrong!
}
)
]).unwrap();
}
pub static BROKEN_PARENT_DIRECTORY: LazyLock<Directory> = LazyLock::new(|| {
Directory::try_from_iter([(
"foo".try_into().unwrap(),
Node::Directory {
digest: DIRECTORY_A.digest(),
size: DIRECTORY_A.size() + 42, // wrong!
},
)])
.unwrap()
});
#[rstest]
/// Uploading an empty directory should succeed.

View file

@ -45,15 +45,14 @@ pub async fn from_addr(
#[cfg(test)]
mod tests {
use std::sync::LazyLock;
use super::from_addr;
use lazy_static::lazy_static;
use rstest::rstest;
use tempfile::TempDir;
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());
#[rstest]
/// This uses an unsupported scheme.