mirror of
https://gitee.com/openharmony/third_party_rust_bitflags
synced 2024-11-23 15:20:08 +00:00
Merge pull request #199 from eupn/use-trybuild
Use trybuild for compiletest
This commit is contained in:
commit
c418ee2b58
@ -22,7 +22,7 @@ matrix:
|
||||
- LABEL="compiletest"
|
||||
script:
|
||||
- cargo test
|
||||
- cargo test -p test_suite --features unstable
|
||||
- cargo test -p test_suite
|
||||
- rust: stable
|
||||
- rust: stable
|
||||
os: osx
|
||||
|
@ -2,12 +2,9 @@
|
||||
name = "test_suite"
|
||||
version = "0.0.0"
|
||||
|
||||
[features]
|
||||
unstable = ["compiletest_rs"]
|
||||
|
||||
[dependencies]
|
||||
bitflags = { path = "../" }
|
||||
compiletest_rs = { version = "0.3.18", optional = true, features=["stable"] }
|
||||
trybuild = "1.0"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
serde_json = "1.0"
|
||||
|
@ -16,5 +16,5 @@ mod example {
|
||||
|
||||
fn main() {
|
||||
let flag1 = example::Flags1::FLAG_A;
|
||||
let flag2 = example::Flags2::FLAG_B; //~ ERROR struct `Flags2` is private
|
||||
let flag2 = example::Flags2::FLAG_B;
|
||||
}
|
||||
|
5
test_suite/tests/compile-fail/private_flags.stderr
Normal file
5
test_suite/tests/compile-fail/private_flags.stderr
Normal file
@ -0,0 +1,5 @@
|
||||
error[E0603]: struct `Flags2` is private
|
||||
--> $DIR/private_flags.rs:19:26
|
||||
|
|
||||
19 | let flag2 = example::Flags2::FLAG_B;
|
||||
| ^^^^^^
|
@ -1,33 +1,5 @@
|
||||
#![cfg(feature = "unstable")]
|
||||
|
||||
extern crate compiletest_rs as compiletest;
|
||||
|
||||
use std::fs;
|
||||
use std::result::Result;
|
||||
|
||||
use compiletest::common::Mode;
|
||||
|
||||
fn run_mode(mode: Mode) {
|
||||
let config = compiletest::Config {
|
||||
mode: mode,
|
||||
src_base: format!("tests/{}", mode).into(),
|
||||
target_rustcflags: fs::read_dir("../target/debug/deps")
|
||||
.unwrap()
|
||||
.map(Result::unwrap)
|
||||
.filter(|entry| {
|
||||
let file_name = entry.file_name();
|
||||
let file_name = file_name.to_string_lossy();
|
||||
file_name.starts_with("libbitflags-") && file_name.ends_with(".rlib")
|
||||
})
|
||||
.max_by_key(|entry| entry.metadata().unwrap().modified().unwrap())
|
||||
.map(|entry| format!("--extern bitflags={}", entry.path().to_string_lossy())),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
compiletest::run_tests(&config);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compile_test() {
|
||||
run_mode(Mode::CompileFail);
|
||||
fn compile_fail() {
|
||||
let t = trybuild::TestCases::new();
|
||||
t.compile_fail("tests/compile-fail/*.rs");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user