Skip to content

Commit 3572361

Browse files
committed
tests: add basic test coverage for cli flag --crate-type
1 parent 64feb9b commit 3572361

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: unknown crate type: ``
2+

tests/ui/cli/crate-type-flag.rs

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//! Check that `rustc`'s `--crate-type` flag accepts `--crate-type=<valid_type>` as well as the
2+
//! multi-value version `--crate-type=<valid_type_1>,<valid_type_2>`.
3+
//!
4+
//! This test does not try to check if the output artifacts are valid.
5+
6+
// FIXME(#132309): add a proper `supports-crate-type` directive.
7+
8+
// Single valid crate types should pass
9+
//@ revisions: lib_ rlib_ staticlib_ dylib_ cdylib_ bin_ proc_macro_
10+
11+
//@[lib_] compile-flags: --crate-type=lib
12+
//@[lib_] check-pass
13+
14+
//@[rlib_] compile-flags: --crate-type=rlib
15+
//@[rlib_] check-pass
16+
17+
//@[staticlib_] compile-flags: --crate-type=staticlib
18+
//@[staticlib_] check-pass
19+
20+
//@[dylib_] ignore-musl (dylibs are not supported)
21+
//@[dylib_] ignore-wasm (dylibs are not supported)
22+
//@[dylib_] compile-flags: --crate-type=dylib
23+
//@[dylib_] check-pass
24+
25+
//@[cdylib_] ignore-musl (cdylibs are not supported)
26+
//@[cdylib_] compile-flags: --crate-type=cdylib
27+
//@[cdylib_] check-pass
28+
29+
//@[bin_] compile-flags: --crate-type=bin
30+
//@[bin_] check-pass
31+
32+
//@[proc_macro_] ignore-wasm (proc-macro is not supported)
33+
//@[proc_macro_] compile-flags: --crate-type=proc-macro
34+
//@[proc_macro_] check-pass
35+
36+
//@ revisions: multivalue multivalue_combined
37+
38+
//@[multivalue] compile-flags: --crate-type=lib,rlib,staticlib
39+
//@[multivalue] check-pass
40+
41+
//@[multivalue_combined] ignore-musl (dylibs are not supported)
42+
//@[multivalue_combined] ignore-wasm (dylibs are not supported)
43+
//@[multivalue_combined] compile-flags: --crate-type=lib,rlib,staticlib --crate-type=dylib
44+
//@[multivalue_combined] check-pass
45+
46+
// `proc-macro` is accepted, but `proc_macro` is not.
47+
//@ revisions: underscore_proc_macro
48+
49+
//@[underscore_proc_macro] compile-flags: --crate-type=proc_macro
50+
//@[underscore_proc_macro] error-pattern: "unknown crate type: `proc_macro`"
51+
52+
// Empty `--crate-type` not accepted.
53+
//@ revisions: empty_crate_type
54+
//@[empty_crate_type] compile-flags: --crate-type=
55+
//@[empty_crate_type] error-pattern: "unknown crate type: ``"
56+
57+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: unknown crate type: `proc_macro`
2+

0 commit comments

Comments
 (0)