Skip to content

Commit 203f909

Browse files
bors[bot]matklad
andauthored
Merge #9644
9644: internal: add simple smoke test for project model r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 9c98606 + 3f78ca0 commit 203f909

File tree

6 files changed

+758
-1
lines changed

6 files changed

+758
-1
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/cfg/src/lib.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,26 @@ pub use dnf::DnfExpr;
2323
/// of key and value in `key_values`.
2424
///
2525
/// See: <https://doc.rust-lang.org/reference/conditional-compilation.html#set-configuration-options>
26-
#[derive(Debug, Clone, PartialEq, Eq, Default)]
26+
#[derive(Clone, PartialEq, Eq, Default)]
2727
pub struct CfgOptions {
2828
enabled: FxHashSet<CfgAtom>,
2929
}
3030

31+
impl fmt::Debug for CfgOptions {
32+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
33+
let mut items = self
34+
.enabled
35+
.iter()
36+
.map(|atom| match atom {
37+
CfgAtom::Flag(it) => it.to_string(),
38+
CfgAtom::KeyValue { key, value } => format!("{}={}", key, value),
39+
})
40+
.collect::<Vec<_>>();
41+
items.sort();
42+
f.debug_tuple("CfgOptions").field(&items).finish()
43+
}
44+
}
45+
3146
impl CfgOptions {
3247
pub fn check(&self, cfg: &CfgExpr) -> Option<bool> {
3348
cfg.fold(&|atom| self.enabled.contains(atom))

crates/project_model/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ semver = "1"
1616
serde = { version = "1.0.106", features = ["derive"] }
1717
serde_json = "1.0.48"
1818
anyhow = "1.0.26"
19+
expect-test = "1"
1920
la-arena = { version = "0.2.0", path = "../../lib/arena" }
2021

2122
cfg = { path = "../cfg", version = "0.0.0" }

crates/project_model/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ mod workspace;
2424
mod rustc_cfg;
2525
mod build_scripts;
2626

27+
#[cfg(test)]
28+
mod tests;
29+
2730
use std::{
2831
convert::{TryFrom, TryInto},
2932
fs::{self, read_dir, ReadDir},

0 commit comments

Comments
 (0)