Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't throw an error when there is no features in Cargo.toml #21

Merged
merged 1 commit into from
Dec 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ fn process_toml(cargo_toml: &str, args: &Args) -> Result<String, String> {
return Err("Found comment not associated with a feature".into());
}
if features.is_empty() {
return Err("Could not find documented features in Cargo.toml".into());
return Ok("*No documented features in Cargo.toml*".into());
}
let mut result = String::new();
for (f, top, comment) in features {
Expand Down Expand Up @@ -585,26 +585,30 @@ default = ["feat1", "something_else"]
}

#[test]
fn parse_error1() {
test_error(
fn no_features() {
let r = process_toml(
r#"
[features]
[dependencies]
foo = 4;
"#,
"Could not find documented features",
);
&Args::default(),
)
.unwrap();
assert_eq!(r, "*No documented features in Cargo.toml*");
}

#[test]
fn parse_error2() {
test_error(
fn no_features2() {
let r = process_toml(
r#"
[packages]
[dependencies]
"#,
"Could not find documented features",
);
&Args::default(),
)
.unwrap();
assert_eq!(r, "*No documented features in Cargo.toml*");
}

#[test]
Expand Down
Loading