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 27, 2024
1 parent 3d5b357 commit 4ab7aab
Show file tree
Hide file tree
Showing 3 changed files with 11 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
3 changes: 3 additions & 0 deletions tests/testsuite/index_cache_sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ fn crates_io() {
.with_stderr(
"\
[UPDATING] `dummy-registry` index
[LOCKING] 3 packages
[DOWNLOADING] crates ...
[DOWNLOADED] dep1 v0.0.0 (registry `dummy-registry`)
[DOWNLOADED] dep2 v0.0.0 (registry `dummy-registry`)
Expand Down Expand Up @@ -74,6 +75,8 @@ fn crates_io() {
.with_stderr(
"\
[UPDATING] `dummy-registry` index
[LOCKING] 1 package
[ADDING] dep3 v0.0.0
[DOWNLOADING] crates ...
[DOWNLOADED] dep3 v0.0.0 (registry `dummy-registry`)
",
Expand Down

0 comments on commit 4ab7aab

Please sign in to comment.