-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a hacky shell for fun code reading (#17503)
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
# rust-analyzer doesn't support hiding noisy test calls in the call hierarchy from tests/benches | ||
# so, here's some wild hack from ryoqun! | ||
|
||
if [[ $1 = "doit" ]]; then | ||
# it's true that we put true just for truely-aligned lines | ||
# shellcheck disable=SC2046 # our rust files are sanely named with no need to escape | ||
true && | ||
sed -i -e 's/#\[cfg(test)\]/#[cfg(escaped-cfg-test)]/g' $(git ls-files :**.rs :^**/build.rs) && | ||
sed -i -e 's/#\[bench\]/#[cfg(escaped-bench)]/g' $(git ls-files :**.rs :^**/build.rs) && | ||
sed -i -e 's/#\[test\]/#[cfg(escaped-test)]/g' $(git ls-files :**.rs :^**/build.rs) && | ||
sed -i -e 's/#\[tokio::test\]/#[cfg(escaped-tokio-test)]/g' $(git ls-files :**.rs :^**/build.rs) | ||
elif [[ $1 = "undoit" ]]; then | ||
# shellcheck disable=SC2046 # our rust files are sanely named with no need to escape | ||
true && | ||
sed -i -e 's/#\[cfg(escaped-cfg-test)\]/#[cfg(test)]/g' $(git ls-files :**.rs :^**/build.rs) && | ||
sed -i -e 's/#\[cfg(escaped-bench)\]/#[bench]/g' $(git ls-files :**.rs :^**/build.rs) && | ||
sed -i -e 's/#\[cfg(escaped-test)\]/#[test]/g' $(git ls-files :**.rs :^**/build.rs) && | ||
sed -i -e 's/#\[cfg(escaped-tokio-test)\]/#[tokio::test]/g' $(git ls-files :**.rs :^**/build.rs) | ||
else | ||
echo "usage: $0 [doit|undoit]" > /dev/stderr | ||
exit 1 | ||
fi |