Skip to content

Commit

Permalink
test(index): enable SQLite index cache in CI
Browse files Browse the repository at this point in the history
__CARGO_TEST_FORCE_SQLITE_INDEX_CACHE to force enable it.
  • Loading branch information
weihanglo committed Mar 14, 2024
1 parent 79bbdae commit 58655e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/cargo/sources/registry/index/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn CacheStore> = 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<dyn CacheStore> = if use_sqlite {
Box::new(LocalDatabase::new(cache_root, gctx))
} else {
Box::new(LocalFileSystem::new(cache_root, gctx))
Expand Down

0 comments on commit 58655e5

Please sign in to comment.