-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add experimental --bisect
option
#170
Conversation
62ccace
to
edbd3de
Compare
const SCRIPT: &str = r#"#! /bin/bash | ||
|
||
set -euo pipefail | ||
|
||
CHANNEL="$(echo "$RUSTUP_TOOLCHAIN" | sed -n 's/^bisector-\(nightly-[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}\)-.*$/\1/;T;p')" | ||
|
||
unset RUSTUP_TOOLCHAIN | ||
|
||
if [[ -z "$CHANNEL" ]]; then | ||
if [[ ! -f first_commit_seen ]]; then | ||
touch first_commit_seen | ||
exit 1 | ||
else | ||
exit 0 | ||
fi | ||
fi | ||
|
||
# smoelius: The rust-toolchain file should reflect the most recent successful build. So if the | ||
# current build fails, restore the rust-toolchain file's previous contents. | ||
TMP="$(mktemp -p . -t rust-toolchain.XXXXXXXXXX)" | ||
cp rust-toolchain "$TMP" | ||
trap ' | ||
STATUS="$?" | ||
if [[ "$STATUS" -eq 0 ]]; then | ||
rm "$TMP" | ||
else | ||
mv "$TMP" rust-toolchain | ||
fi | ||
exit "$STATUS" | ||
' EXIT | ||
|
||
sed -i "s/^channel = \"[^\"]*\"$/channel = \"$CHANNEL\"/" rust-toolchain | ||
|
||
if [[ ! -f first_channel_seen ]]; then | ||
cargo build --tests || (touch first_channel_seen && false) | ||
elif [[ ! -f successful_build_seen ]]; then | ||
# smoelius: Pretend the build succeeds (even if it doesn't) and proceed backwards until we find | ||
# one that actually succeeds. | ||
(cargo build --tests && touch successful_build_seen) || true | ||
else | ||
cargo build --tests | ||
fi | ||
"#; |
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.
An easy way to make this cross-platform like this is something like https://github.com/matklad/xshell/, which has mostly the same syntax as shell, but uses Command::new
under the hood and doesn't depend on a specific shell.
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.
Oh, I just saw you're passing the path to the script as an argument to some tool - maybe you could do that with xshell by adding a second binary and passing its path? something like src/bin/bisect.rs
and then cargo install
would install it alongside cargo-dylint.
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 think I like this idea.
However, given that the script mostly works and I have other priorities (cough), I will likely merge this as-is and make implementing your suggestion a TODO item.
Thanks, BTW.
No description provided.