Skip to content

Commit 58655e5

Browse files
committed
test(index): enable SQLite index cache in CI
__CARGO_TEST_FORCE_SQLITE_INDEX_CACHE to force enable it.
1 parent 79bbdae commit 58655e5

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ jobs:
185185
- name: Clear test output
186186
run: ci/clean-test-output.sh
187187

188+
- name: Check operability of index cache in SQLite3
189+
run: 'cargo test -p cargo --test testsuite -- alt_registry:: global_cache_tracker::'
190+
env:
191+
__CARGO_TEST_FORCE_SQLITE_INDEX_CACHE: 1
188192
# This only tests `cargo fix` because fix-proxy-mode is one of the most
189193
# complicated subprocess management in Cargo.
190194
- name: Check operability of rustc invocation with argfile

src/cargo/sources/registry/index/cache.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,10 @@ impl<'gctx> CacheManager<'gctx> {
248248
///
249249
/// `root` --- The root path where caches are located.
250250
pub fn new(cache_root: Filesystem, gctx: &'gctx GlobalContext) -> CacheManager<'gctx> {
251-
let store: Box<dyn CacheStore> = if gctx.cli_unstable().index_cache_sqlite {
251+
#[allow(clippy::disallowed_methods)]
252+
let use_sqlite = gctx.cli_unstable().index_cache_sqlite
253+
|| std::env::var("__CARGO_TEST_FORCE_SQLITE_INDEX_CACHE").is_ok();
254+
let store: Box<dyn CacheStore> = if use_sqlite {
252255
Box::new(LocalDatabase::new(cache_root, gctx))
253256
} else {
254257
Box::new(LocalFileSystem::new(cache_root, gctx))

0 commit comments

Comments
 (0)