Debian Codegraph @

debian/rust-vendor/zerocopy/tests/ui.rs

raw
1 // Copyright 2019 The Fuchsia Authors
2 //
3 // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
4 // <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
5 // license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
6 // This file may not be copied, modified, or distributed except according to
7 // those terms.
8
9 // Many of our UI tests require the "derive" feature to function properly. In
10 // particular:
11 // - Some tests directly include `zerocopy-derive/tests/include.rs`, which
12 // derives traits on the `AU16` type.
13 // - The file `invalid-impls.rs` directly includes `src/util/macros.rs` in order
14 // to test the `impl_or_verify!` macro which is defined in that file.
15 // Specifically, it tests the verification portion of that macro, which is
16 // enabled when `cfg(any(feature = "derive", test))`. While `--cfg test` is of
17 // course passed to the code in the file you're reading right now, `trybuild`
18 // does not pass `--cfg test` when it invokes Cargo. As a result, this
19 // `trybuild` test only tests the correct behavior when the "derive" feature
20 // is enabled.
21 #![cfg(feature = "derive")]
22
23 use testutil::UiTestRunner;
24
25 #[test]
26 #[cfg_attr(miri, ignore)]
27 fn test_ui() {
28 // FIXME: Instead of manually passing `--features derive` when building, we
29 // should just pass whatever is passed to us.
30 UiTestRunner::new()
31 .rustc_arg("--cfg=feature=\"derive\"") // For tests that check #cfg(feature = "derive")
32 .rustc_arg("-Wwarnings") // To reflect typical user experience in stderr
33 .run();
34 }