Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ cfg-if = "1.0.3"
color-eyre = "0.6.5"
# config's "preserve_order" feature is needed for preserving the order of
# setup scripts in .config/nextest.toml.
config = { version = "0.15.16", default-features = false, features = [
config = { version = "0.15.18", default-features = false, features = [
"toml",
"preserve_order",
] }
Expand Down
34 changes: 25 additions & 9 deletions nextest-runner/src/config/elements/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ mod tests {
[profile.default]
archive.include = { path = "foo", relative-to = "target" }
"#},
ConfigErrorKind::Message,
r"invalid type: map, expected a sequence"
; "missing list")]
#[test_case(
Expand All @@ -361,7 +362,8 @@ mod tests {
{ path = "foo" }
]
"#},
r"missing field `relative-to`"
ConfigErrorKind::NotFound,
r#"profile.default.archive.include[0]relative-to"#
; "missing relative-to")]
#[test_case(
indoc!{r#"
Expand All @@ -370,6 +372,7 @@ mod tests {
{ path = "bar", relative-to = "unknown" }
]
"#},
ConfigErrorKind::Message,
r"enum ArchiveRelativeTo does not have variant constructor unknown"
; "invalid relative-to")]
#[test_case(
Expand All @@ -379,6 +382,7 @@ mod tests {
{ path = "bar", relative-to = "target", depth = -1 }
]
"#},
ConfigErrorKind::Message,
r#"invalid value: integer `-1`, expected a non-negative integer or "infinite""#
; "negative depth")]
#[test_case(
Expand All @@ -388,6 +392,7 @@ mod tests {
{ path = "foo/../bar", relative-to = "target" }
]
"#},
ConfigErrorKind::Message,
r#"invalid value: string "foo/../bar", expected a relative path with no parent components"#
; "parent component")]
#[test_case(
Expand All @@ -397,6 +402,7 @@ mod tests {
{ path = "/foo/bar", relative-to = "target" }
]
"#},
ConfigErrorKind::Message,
r#"invalid value: string "/foo/bar", expected a relative path with no parent components"#
; "absolute path")]
#[test_case(
Expand All @@ -406,6 +412,7 @@ mod tests {
{ path = "foo", relative-to = "target", on-missing = "unknown" }
]
"#},
ConfigErrorKind::Message,
r#"invalid value: string "unknown", expected a string: "ignore", "warn", or "error""#
; "invalid on-missing")]
#[test_case(
Expand All @@ -415,9 +422,14 @@ mod tests {
{ path = "foo", relative-to = "target", on-missing = 42 }
]
"#},
ConfigErrorKind::Message,
r#"invalid type: integer `42`, expected a string: "ignore", "warn", or "error""#
; "invalid on-missing type")]
fn parse_invalid(config_contents: &str, expected_message: &str) {
fn parse_invalid(
config_contents: &str,
expected_kind: ConfigErrorKind,
expected_message: &str,
) {
let workspace_dir = tempdir().unwrap();

let graph = temp_workspace(&workspace_dir, config_contents);
Expand All @@ -434,14 +446,18 @@ mod tests {
.expect_err("config expected to be invalid");

let message = match config_err.kind() {
ConfigParseErrorKind::DeserializeError(path_error) => match path_error.inner() {
ConfigError::Message(message) => message,
other => {
panic!(
"for config error {config_err:?}, expected ConfigError::Message for inner error {other:?}"
);
ConfigParseErrorKind::DeserializeError(path_error) => {
match (path_error.inner(), expected_kind) {
(ConfigError::NotFound(message), ConfigErrorKind::NotFound) => message,
(ConfigError::Message(message), ConfigErrorKind::Message) => message,
(other, expected) => {
panic!(
"for config error {config_err:?}, expected \
ConfigErrorKind::{expected:?} for inner error {other:?}"
);
}
}
},
}
other => {
panic!(
"for config error {other:?}, expected ConfigParseErrorKind::DeserializeError"
Expand Down
2 changes: 1 addition & 1 deletion nextest-runner/src/config/elements/leak_timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ mod tests {
[profile.ci]
leak-timeout = { result = "fail" }
"#},
Err("original: missing field `period`"),
Err(r#"original: missing configuration field "profile.ci.leak-timeout.period""#),
None

; "partial leak-timeout table should error"
Expand Down
2 changes: 1 addition & 1 deletion nextest-runner/src/config/elements/max_fail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ mod tests {
[profile.custom]
fail-fast = { invalid-key = 1 }
"#},
"profile.custom.fail-fast: missing field `max-fail`"
r#"profile.custom.fail-fast: missing configuration field "profile.custom.fail-fast.max-fail""#
; "invalid map key"
)]
#[test_case(
Expand Down
41 changes: 30 additions & 11 deletions nextest-runner/src/config/elements/retry_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,79 +300,94 @@ mod tests {
[profile.default]
retries = { backoff = "foo" }
"#},
ConfigErrorKind::Message,
"unknown variant `foo`, expected `fixed` or `exponential`"
; "invalid value for backoff")]
#[test_case(
indoc!{r#"
[profile.default]
retries = { backoff = "fixed" }
"#},
"missing field `count`"
ConfigErrorKind::NotFound,
"profile.default.retries.count"
; "fixed specified without count")]
#[test_case(
indoc!{r#"
[profile.default]
retries = { backoff = "fixed", count = 1, delay = "foobar" }
"#},
ConfigErrorKind::Message,
"invalid value: string \"foobar\", expected a duration"
; "delay is not a valid duration")]
#[test_case(
indoc!{r#"
[profile.default]
retries = { backoff = "fixed", count = 1, jitter = true }
"#},
ConfigErrorKind::Message,
"`jitter` cannot be true if `delay` isn't specified or is zero"
; "jitter specified without delay")]
#[test_case(
indoc!{r#"
[profile.default]
retries = { backoff = "fixed", count = 1, max-delay = "10s" }
"#},
ConfigErrorKind::Message,
"unknown field `max-delay`, expected one of `count`, `delay`, `jitter`"
; "max-delay is incompatible with fixed backoff")]
#[test_case(
indoc!{r#"
[profile.default]
retries = { backoff = "exponential", count = 1 }
"#},
"missing field `delay`"
ConfigErrorKind::NotFound,
"profile.default.retries.delay"
; "exponential backoff must specify delay")]
#[test_case(
indoc!{r#"
[profile.default]
retries = { backoff = "exponential", delay = "1s" }
"#},
"missing field `count`"
ConfigErrorKind::NotFound,
"profile.default.retries.count"
; "exponential backoff must specify count")]
#[test_case(
indoc!{r#"
[profile.default]
retries = { backoff = "exponential", count = 0, delay = "1s" }
"#},
ConfigErrorKind::Message,
"`count` cannot be zero with exponential backoff"
; "exponential backoff must have a non-zero count")]
#[test_case(
indoc!{r#"
[profile.default]
retries = { backoff = "exponential", count = 1, delay = "0s" }
"#},
ConfigErrorKind::Message,
"`delay` cannot be zero with exponential backoff"
; "exponential backoff must have a non-zero delay")]
#[test_case(
indoc!{r#"
[profile.default]
retries = { backoff = "exponential", count = 1, delay = "1s", max-delay = "0s" }
"#},
ConfigErrorKind::Message,
"`max-delay` cannot be zero with exponential backoff"
; "exponential backoff must have a non-zero max delay")]
#[test_case(
indoc!{r#"
[profile.default]
retries = { backoff = "exponential", count = 1, delay = "4s", max-delay = "2s", jitter = true }
"#},
ConfigErrorKind::Message,
"`max-delay` cannot be less than delay"
; "max-delay greater than delay")]
fn parse_retries_invalid(config_contents: &str, expected_message: &str) {
fn parse_retries_invalid(
config_contents: &str,
expected_kind: ConfigErrorKind,
expected_message: &str,
) {
let workspace_dir = tempdir().unwrap();

let graph = temp_workspace(&workspace_dir, config_contents);
Expand All @@ -388,14 +403,18 @@ mod tests {
.expect_err("config expected to be invalid");

let message = match config_err.kind() {
ConfigParseErrorKind::DeserializeError(path_error) => match path_error.inner() {
ConfigError::Message(message) => message,
other => {
panic!(
"for config error {config_err:?}, expected ConfigError::Message for inner error {other:?}"
);
ConfigParseErrorKind::DeserializeError(path_error) => {
match (path_error.inner(), expected_kind) {
(ConfigError::Message(message), ConfigErrorKind::Message) => message,
(ConfigError::NotFound(message), ConfigErrorKind::NotFound) => message,
(other, expected) => {
panic!(
"for config error {config_err:?}, expected \
ConfigErrorKind::{expected:?} for inner error {other:?}"
);
}
}
},
}
other => {
panic!(
"for config error {other:?}, expected ConfigParseErrorKind::DeserializeError"
Expand Down
2 changes: 1 addition & 1 deletion nextest-runner/src/config/elements/slow_timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ mod tests {
[profile.ci]
slow-timeout = { terminate-after = 3 }
"#},
Err("original: missing field `period`"),
Err("original: missing configuration field \"profile.ci.slow-timeout.period\""),
None

; "partial slow-timeout table should error"
Expand Down
4 changes: 2 additions & 2 deletions nextest-runner/src/config/scripts/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ mod tests {
indoc! {r#"
[scripts.setup.foo]
"#},
"scripts.setup.foo: missing field `command`"
r#"scripts.setup.foo: missing configuration field "scripts.setup.foo.command""#

; "missing command"
)]
Expand All @@ -1227,7 +1227,7 @@ mod tests {
[scripts.setup.foo]
command = { relative-to = "target" }
"#},
"missing field `command-line`"
r#"missing configuration field "scripts.setup.foo.command.command-line""#

; "missing command-line in table"
)]
Expand Down
6 changes: 6 additions & 0 deletions nextest-runner/src/config/utils/test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ pub(in crate::config) struct BinaryQueryCreator<'a> {
platform: BuildPlatform,
}

#[derive(Clone, Copy, Debug)]
pub(in crate::config) enum ConfigErrorKind {
NotFound,
Message,
}

impl BinaryQueryCreator<'_> {
pub(in crate::config) fn to_query(&self) -> BinaryQuery<'_> {
BinaryQuery {
Expand Down
Loading