Skip to content

Commit 9c638ea

Browse files
authored
Merge pull request #362 from ehuss/cbr-hyphen-space
Make `cargo-bisect-rustc` work with hyphen or space
2 parents b351a7d + bf0b33c commit 9c638ea

File tree

4 files changed

+183
-27
lines changed

4 files changed

+183
-27
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ jobs:
3131
- name: Verify that binary works
3232
run: |
3333
cargo run -- bisect-rustc --help | grep "Examples:"
34-
cargo run -- --help | grep "Commands:"
3534
3635
fmt:
3736
name: rustfmt

src/main.rs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,6 @@ const REPORT_HEADER: &str = "\
6969
= Copy and paste the text below into the issue report thread. Thanks! =
7070
==================================================================================";
7171

72-
#[derive(Debug, Parser)]
73-
#[command(bin_name = "cargo", subcommand_required = true)]
74-
enum Cargo {
75-
BisectRustc(Opts),
76-
}
77-
7872
#[derive(Debug, Parser)]
7973
#[command(
8074
bin_name = "cargo bisect-rustc",
@@ -397,16 +391,15 @@ impl Config {
397391
// Application entry point
398392
fn run() -> anyhow::Result<()> {
399393
env_logger::try_init()?;
400-
let args = match Cargo::try_parse() {
401-
Ok(Cargo::BisectRustc(args)) => args,
402-
Err(e) => match e.context().next() {
403-
None => {
404-
Cargo::parse();
405-
unreachable!()
406-
}
407-
_ => Opts::parse(),
408-
},
409-
};
394+
let mut os_args: Vec<_> = std::env::args_os().collect();
395+
// This allows both `cargo-bisect-rustc` (with a hyphen) and
396+
// `cargo bisect-rustc` (with a space) to work identically.
397+
if let Some(command) = os_args.get(1) {
398+
if command == "bisect-rustc" {
399+
os_args.remove(1);
400+
}
401+
}
402+
let args = Opts::parse_from(os_args);
410403
let cfg = Config::from_args(args)?;
411404

412405
if let Some(ref bound) = cfg.args.install {

tests/cmd/bare-h.stdout

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,50 @@
1-
Usage: cargo <COMMAND>
1+
Bisects rustc toolchains with rustup
22

3-
Commands:
4-
bisect-rustc Bisects rustc toolchains with rustup
5-
help Print this message or the help of the given subcommand(s)
3+
Usage: cargo bisect-rustc [OPTIONS] [-- <COMMAND_ARGS>...]
4+
5+
Arguments:
6+
[COMMAND_ARGS]... Arguments to pass to cargo or the file specified by --script during tests
67

78
Options:
8-
-h, --help Print help
9+
-a, --alt Download the alt build instead of normal build
10+
--access <ACCESS> How to access Rust git repository [default: github] [possible
11+
values: checkout, github]
12+
--by-commit Bisect via commit artifacts
13+
-c, --component <COMPONENTS> additional components to install
14+
--end <END> Right bound for search (*with* regression). You can use a date
15+
(YYYY-MM-DD), git tag name (e.g. 1.58.0) or git commit SHA.
16+
--force-install Force installation over existing artifacts
17+
-h, --help Print help (see more with '--help')
18+
--host <HOST> Host triple for the compiler [default: [..]]
19+
--install <INSTALL> Install the given artifact
20+
--preserve Preserve the downloaded artifacts
21+
--preserve-target Preserve the target directory used for builds
22+
--prompt Manually evaluate for regression with prompts
23+
--regress <REGRESS> Custom regression definition [default: error] [possible values:
24+
error, success, ice, non-ice, non-error]
25+
--script <SCRIPT> Script replacement for `cargo build` command
26+
--start <START> Left bound for search (*without* regression). You can use a date
27+
(YYYY-MM-DD), git tag name (e.g. 1.58.0) or git commit SHA.
28+
-t, --timeout <TIMEOUT> Assume failure after specified number of seconds (for bisecting
29+
hangs)
30+
--target <TARGET> Cross-compilation target platform
31+
--term-new <TERM_NEW> Text shown when a test does match the condition requested
32+
--term-old <TERM_OLD> Text shown when a test fails to match the condition requested
33+
--test-dir <TEST_DIR> Root directory for tests [default: .]
34+
-v, --verbose...
35+
-V, --version Print version
36+
--with-dev Download rustc-dev [default: no download]
37+
--with-src Download rust-src [default: no download]
38+
--without-cargo Do not install cargo [default: install cargo]
39+
40+
Examples:
41+
Run a fully automatic nightly bisect doing `cargo check`:
42+
```
43+
cargo bisect-rustc --start 2018-07-07 --end 2018-07-30 --test-dir ../my_project/ -- check
44+
```
45+
46+
Run a PR-based bisect with manual prompts after each run doing `cargo build`:
47+
```
48+
cargo bisect-rustc --start 6a1c0637ce44aeea6c60527f4c0e7fb33f2bcd0d /
49+
--end 866a713258915e6cbb212d135f751a6a8c9e1c0a --test-dir ../my_project/ --prompt -- build
50+
```

tests/cmd/bare-help.stdout

Lines changed: 127 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,130 @@
1-
Usage: cargo <COMMAND>
1+
Bisects rustc toolchains with rustup
22

3-
Commands:
4-
bisect-rustc Bisects rustc toolchains with rustup
5-
help Print this message or the help of the given subcommand(s)
3+
Usage: cargo bisect-rustc [OPTIONS] [-- <COMMAND_ARGS>...]
4+
5+
Arguments:
6+
[COMMAND_ARGS]...
7+
Arguments to pass to cargo or the file specified by --script during tests
68

79
Options:
8-
-h, --help Print help
10+
-a, --alt
11+
Download the alt build instead of normal build
12+
13+
--access <ACCESS>
14+
How to access Rust git repository
15+
16+
[default: github]
17+
[possible values: checkout, github]
18+
19+
--by-commit
20+
Bisect via commit artifacts
21+
22+
-c, --component <COMPONENTS>
23+
additional components to install
24+
25+
--end <END>
26+
Right bound for search (*with* regression). You can use a date (YYYY-MM-DD), git tag name
27+
(e.g. 1.58.0) or git commit SHA.
28+
29+
--force-install
30+
Force installation over existing artifacts
31+
32+
-h, --help
33+
Print help (see a summary with '-h')
34+
35+
--host <HOST>
36+
Host triple for the compiler
37+
38+
[default: [..]]
39+
40+
--install <INSTALL>
41+
Install the given artifact
42+
43+
--preserve
44+
Preserve the downloaded artifacts
45+
46+
--preserve-target
47+
Preserve the target directory used for builds
48+
49+
--prompt
50+
Manually evaluate for regression with prompts
51+
52+
--regress <REGRESS>
53+
Custom regression definition
54+
55+
[default: error]
56+
57+
Possible values:
58+
- error: Marks test outcome as `Regressed` if and only if the `rustc` process reports
59+
a non-success status. This corresponds to when `rustc` has an internal compiler error
60+
(ICE) or when it detects an error in the input program. This covers the most common use
61+
case for `cargo-bisect-rustc` and is thus the default setting
62+
- success: Marks test outcome as `Regressed` if and only if the `rustc` process reports
63+
a success status. This corresponds to when `rustc` believes it has successfully compiled
64+
the program. This covers the use case for when you want to bisect to see when a bug was
65+
fixed
66+
- ice: Marks test outcome as `Regressed` if and only if the `rustc` process issues a
67+
diagnostic indicating that an internal compiler error (ICE) occurred. This covers the
68+
use case for when you want to bisect to see when an ICE was introduced on a codebase
69+
that is meant to produce a clean error
70+
- non-ice: Marks test outcome as `Regressed` if and only if the `rustc` process does not
71+
issue a diagnostic indicating that an internal compiler error (ICE) occurred. This
72+
covers the use case for when you want to bisect to see when an ICE was fixed
73+
- non-error: Marks test outcome as `Baseline` if and only if the `rustc` process reports
74+
error status and does not issue any diagnostic indicating that an internal compiler
75+
error (ICE) occurred. This is the use case if the regression is a case where an
76+
ill-formed program has stopped being properly rejected by the compiler. (The main
77+
difference between this case and `success` is the handling of ICE: `success` assumes
78+
that ICE should be considered baseline; `non-error` assumes ICE should be considered a
79+
sign of a regression.)
80+
81+
--script <SCRIPT>
82+
Script replacement for `cargo build` command
83+
84+
--start <START>
85+
Left bound for search (*without* regression). You can use a date (YYYY-MM-DD), git tag
86+
name (e.g. 1.58.0) or git commit SHA.
87+
88+
-t, --timeout <TIMEOUT>
89+
Assume failure after specified number of seconds (for bisecting hangs)
90+
91+
--target <TARGET>
92+
Cross-compilation target platform
93+
94+
--term-new <TERM_NEW>
95+
Text shown when a test does match the condition requested
96+
97+
--term-old <TERM_OLD>
98+
Text shown when a test fails to match the condition requested
99+
100+
--test-dir <TEST_DIR>
101+
Root directory for tests
102+
103+
[default: .]
104+
105+
-v, --verbose...
106+
107+
108+
-V, --version
109+
Print version
110+
111+
--with-dev
112+
Download rustc-dev [default: no download]
113+
114+
--with-src
115+
Download rust-src [default: no download]
116+
117+
--without-cargo
118+
Do not install cargo [default: install cargo]
119+
120+
Examples:
121+
Run a fully automatic nightly bisect doing `cargo check`:
122+
```
123+
cargo bisect-rustc --start 2018-07-07 --end 2018-07-30 --test-dir ../my_project/ -- check
124+
```
125+
126+
Run a PR-based bisect with manual prompts after each run doing `cargo build`:
127+
```
128+
cargo bisect-rustc --start 6a1c0637ce44aeea6c60527f4c0e7fb33f2bcd0d /
129+
--end 866a713258915e6cbb212d135f751a6a8c9e1c0a --test-dir ../my_project/ --prompt -- build
130+
```

0 commit comments

Comments
 (0)