|
1 | 1 | //! CI script used for Bevy.
|
2 | 2 |
|
3 | 3 | use bitflags::bitflags;
|
4 |
| -use core::panic; |
5 | 4 | use std::collections::BTreeMap;
|
6 | 5 | use xshell::{cmd, Cmd, Shell};
|
7 | 6 |
|
8 | 7 | bitflags! {
|
| 8 | + /// A collection of individual checks that can be run in CI. |
9 | 9 | #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
10 | 10 | struct Check: u32 {
|
11 |
| - const FORMAT = 0b00000001; |
12 |
| - const CLIPPY = 0b00000010; |
13 |
| - const COMPILE_FAIL = 0b00000100; |
14 |
| - const TEST = 0b00001000; |
15 |
| - const DOC_TEST = 0b00010000; |
16 |
| - const DOC_CHECK = 0b00100000; |
17 |
| - const BENCH_CHECK = 0b01000000; |
18 |
| - const EXAMPLE_CHECK = 0b10000000; |
19 |
| - const COMPILE_CHECK = 0b100000000; |
20 |
| - const CFG_CHECK = 0b1000000000; |
21 |
| - const TEST_CHECK = 0b10000000000; |
| 11 | + const FORMAT = 1 << 0; |
| 12 | + const CLIPPY = 1 << 1; |
| 13 | + const COMPILE_FAIL = 1 << 2; |
| 14 | + const TEST = 1 << 3; |
| 15 | + const DOC_TEST = 1 << 4; |
| 16 | + const DOC_CHECK = 1 << 5; |
| 17 | + const BENCH_CHECK = 1 << 6; |
| 18 | + const EXAMPLE_CHECK = 1 << 7; |
| 19 | + const COMPILE_CHECK = 1 << 8; |
| 20 | + const CFG_CHECK = 1 << 9; |
| 21 | + const TEST_CHECK = 1 << 10; |
22 | 22 | }
|
23 |
| -} |
24 | 23 |
|
25 |
| -bitflags! { |
| 24 | + /// A collection of flags that can modify how checks are run. |
26 | 25 | #[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
27 | 26 | struct Flag: u32 {
|
28 |
| - const KEEP_GOING = 0b00000001; |
| 27 | + /// Forces certain checks to continue running even if they hit an error. |
| 28 | + const KEEP_GOING = 1 << 0; |
29 | 29 | }
|
30 | 30 | }
|
31 | 31 |
|
@@ -80,27 +80,30 @@ fn main() {
|
80 | 80 | // the executable, so it is ignored. Any parameter may either be a flag or the name of a battery of tests
|
81 | 81 | // to include.
|
82 | 82 | let (mut checks, mut flags) = (Check::empty(), Flag::empty());
|
| 83 | + |
| 84 | + // Skip first argument, which is usually the path of the executable. |
83 | 85 | for arg in std::env::args().skip(1) {
|
84 |
| - if let Some((_, flag)) = flag_arguments.iter().find(|(flag_arg, _)| *flag_arg == arg) { |
85 |
| - flags.insert(*flag); |
86 |
| - continue; |
87 |
| - } |
88 | 86 | if let Some((_, check)) = arguments.iter().find(|(check_arg, _)| *check_arg == arg) {
|
89 | 87 | // Note that this actually adds all of the constituent checks to the test suite.
|
90 | 88 | checks.insert(*check);
|
91 |
| - continue; |
| 89 | + } else if let Some((_, flag)) = flag_arguments.iter().find(|(flag_arg, _)| *flag_arg == arg) |
| 90 | + { |
| 91 | + flags.insert(*flag); |
| 92 | + } else { |
| 93 | + // We encountered an invalid parameter: |
| 94 | + eprintln!( |
| 95 | + "Invalid argument: {arg:?}.\n\ |
| 96 | + Valid parameters: {}.", |
| 97 | + // Skip first argument so it can be added in fold(), when displaying as a comma separated list. |
| 98 | + arguments[1..] |
| 99 | + .iter() |
| 100 | + .map(|(s, _)| s) |
| 101 | + .chain(flag_arguments.iter().map(|(s, _)| s)) |
| 102 | + .fold(arguments[0].0.to_owned(), |c, v| c + ", " + v) |
| 103 | + ); |
| 104 | + |
| 105 | + return; |
92 | 106 | }
|
93 |
| - // We encountered an invalid parameter: |
94 |
| - println!( |
95 |
| - "Invalid argument: {arg:?}.\n\ |
96 |
| - Valid parameters: {}.", |
97 |
| - arguments[1..] |
98 |
| - .iter() |
99 |
| - .map(|(s, _)| s) |
100 |
| - .chain(flag_arguments.iter().map(|(s, _)| s)) |
101 |
| - .fold(arguments[0].0.to_owned(), |c, v| c + ", " + v) |
102 |
| - ); |
103 |
| - return; |
104 | 107 | }
|
105 | 108 |
|
106 | 109 | // If no checks are specified, we run every check
|
|
0 commit comments