Skip to content

Commit 02f7264

Browse files
taiki-ecarllerche
authored andcommitted
chore: check each feature works properly (#1695)
It is hard to maintain features list manually, so use cargo-hack's `--each-feature` flag. And cargo-hack provides a workaround for an issue that dev-dependencies leaking into normal build (`--no-dev-deps` flag), so removed own ci tool. Also, compared to running tests on all features, there is not much advantage in running tests on each feature, so only the default features and all features are tested. If the behavior changes depending on the feature, we need to test it as another job in CI.
1 parent 2902e39 commit 02f7264

23 files changed

+77
-286
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@ members = [
99

1010
# Internal
1111
"examples",
12-
"tests-build",
1312
"tests-integration",
1413
]

azure-pipelines.yml

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,8 @@ jobs:
2525
displayName: Test tokio
2626
cross: true
2727
crates:
28-
tokio:
29-
- fs
30-
- io
31-
- io-util
32-
- net-driver
33-
- process
34-
- rt-full
35-
- signal
36-
- sync
37-
- tcp
38-
- timer
39-
- udp
40-
- uds
41-
tests-integration: []
28+
- tokio
29+
- tests-integration
4230

4331
# Test crates that are NOT platform specific
4432
- template: ci/azure-test-stable.yml
@@ -47,29 +35,10 @@ jobs:
4735
displayName: Test sub crates -
4836
rust: beta
4937
crates:
50-
tokio-macros: []
51-
tokio-test: []
52-
tokio-util: []
53-
examples: []
54-
55-
# Test compilation failure
56-
# Disable pending: https://github.com/tokio-rs/tokio/pull/1695#issuecomment-547045383
57-
# - template: ci/azure-test-stable.yml
58-
# parameters:
59-
# name: test_features
60-
# displayName: Test feature flags
61-
# rust: beta
62-
# crates:
63-
# tests-build:
64-
# # - tokio-executor
65-
# # - executor-without-current-thread
66-
# # - macros-invalid-input
67-
# # - net-no-features
68-
# # - net-with-tcp
69-
# # - net-with-udp
70-
# # - net-with-uds
71-
# # - tokio-no-features
72-
# # - tokio-with-net
38+
- tokio-macros
39+
- tokio-test
40+
- tokio-util
41+
- examples
7342

7443
# Run loom tests
7544
- template: ci/azure-loom.yml

ci/azure-test-stable.yml

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ jobs:
2020
# rust_version: stable
2121
rust_version: ${{ parameters.rust }}
2222

23+
- script: cargo install cargo-hack
24+
displayName: Install cargo-hack
25+
# FIXME(taiki-e): many features of current cargo-hack are not available on windows: https://github.com/taiki-e/cargo-hack/issues/3
26+
condition: not(eq(variables['Agent.OS'], 'Windows_NT'))
27+
2328
- template: azure-is-release.yml
2429

2530
- ${{ each crate in parameters.crates }}:
@@ -28,17 +33,28 @@ jobs:
2833
env:
2934
LOOM_MAX_PREEMPTIONS: 2
3035
CI: 'True'
31-
displayName: ${{ crate.key }} - cargo test
32-
workingDirectory: $(Build.SourcesDirectory)/${{ crate.key }}
33-
34-
# Run with each specified feature
35-
- ${{ each feature in crate.value }}:
36-
- script: cargo test --no-default-features --features ${{ feature }}
37-
env:
38-
LOOM_MAX_PREEMPTIONS: 2
39-
CI: 'True'
40-
displayName: ${{ crate.key }} - cargo test --features ${{ feature }}
41-
workingDirectory: $(Build.SourcesDirectory)/${{ crate.key }}
36+
displayName: ${{ crate }} - cargo test
37+
workingDirectory: $(Build.SourcesDirectory)/${{ crate }}
38+
39+
# Run with all crate features
40+
- script: cargo test --all-features
41+
env:
42+
LOOM_MAX_PREEMPTIONS: 2
43+
CI: 'True'
44+
displayName: ${{ crate }} - cargo test --all-features
45+
workingDirectory: $(Build.SourcesDirectory)/${{ crate }}
46+
47+
# Check each specified feature works properly
48+
# * --each-feature - run for each feature which includes --no-default-features and default features of package
49+
# * --no-dev-deps - build without dev-dependencies to avoid https://github.com/rust-lang/cargo/issues/4866
50+
- script: cargo hack check --each-feature --no-dev-deps
51+
env:
52+
LOOM_MAX_PREEMPTIONS: 2
53+
CI: 'True'
54+
displayName: ${{ crate }} - cargo hack check --each-feature
55+
workingDirectory: $(Build.SourcesDirectory)/${{ crate }}
56+
# FIXME(taiki-e): many features of current cargo-hack are not available on windows: https://github.com/taiki-e/cargo-hack/issues/3
57+
condition: not(eq(variables['Agent.OS'], 'Windows_NT'))
4258

4359
- template: azure-patch-crates.yml
4460

@@ -48,14 +64,25 @@ jobs:
4864
env:
4965
LOOM_MAX_PREEMPTIONS: 2
5066
CI: 'True'
51-
displayName: ${{ crate.key }} - cargo test
52-
workingDirectory: $(Build.SourcesDirectory)/${{ crate.key }}
53-
54-
# Run with each specified feature
55-
- ${{ each feature in crate.value }}:
56-
- script: cargo test --no-default-features --features ${{ feature }}
57-
env:
58-
LOOM_MAX_PREEMPTIONS: 2
59-
CI: 'True'
60-
displayName: ${{ crate.key }} - cargo test --features ${{ feature }}
61-
workingDirectory: $(Build.SourcesDirectory)/${{ crate.key }}
67+
displayName: ${{ crate }} - cargo test
68+
workingDirectory: $(Build.SourcesDirectory)/${{ crate }}
69+
70+
# Run with all crate features
71+
- script: cargo test --all-features
72+
env:
73+
LOOM_MAX_PREEMPTIONS: 2
74+
CI: 'True'
75+
displayName: ${{ crate }} - cargo test --all-features
76+
workingDirectory: $(Build.SourcesDirectory)/${{ crate }}
77+
78+
# Check each specified feature works properly
79+
# * --each-feature - run for each feature which includes --no-default-features and default features of package
80+
# * --no-dev-deps - build without dev-dependencies to avoid https://github.com/rust-lang/cargo/issues/4866
81+
- script: cargo hack check --each-feature --no-dev-deps
82+
env:
83+
LOOM_MAX_PREEMPTIONS: 2
84+
CI: 'True'
85+
displayName: ${{ crate }} - cargo hack check --each-feature
86+
workingDirectory: $(Build.SourcesDirectory)/${{ crate }}
87+
# FIXME(taiki-e): many features of current cargo-hack are not available on windows: https://github.com/taiki-e/cargo-hack/issues/3
88+
condition: not(eq(variables['Agent.OS'], 'Windows_NT'))

tests-build/Cargo.toml

Lines changed: 0 additions & 25 deletions
This file was deleted.

tests-build/README.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests-build/src/lib.rs

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests-build/tests/fail/executor_without_current_thread.rs

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests-build/tests/fail/executor_without_current_thread.stderr

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests-build/tests/fail/macros_invalid_input.rs

Lines changed: 0 additions & 25 deletions
This file was deleted.

tests-build/tests/fail/macros_invalid_input.stderr

Lines changed: 0 additions & 41 deletions
This file was deleted.

tests-build/tests/fail/net_without_tcp_missing_tcp.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests-build/tests/fail/net_without_tcp_missing_tcp.stderr

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests-build/tests/fail/net_without_udp_missing_udp.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests-build/tests/fail/net_without_udp_missing_udp.stderr

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests-build/tests/fail/net_without_uds_missing_uds.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests-build/tests/fail/net_without_uds_missing_uds.stderr

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests-build/tests/fail/tokio_without_net_missing_net.rs

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests-build/tests/fail/tokio_without_net_missing_net.stderr

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests-build/tests/features.rs

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)