Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit 6e6d189

Browse files
committed
Rename to dev-context-only-utils
1 parent fd2d6cf commit 6e6d189

5 files changed

+43
-39
lines changed

ci/buildkite-pipeline.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ wait_step() {
141141

142142
all_test_steps() {
143143
command_step checks1 ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_nightly_docker_image ci/test-checks.sh" 20 check
144-
command_step checks2 ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_nightly_docker_image ci/test-dev-utils.sh check-bins" 15 check
145-
command_step checks3 ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_nightly_docker_image ci/test-dev-utils.sh check-all-targets" 15 check
144+
command_step checks2 ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_nightly_docker_image ci/test-dev-context-only-utils.sh check-bins" 15 check
145+
command_step checks3 ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_nightly_docker_image ci/test-dev-context-only-utils.sh check-all-targets" 15 check
146146
wait_step
147147

148148
# Full test suite

ci/test-checks.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ else
112112
_ scripts/cargo-for-all-lock-files.sh -- "+${rust_nightly}" sort --workspace --check
113113
fi
114114

115-
_ scripts/check-dev-utils.sh tree
115+
_ scripts/check-dev-context-only-utils.sh tree
116116

117117
_ scripts/cargo-for-all-lock-files.sh -- "+${rust_nightly}" fmt --all -- --check
118118

ci/test-dev-context-only-utils.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
set -eo pipefail
4+
5+
scripts/check-dev-context-only-utils.sh "$@"

ci/test-dev-utils.sh

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

scripts/check-dev-utils.sh renamed to scripts/check-dev-context-only-utils.sh

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,32 @@ source ci/_
77
# (benches, frozen abi...)
88
source ci/rust-version.sh nightly
99

10-
# There's a special common feature called `dev-utils` to
10+
# There's a special common feature called `dev-context-only-utils` to
1111
# overcome cargo's issue: https://github.com/rust-lang/cargo/issues/8379
1212
# This feature is like `cfg(test)`, which works between crates.
1313
#
1414
# Unfortunately, this in turn needs some special checks to avoid common
15-
# pitfalls of `dev-utils` itself.
15+
# pitfalls of `dev-context-only-utils` itself.
1616
#
17-
# Firstly, detect any misuse of dev-utils as normal/build dependencies.
18-
# Also, allow some exceptions for special purpose crates. This white-listing
19-
# mechanism can be used for core-development-oriented crates like bench bins.
17+
# Firstly, detect any misuse of dev-context-only-utils as normal/build
18+
# dependencies. Also, allow some exceptions for special purpose crates. This
19+
# white-listing mechanism can be used for core-development-oriented crates like
20+
# bench bins.
2021
#
21-
# Put differently, use of dev-utils is forbidden for non-dev dependencies in
22-
# general. However, allow its use for non-dev dependencies only if its use
23-
# is confined under a dep. subgraph with all nodes being marked as dev-utils.
22+
# Put differently, use of dev-context-only-utils is forbidden for non-dev
23+
# dependencies in general. However, allow its use for non-dev dependencies only
24+
# if its use is confined under a dep. subgraph with all nodes being marked as
25+
# dev-context-only-utils.
2426

25-
# Add your troubled package which seems to want to use `dev-utils` as normal (not
26-
# dev) dependencies, only if you're sure that there's good reason to bend
27-
# dev-util's original intention and that listed package isn't part of released
28-
# binaries.
29-
declare -r dev_utils_feature="dev-utils"
30-
declare dev_util_tainted_packages=(
27+
# Add your troubled package which seems to want to use `dev-context-only-utils`
28+
# as normal (not dev) dependencies, only if you're sure that there's good
29+
# reason to bend dev-context-only-utils's original intention and that listed
30+
# package isn't part of released binaries.
31+
declare tainted_packages=(
3132
)
3233

3334
# convert to comma separeted (ref: https://stackoverflow.com/a/53839433)
34-
printf -v allowed '"%s",' "${dev_util_tainted_packages[@]}"
35+
printf -v allowed '"%s",' "${tainted_packages[@]}"
3536
allowed="${allowed%,}"
3637

3738
mode=${1:-full}
@@ -60,7 +61,7 @@ if [[ $mode = "tree" || $mode = "full" ]]; then
6061
| flatten
6162
| map(select(
6263
(.dependencyFeatures
63-
| index("${dev_utils_feature}")
64+
| index("dev-context-only-utils")
6465
) and (.crate as \$needle
6566
| ([$allowed] | index(\$needle))
6667
| not
@@ -71,10 +72,11 @@ if [[ $mode = "tree" || $mode = "full" ]]; then
7172
EOF
7273
)
7374

74-
abusers="$(_ cargo "+${rust_nightly}" metadata --format-version=1 | jq -r "$query")"
75+
abusers="$(_ cargo "+${rust_nightly}" metadata --format-version=1 |
76+
jq -r "$query")"
7577
if [[ -n "$abusers" ]]; then
7678
cat <<EOF 1>&2
77-
${dev_utils_feature} must not be used as normal dependencies, but is by \
79+
\`dev-context-only-utils\' must not be used as normal dependencies, but is by \
7880
"([crate]: [dependency])":
7981
$abusers
8082
EOF
@@ -106,7 +108,7 @@ EOF
106108
end)
107109
| flatten
108110
| map(select(
109-
(.crateFeatures | index("${dev_utils_feature}")) | not
111+
(.crateFeatures | index("dev-context-only-utils")) | not
110112
))
111113
| map(.crate)
112114
| join("\n ")
@@ -121,25 +123,27 @@ EOF
121123
if [[ -n "$misconfigured_crates" ]]; then
122124
cat <<EOF 1>&2
123125
All crates marked \`tainted\`, as well as their dependents, MUST declare the \
124-
\`$dev_utils_feature\`. The following crates are in violation:
126+
\`dev-context-only-utils\`. The following crates are in violation:
125127
$misconfigured_crates
126128
EOF
127129
exit 1
128130
fi
129131
fi
130132

131-
# Detect possible compilation errors of problematic usage of `dev-utils`-gated code
132-
# without being explicitly declared as such in respective workspace member
133-
# `Cargo.toml`s. This cannot be detected with `--workspace --all-targets`, due
134-
# to unintentional `dev-utils` feature activation by cargo's feature
135-
# unification mechanism.
136-
# So, we use `cargo hack` to exhaustively build each individual workspace
137-
# members in isolation to work around.
133+
# Detect possible compilation errors of problematic usage of
134+
# `dev-context-only-utils`-gated code without being explicitly declared as such
135+
# in respective workspace member `Cargo.toml`s. This cannot be detected with
136+
# `--workspace --all-targets`, due to unintentional `dev-context-only-utils`
137+
# feature activation by cargo's feature unification mechanism. So, we use
138+
# `cargo hack` to exhaustively build each individual workspace members in
139+
# isolation to work around.
138140
#
139-
# 1. Check implicit usage of `dev-utils`-gated code in non-dev (= production) code by
140-
# building without dev dependencies (= tests/benches) for each crate
141-
# 2. Check implicit usage of `dev-utils`-gated code in dev (= test/benches) code by
142-
# building in isolation from other crates, which might happen to enable `dev-utils`
141+
# 1. Check implicit usage of `dev-context-only-utils`-gated code in non-dev (=
142+
# production) code by building without dev dependencies (= tests/benches) for
143+
# each crate
144+
# 2. Check implicit usage of `dev-context-only-utils`-gated code in dev (=
145+
# test/benches) code by building in isolation from other crates, which might
146+
# happen to enable `dev-context-only-utils`
143147
if [[ $mode = "check-bins" || $mode = "full" ]]; then
144148
_ cargo "+${rust_nightly}" hack check --bins
145149
fi

0 commit comments

Comments
 (0)