diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index b8959b991f..8f71f3146f 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -213,6 +213,8 @@ jobs: run: cargo clippy -p test_readme - name: Clippy test_registry run: cargo clippy -p test_registry + - name: Clippy test_registry_default + run: cargo clippy -p test_registry_default - name: Clippy test_reserved run: cargo clippy -p test_reserved - name: Clippy test_resources diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fe68bd00f3..05af0e6b74 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -239,6 +239,8 @@ jobs: run: cargo test -p test_readme --target ${{ matrix.target }} ${{ matrix.etc }} - name: Test test_registry run: cargo test -p test_registry --target ${{ matrix.target }} ${{ matrix.etc }} + - name: Test test_registry_default + run: cargo test -p test_registry_default --target ${{ matrix.target }} ${{ matrix.etc }} - name: Test test_reserved run: cargo test -p test_reserved --target ${{ matrix.target }} ${{ matrix.etc }} - name: Test test_resources @@ -253,10 +255,10 @@ jobs: run: cargo test -p test_riddle --target ${{ matrix.target }} ${{ matrix.etc }} - name: Test test_standalone run: cargo test -p test_standalone --target ${{ matrix.target }} ${{ matrix.etc }} - - name: Test test_string_param - run: cargo test -p test_string_param --target ${{ matrix.target }} ${{ matrix.etc }} - name: Clean run: cargo clean + - name: Test test_string_param + run: cargo test -p test_string_param --target ${{ matrix.target }} ${{ matrix.etc }} - name: Test test_strings run: cargo test -p test_strings --target ${{ matrix.target }} ${{ matrix.etc }} - name: Test test_structs diff --git a/crates/libs/registry/Cargo.toml b/crates/libs/registry/Cargo.toml index eea2b849f3..1a064ab1cd 100644 --- a/crates/libs/registry/Cargo.toml +++ b/crates/libs/registry/Cargo.toml @@ -30,3 +30,7 @@ default-features = false version = "0.1.0" path = "../strings" default-features = false + +[features] +default = ["std"] +std = ["windows-result/std", "windows-strings/std"] diff --git a/crates/tests/registry_default/Cargo.toml b/crates/tests/registry_default/Cargo.toml new file mode 100644 index 0000000000..141fa4956a --- /dev/null +++ b/crates/tests/registry_default/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "test_registry_default" +version = "0.0.0" +edition = "2021" +publish = false + +[lib] +doc = false +doctest = false + +[dependencies.windows-registry] +path = "../../libs/registry" diff --git a/crates/tests/registry_default/src/lib.rs b/crates/tests/registry_default/src/lib.rs new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/crates/tests/registry_default/src/lib.rs @@ -0,0 +1 @@ + diff --git a/crates/tests/registry_default/tests/test.rs b/crates/tests/registry_default/tests/test.rs new file mode 100644 index 0000000000..2216cdac25 --- /dev/null +++ b/crates/tests/registry_default/tests/test.rs @@ -0,0 +1,21 @@ +// This just confirms that the default feature "std" for the `windows-registry` crate also enables the +// default feature "std" for both the `windows-result` and `windows-strings` dependencies. +// +// `Box` requires "std" feature for the `windows-result` crate. +#[test] +fn test() -> Result<(), Box> { + let test_key = "software\\windows-rs\\tests\\default"; + _ = windows_registry::CURRENT_USER.remove_tree(test_key); + let key = windows_registry::CURRENT_USER.create(test_key)?; + + key.set_u32("u32", 123u32)?; + assert_eq!(key.get_u32("u32")?, 123u32); + + // `to_os_string` requires the "std" feature for the `windows-strings` crate. + assert_eq!( + windows_registry::HSTRING::from("value").to_os_string(), + "value" + ); + + Ok(()) +}