Skip to content

Commit a7ae998

Browse files
committed
spirv-builder: clap testing
1 parent 4211982 commit a7ae998

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
@@ -54,7 +54,7 @@ jobs:
5454
run: cargo test -p rustc_codegen_spirv --release --no-default-features --features "use-installed-tools"
5555

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

5959
# Examples
6060
- 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)