Skip to content

Commit 91fbab6

Browse files
committed
Use serial_test when using HOST_OPTIONS.scoped_options
Add a suggestion to the docs to use this. It can help prevent tests from conflicting with each other if they modify HOST_OPTIONS.
1 parent 3e5577b commit 91fbab6

File tree

6 files changed

+11
-3
lines changed

6 files changed

+11
-3
lines changed

Cargo.lock

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

crates/spk-cli/cmd-build/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ spk-cmd-make-source = { workspace = true }
3030

3131
[dev-dependencies]
3232
rstest = { workspace = true }
33+
serial_test = { workspace = true }
3334
spk-schema = { workspace = true }
3435
spk-storage = { workspace = true }
3536
tempfile = { workspace = true }

crates/spk-cli/cmd-build/src/cmd_build_test/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,7 @@ build:
611611
// this case passes because host options override default values, and the
612612
// provided host option value of "linux" is a valid choice.
613613
#[case::non_empty_value_for_host_option_bad_value_succeeds_with_host_options_enabled("os", "beos", &["linux", "windows"], true)]
614+
#[serial_test::serial(host_options)]
614615
#[tokio::test]
615616
async fn test_options_with_choices_and_empty_values(
616617
tmpdir: tempfile::TempDir,

crates/spk-cli/cmd-build/src/cmd_build_test/variant_filter.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ build:
661661
}
662662

663663
#[rstest]
664+
#[serial_test::serial(host_options)]
664665
#[tokio::test]
665666
async fn test_build_filters_variants_based_on_host_opts(tmpdir: tempfile::TempDir) {
666667
let _rt = spfs_runtime().await;

crates/spk-schema/crates/foundation/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ ring = { workspace = true }
4242
rstest = { workspace = true }
4343
serde = { workspace = true, features = ["derive"] }
4444
serde_yaml = { workspace = true }
45+
serial_test = { workspace = true }
4546
spfs = { workspace = true }
4647
strum = { workspace = true, features = ["derive"] }
4748
sys-info = "0.9.0"

crates/spk-schema/crates/foundation/src/option_map/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,12 @@ impl HostOptions {
101101
/// Change [`HOST_OPTIONS`] to return the provided substitute options for
102102
/// the duration of the given future.
103103
///
104-
/// There is no guarantee that some other concurrent task doesn't also
105-
/// change the options before the given future completes.
106-
///
107104
/// This method is intended to only be used by tests.
105+
///
106+
/// There is no guarantee that some other concurrent task doesn't also
107+
/// change the options before the given future completes. It is recommended
108+
/// to use [`serial_test::serial`] and include the key "host_options" when
109+
/// using this function.
108110
pub async fn scoped_options<T>(
109111
&self,
110112
substitute_host_options: Result<OptionMap>,

0 commit comments

Comments
 (0)