-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Add special feature for inter-crate safe dev-related code reuse #32169
Conversation
dev-utils
) to avoid accidental test code usage
dev-utils
) to avoid accidental test code usagedev-utils
) to avoid accidental test code usage
dev-utils
) to avoid accidental test code usagedev-utils
to avoid accidental test code usage
dev-utils
to avoid accidental test code usagedev-utils
to avoid test code misuse
dev-utils
to avoid test code misusedev-utils
to avoid test code misuse
dev-utils
to avoid test code misusedev-utils
to avoid test code misuse
dev-utils
to avoid test code misusedev-utils
to avoid test code misuse
Codecov Report
@@ Coverage Diff @@
## master #32169 +/- ##
=========================================
- Coverage 82.0% 82.0% -0.1%
=========================================
Files 770 770
Lines 209236 209236
=========================================
- Hits 171679 171627 -52
- Misses 37557 37609 +52 |
looks like |
hmm, how do you think so? maybe, you saw MSRV at https://crates.io/crates/cargo-hack (currently 1.60)? it's just build dependency of it's released periodically: https://github.com/taiki-e/cargo-hack/releases
i think there's little concern. |
ah yeah, didn't realize that msrv was so prominent on crates.io nowadays. i probably just saw the first version-looking string and went with it 🙃 |
lol... run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm generally supportive of this change for the sake of eliminating test-only logic from crate public apis. in order to fully take advantage, we'll need to replace all instances of cargo {test,check}
with the cargo-hack
-wrapped versions, right?
dev-utils
to avoid test code misusedev-utils
feature for inter-crate test code safe reuse
@t-nelson nope. as this pr introduced another set of |
oookay. I've finally finished up this pr. ready for review. also, I'll create bunch of test prs to test this pr. |
scripts/check-dev-utils.sh
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unexpected from me? lol I've done some dense commenting work. :)
scripts/check-dev-utils.sh
Outdated
# binaries. | ||
# Note also that dev-utils-ci-marker feature must be added and all of its | ||
# dependencies should be edited likewise if any. | ||
declare dev_util_tainted_packages=( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently empty; i'll add some with a follow up pr.
scripts/check-dev-utils.sh
Outdated
|
||
mode=${1:-full} | ||
|
||
if [[ $mode = "tree" || $mode = "full" ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hehe, I added this set of new checks after i drafted this pr.
scripts/check-dev-utils.sh
Outdated
declare dev_util_tainted_packages=( | ||
) | ||
|
||
mode=${1:-full} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the default full
is intended for local development use.
phew, ci abusing time (^o^)/ I've prepared 6 scenarios and all results are expected. (EDIT: these are re-run; see #32169 (comment))
|
well, i spotted a bug and fixed 652df19 good new is that the marker feature is gone. also, i added ci scenarios at #32169 (comment) |
dev-utils
feature for inter-crate test code safe reusedev-utils
feature for inter-crate safe dev-related code reuse
dev-utils
feature for inter-crate safe dev-related code reusedev-utils
feat. for inter-crate safe dev-related code reuse
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, dev-profile implies -Copt-level=0 and etc for me (ref: https://doc.rust-lang.org/cargo/reference/profiles.html#dev). that's not true for benches and cargo test --release (dev-utils could be valid use cases for these)
haha... dammit. i want a general word for this context
oh durr... |
thanks for trying hard to give this baby a proper name. :) but, allow me to defend I wonder the also, as we're recognizing usage of lastly, we have (hopefully) proper ci guard against misuse. |
the main reason i don't believe |
@t-nelson thanks for clarification. I'm persuaded and giving up shorter name: 6e6d189 requesting hopefully final review. :) Also, I'll update the ci scenarios prs shortly after :) (hint: i wonder it can make it to ship this today before US holiday...) |
dev-utils
feat. for inter-crate safe dev-related code reuseThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woot! let's give it a shot
Problem
I'm tired of waiting rust-lang/cargo#8379 being fixed. :)
joking aside, there's so many code in our monorepo, which shouldn't be used in production code, but made
pub
only for the sake of usage in dependent crate's test/bench purposes.when reviewing prs which touch such a method, it's too laborious to verify there's no misuse.
... and our social contract of naming things as
for_test(s)
and be careful in general doesn't work always: #32424also,
#[deprecated]
won't work: the code should still be usable for test code; and sparkling#[allow(deprecated)]
s at each and every call site would be too laborious.Summary of Changes
Use a well-known work around: rust-lang/cargo#8379 (comment)
The caveat is that some special treatment must be taken due to cargo's feature unification. so I added
cargo hack
tricks intest-checks.sh
.the downside is that ci takes longer.... (don't scared of this pr's build time; this is mainly due to unpopulated
target
dir...; usually should take +~5 mins)lastly, this feature makes call-hierarchy-based auditing easier, binaries smaller, and last-not-least, humans lazier. lol
examples of
dev-context-only-utils
usagenew pipeline example
naming is finalized; please open follow up pr if you insist
below is kept for historical reference
fixes: #32170
fixes: #32171
fixes: #32246
fixes: #32247
fixes: #32248
fixes: #32249
fixes: #32344
fixes: #32345