Skip to content

Commit 290ef12

Browse files
committed
built-tests: use custom crate to test implicit optional-dependency features aren't there
1 parent e5fe3cb commit 290ef12

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

src/docbuilder/rustwide_builder.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,7 @@ mod tests {
12951295
use crate::registry_api::ReleaseData;
12961296
use crate::storage::{CompressionAlgorithm, compression};
12971297
use crate::test::{AxumRouterTestExt, TestEnvironment, wrapper};
1298+
use pretty_assertions::assert_eq;
12981299
use std::{io, iter};
12991300
use test_case::test_case;
13001301

@@ -1979,21 +1980,25 @@ mod tests {
19791980
#[ignore]
19801981
fn test_no_implicit_features_for_optional_dependencies_with_dep_syntax() {
19811982
wrapper(|env| {
1982-
let crate_ = "stylish-core";
1983-
let version = "0.1.1";
19841983
let mut builder = RustwideBuilder::init(env).unwrap();
19851984
builder.update_toolchain()?;
19861985
assert!(
19871986
builder
1988-
.build_package(crate_, version, PackageKind::CratesIo, false)?
1987+
.build_local_package(Path::new("tests/crates/optional-dep"))?
19891988
.successful
19901989
);
19911990

1992-
assert!(
1993-
!get_features(env, crate_, version)?
1991+
assert_eq!(
1992+
get_features(env, "optional-dep", "0.0.1")?
19941993
.unwrap()
19951994
.iter()
1996-
.any(|f| f.name == "with_builtin_macros")
1995+
.map(|f| f.name.to_owned())
1996+
.sorted()
1997+
.collect_vec(),
1998+
// "regex" feature is not in the list,
1999+
// because we don't have implicit features for optional dependencies
2000+
// with `dep` syntax any more.
2001+
vec!["alloc", "default", "optional_regex", "std"]
19972002
);
19982003

19992004
Ok(())
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "optional-dep"
3+
version = "0.0.1"
4+
edition = "2024"
5+
6+
[features]
7+
default = ["std"]
8+
std = ["alloc"]
9+
alloc = []
10+
optional_regex = ["dep:regex"]
11+
12+
[dependencies]
13+
regex = { version = "1.11.3", optional = true }

tests/crates/optional-dep/src/lib.rs

Whitespace-only changes.

0 commit comments

Comments
 (0)