mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
internal: add simple smoke test for project model
Our project model code is rather complicated -- the logic for lowering from `cargo metadata` to `CrateGraph` is fiddly and special-case. So far, we survived without testing this at all, but this increasingly seems like a poor option. So this PR introduces a simple tests just to detect the most obvious failures. The idea here is that, although we rely on external processes (cargo & rustc), we are actually using their stable interfaces, so we might just mock out the outputs. Long term, I would like to try to virtualize IO here, so as to do such mocking in a more principled way, but lets start simple. Should we forgo the mocking and just call `cargo metadata` directly perhaps? Touch question -- I personally feel that fast, in-process tests are more important in this case than any extra assurance we get from running the real thing. Super-long term, we would probably want to extend our heavy tests to cover more use-cases, but we should figure a way to do that without slowing the tests down for everyone. Perhaps we need two-tiered bors system, where we pull from `master` into `release` branch only when an additional set of tests passes?
This commit is contained in:
parent
2211d2cece
commit
b0c4b776b5
6 changed files with 782 additions and 1 deletions
|
@ -23,11 +23,26 @@ pub use dnf::DnfExpr;
|
|||
/// of key and value in `key_values`.
|
||||
///
|
||||
/// See: <https://doc.rust-lang.org/reference/conditional-compilation.html#set-configuration-options>
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default)]
|
||||
#[derive(Clone, PartialEq, Eq, Default)]
|
||||
pub struct CfgOptions {
|
||||
enabled: FxHashSet<CfgAtom>,
|
||||
}
|
||||
|
||||
impl fmt::Debug for CfgOptions {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let mut items = self
|
||||
.enabled
|
||||
.iter()
|
||||
.map(|atom| match atom {
|
||||
CfgAtom::Flag(it) => it.to_string(),
|
||||
CfgAtom::KeyValue { key, value } => format!("{}={}", key, value),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
items.sort();
|
||||
f.debug_tuple("CfgOptions").field(&items).finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl CfgOptions {
|
||||
pub fn check(&self, cfg: &CfgExpr) -> Option<bool> {
|
||||
cfg.fold(&|atom| self.enabled.contains(atom))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue