From 58655e5e70d350af0eb2b469086e6a57005c0cdc Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Thu, 14 Mar 2024 17:23:53 -0400 Subject: [PATCH] test(index): enable SQLite index cache in CI __CARGO_TEST_FORCE_SQLITE_INDEX_CACHE to force enable it. --- .github/workflows/main.yml | 4 ++++ src/cargo/sources/registry/index/cache.rs | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3f68682cf5a3..7634dd99a98f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -185,6 +185,10 @@ jobs: - name: Clear test output run: ci/clean-test-output.sh + - name: Check operability of index cache in SQLite3 + run: 'cargo test -p cargo --test testsuite -- alt_registry:: global_cache_tracker::' + env: + __CARGO_TEST_FORCE_SQLITE_INDEX_CACHE: 1 # This only tests `cargo fix` because fix-proxy-mode is one of the most # complicated subprocess management in Cargo. - name: Check operability of rustc invocation with argfile diff --git a/src/cargo/sources/registry/index/cache.rs b/src/cargo/sources/registry/index/cache.rs index 8088f6a7469e..84d2640cc505 100644 --- a/src/cargo/sources/registry/index/cache.rs +++ b/src/cargo/sources/registry/index/cache.rs @@ -248,7 +248,10 @@ impl<'gctx> CacheManager<'gctx> { /// /// `root` --- The root path where caches are located. pub fn new(cache_root: Filesystem, gctx: &'gctx GlobalContext) -> CacheManager<'gctx> { - let store: Box = if gctx.cli_unstable().index_cache_sqlite { + #[allow(clippy::disallowed_methods)] + let use_sqlite = gctx.cli_unstable().index_cache_sqlite + || std::env::var("__CARGO_TEST_FORCE_SQLITE_INDEX_CACHE").is_ok(); + let store: Box = if use_sqlite { Box::new(LocalDatabase::new(cache_root, gctx)) } else { Box::new(LocalFileSystem::new(cache_root, gctx))