From 5f876e9f353f95eabdaf244cea38e2ad3fdf3479 Mon Sep 17 00:00:00 2001 From: Yoav Lavi Date: Tue, 19 Apr 2022 11:50:11 +0200 Subject: [PATCH 1/5] Add a caveats section for conditional compilation This section explains the caveats and possible solutions for conditional compilation scenarios, detailing the configuration and tooling needed to properly cover such a project. The need for this PR is based on a [conversation with Eh2406](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/build.20variants/near/278972904) --- src/conditional-compilation.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/conditional-compilation.md b/src/conditional-compilation.md index 6966cec4f..e299b1a90 100644 --- a/src/conditional-compilation.md +++ b/src/conditional-compilation.md @@ -337,6 +337,14 @@ let machine_kind = if cfg!(unix) { println!("I'm running on a {} machine!", machine_kind); ``` +## Caveats + +Conditional compilation, be it features or targets, require an exponential number of configurations and test cases to be properly covered. By default, testing, linting, MIRI, docs and others will only run on the default set of features and for the current platform. + +CI jobs for different targets can help with linting, testing and building on different platforms, and there are certain tools like [cargo-hack](https://github.com/taiki-e/cargo-hack) and [cargo-all-features](https://github.com/frewsxcv/cargo-all-features) that allow you to test all combinations of features which can help reduce the amount of configuraton needed. + +Certain tools, like `rustfmt`, are an exception to this rule. + [IDENTIFIER]: identifiers.md [RAW_STRING_LITERAL]: tokens.md#raw-string-literals [STRING_LITERAL]: tokens.md#string-literals From b0de1931c4f75602de6a257252a34aa211e31e77 Mon Sep 17 00:00:00 2001 From: Yoav Lavi Date: Tue, 19 Apr 2022 11:53:16 +0200 Subject: [PATCH 2/5] Update conditional-compilation.md --- src/conditional-compilation.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/conditional-compilation.md b/src/conditional-compilation.md index e299b1a90..382876464 100644 --- a/src/conditional-compilation.md +++ b/src/conditional-compilation.md @@ -343,8 +343,6 @@ Conditional compilation, be it features or targets, require an exponential numbe CI jobs for different targets can help with linting, testing and building on different platforms, and there are certain tools like [cargo-hack](https://github.com/taiki-e/cargo-hack) and [cargo-all-features](https://github.com/frewsxcv/cargo-all-features) that allow you to test all combinations of features which can help reduce the amount of configuraton needed. -Certain tools, like `rustfmt`, are an exception to this rule. - [IDENTIFIER]: identifiers.md [RAW_STRING_LITERAL]: tokens.md#raw-string-literals [STRING_LITERAL]: tokens.md#string-literals From 595803f503fab39ebba6eef18cdad84d5dcae1f2 Mon Sep 17 00:00:00 2001 From: Yoav Lavi Date: Tue, 19 Apr 2022 13:33:32 +0200 Subject: [PATCH 3/5] Update conditional-compilation.md --- src/conditional-compilation.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/conditional-compilation.md b/src/conditional-compilation.md index 382876464..0e428bd19 100644 --- a/src/conditional-compilation.md +++ b/src/conditional-compilation.md @@ -341,7 +341,9 @@ println!("I'm running on a {} machine!", machine_kind); Conditional compilation, be it features or targets, require an exponential number of configurations and test cases to be properly covered. By default, testing, linting, MIRI, docs and others will only run on the default set of features and for the current platform. -CI jobs for different targets can help with linting, testing and building on different platforms, and there are certain tools like [cargo-hack](https://github.com/taiki-e/cargo-hack) and [cargo-all-features](https://github.com/frewsxcv/cargo-all-features) that allow you to test all combinations of features which can help reduce the amount of configuraton needed. +Having a CI job per target an help with linting, testing and building for all targets. There are also some tools that accept a `--target` flag for cross compilation. + +For feature coverage, there are certain tools like [cargo-hack](https://github.com/taiki-e/cargo-hack) and [cargo-all-features](https://github.com/frewsxcv/cargo-all-features) that allow you to test all combinations of features which can help reduce the amount of configuraton needed. [IDENTIFIER]: identifiers.md [RAW_STRING_LITERAL]: tokens.md#raw-string-literals From b6c994dbd856e8873c1a3e408e29eb8a99412582 Mon Sep 17 00:00:00 2001 From: Yoav Lavi Date: Tue, 19 Apr 2022 13:42:40 +0200 Subject: [PATCH 4/5] Update conditional-compilation.md --- src/conditional-compilation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conditional-compilation.md b/src/conditional-compilation.md index 0e428bd19..a599b09dd 100644 --- a/src/conditional-compilation.md +++ b/src/conditional-compilation.md @@ -341,7 +341,7 @@ println!("I'm running on a {} machine!", machine_kind); Conditional compilation, be it features or targets, require an exponential number of configurations and test cases to be properly covered. By default, testing, linting, MIRI, docs and others will only run on the default set of features and for the current platform. -Having a CI job per target an help with linting, testing and building for all targets. There are also some tools that accept a `--target` flag for cross compilation. +Having a CI job per target can help with linting, testing and building for all targets. There are also some tools that accept a `--target` flag for cross compilation. For feature coverage, there are certain tools like [cargo-hack](https://github.com/taiki-e/cargo-hack) and [cargo-all-features](https://github.com/frewsxcv/cargo-all-features) that allow you to test all combinations of features which can help reduce the amount of configuraton needed. From 22a75b531c6e3521668147f303449cce6776d3f6 Mon Sep 17 00:00:00 2001 From: Yoav Lavi Date: Wed, 20 Apr 2022 15:21:12 +0200 Subject: [PATCH 5/5] Update conditional-compilation.md --- src/conditional-compilation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conditional-compilation.md b/src/conditional-compilation.md index a599b09dd..13d85cfe5 100644 --- a/src/conditional-compilation.md +++ b/src/conditional-compilation.md @@ -339,7 +339,7 @@ println!("I'm running on a {} machine!", machine_kind); ## Caveats -Conditional compilation, be it features or targets, require an exponential number of configurations and test cases to be properly covered. By default, testing, linting, MIRI, docs and others will only run on the default set of features and for the current platform. +Conditional compilation, be it features or targets, require an exponential number of configurations and test cases to be properly covered. By default, testing, linting, Miri, docs and others will only run on the default set of features and for the current platform. Having a CI job per target can help with linting, testing and building for all targets. There are also some tools that accept a `--target` flag for cross compilation.