Skip to content

Commit a64583d

Browse files
committed
spirv-builder: clap testing
1 parent 2c620bd commit a64583d

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
run: cargo test -p rustc_codegen_spirv --release --no-default-features --features "use-installed-tools"
5858

5959
- name: workspace test (excluding examples & difftest)
60-
run: cargo test --release --workspace --exclude "example-runner-*" --exclude "difftest*" --no-default-features --features "use-installed-tools"
60+
run: cargo test --release --workspace --exclude "example-runner-*" --exclude "difftest*" --no-default-features --features "use-installed-tools,clap"
6161

6262
# Examples
6363
- name: cargo check examples

crates/spirv-builder/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@
7373

7474
pub mod cargo_cmd;
7575
mod depfile;
76+
#[cfg(test)]
77+
mod tests;
7678
#[cfg(feature = "watch")]
7779
mod watch;
7880

crates/spirv-builder/src/tests.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#[cfg(feature = "clap")]
2+
mod clap {
3+
pub use crate::*;
4+
use clap::Parser;
5+
6+
/// look at the output of this test to see what `--help` prints
7+
#[test]
8+
fn test_clap_help() {
9+
// any malformed clap declarations should panic within clap's parse
10+
match SpirvBuilder::try_parse_from(["", "--help"]) {
11+
Ok(_) => panic!("`--help` should make clap return an error"),
12+
Err(e) => {
13+
let e = e.to_string();
14+
println!("{}", e);
15+
// sanity check help
16+
assert!(e.contains("--target"));
17+
}
18+
};
19+
}
20+
}

0 commit comments

Comments
 (0)