| 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 |
use testutil::ToolchainVersion; |
| 10 |
|
| 11 |
#[test] |
| 12 |
#[cfg_attr(miri, ignore)] |
| 13 |
fn ui() { |
| 14 |
let version = ToolchainVersion::extract_from_pwd().unwrap(); |
| 15 |
// See the doc comment on this method for an explanation of what this does |
| 16 |
// and why we store source files in different directories. |
| 17 |
let source_files_dirname = version.get_ui_source_files_dirname_and_maybe_print_warning(); |
| 18 |
|
| 19 |
let t = trybuild::TestCases::new(); |
| 20 |
t.compile_fail(format!("tests/{source_files_dirname}/*.rs")); |
| 21 |
} |
| 22 |
|
| 23 |
// The file `invalid-impls.rs` directly includes `src/macros.rs` in order to |
| 24 |
// test the `impl_or_verify!` macro which is defined in that file. Specifically, |
| 25 |
// it tests the verification portion of that macro, which is enabled when |
| 26 |
// `cfg(any(feature = "derive", test))`. While `--cfg test` is of course passed |
| 27 |
// to the code in the file you're reading right now, `trybuild` does not pass |
| 28 |
// `--cfg test` when it invokes Cargo. As a result, this `trybuild` test only |
| 29 |
// tests the correct behavior when the "derive" feature is enabled. |
| 30 |
#[cfg(feature = "derive")] |
| 31 |
#[test] |
| 32 |
#[cfg_attr(miri, ignore)] |
| 33 |
fn ui_invalid_impls() { |
| 34 |
let version = ToolchainVersion::extract_from_pwd().unwrap(); |
| 35 |
// See the doc comment on this method for an explanation of what this does |
| 36 |
// and why we store source files in different directories. |
| 37 |
let source_files_dirname = version.get_ui_source_files_dirname_and_maybe_print_warning(); |
| 38 |
|
| 39 |
let t = trybuild::TestCases::new(); |
| 40 |
t.compile_fail(format!("tests/{source_files_dirname}/invalid-impls/*.rs")); |
| 41 |
} |