fix: Fix CI running analysis-stats incorrectly against the standard libraries

This commit is contained in:
Lukas Wirth 2024-10-18 10:56:23 +02:00
parent 8dd53a3a46
commit e5af3ae427
4 changed files with 13 additions and 8 deletions

View file

@ -104,11 +104,11 @@ jobs:
if: matrix.os == 'ubuntu-latest'
run: target/${{ matrix.target }}/debug/rust-analyzer analysis-stats .
- name: Run analysis-stats on rust std library
- name: Run analysis-stats on the rust standard libraries
if: matrix.os == 'ubuntu-latest'
env:
RUSTC_BOOTSTRAP: 1
run: target/${{ matrix.target }}/debug/rust-analyzer analysis-stats --with-deps $(rustc --print sysroot)/lib/rustlib/src/rust/library/std
RUSTC_BOOTSTRAP: 1
run: target/${{ matrix.target }}/debug/rust-analyzer analysis-stats --with-deps --no-sysroot --no-test $(rustc --print sysroot)/lib/rustlib/src/rust/library/
- name: clippy
if: matrix.os == 'windows-latest'

View file

@ -222,8 +222,6 @@ fn rust_project_is_proc_macro_has_proc_macro_dep() {
}
#[test]
// FIXME Remove the ignore
#[ignore = "requires nightly until the sysroot ships a cargo workspace for library on stable"]
fn smoke_test_real_sysroot_cargo() {
let file_map = &mut FxHashMap::<AbsPathBuf, FileId>::default();
let meta: Metadata = get_test_json_file("hello-world-metadata.json");
@ -235,7 +233,6 @@ fn smoke_test_real_sysroot_cargo() {
&Default::default(),
);
assert!(matches!(sysroot.mode(), SysrootMode::Workspace(_)));
let project_workspace = ProjectWorkspace {
kind: ProjectWorkspaceKind::Cargo {
cargo: cargo_workspace,

View file

@ -6,6 +6,7 @@ use std::{
time::{SystemTime, UNIX_EPOCH},
};
use cfg::{CfgAtom, CfgDiff};
use hir::{
db::{DefDatabase, ExpandDatabase, HirDatabase},
Adt, AssocItem, Crate, DefWithBody, HasSource, HirDisplay, HirFileIdExt, ImportPathConfig,
@ -31,7 +32,7 @@ use itertools::Itertools;
use load_cargo::{load_workspace, LoadCargoConfig, ProcMacroServerChoice};
use oorandom::Rand32;
use profile::{Bytes, StopWatch};
use project_model::{CargoConfig, ProjectManifest, ProjectWorkspace, RustLibSource};
use project_model::{CargoConfig, CfgOverrides, ProjectManifest, ProjectWorkspace, RustLibSource};
use rayon::prelude::*;
use rustc_hash::{FxHashMap, FxHashSet};
use syntax::{AstNode, SyntaxNode};
@ -65,7 +66,11 @@ impl flags::AnalysisStats {
false => Some(RustLibSource::Discover),
},
all_targets: true,
set_test: true,
set_test: !self.no_test,
cfg_overrides: CfgOverrides {
global: CfgDiff::new(vec![CfgAtom::Flag(hir::sym::miri.clone())], vec![]).unwrap(),
selective: Default::default(),
},
..Default::default()
};
let no_progress = &|_| ();

View file

@ -71,6 +71,8 @@ xflags::xflags! {
optional --with-deps
/// Don't load sysroot crates (`std`, `core` & friends).
optional --no-sysroot
/// Don't set #[cfg(test)].
optional --no-test
/// Don't run build scripts or load `OUT_DIR` values by running `cargo check` before analysis.
optional --disable-build-scripts
@ -233,6 +235,7 @@ pub struct AnalysisStats {
pub only: Option<String>,
pub with_deps: bool,
pub no_sysroot: bool,
pub no_test: bool,
pub disable_build_scripts: bool,
pub disable_proc_macros: bool,
pub proc_macro_srv: Option<PathBuf>,