File: trybuild.rs

package info (click to toggle)
rust-peg 0.8.5-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie
  • size: 756 kB
  • sloc: makefile: 20; sh: 12
file content (26 lines) | stat: -rw-r--r-- 919 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
fn main() {
    let args: Vec<_> = std::env::args().collect();
    let t = trybuild::TestCases::new();

    t.pass("tests/run-pass/*.rs");

    let expected_rust_ver = env!("CARGO_PKG_RUST_VERSION");
    let run_anyway = args.iter().any(|a| a == "--compile-fail");

    let run_compile_fail = run_anyway || version_check::is_exact_version(expected_rust_ver).unwrap_or(true);
    if run_compile_fail {
        t.compile_fail("tests/compile-fail/*.rs");
    }

    // Trybuild runs the configured tests on drop
    drop(t);

    if !run_compile_fail {
        eprintln!("!!! Skipped compile-fail tests !!!");
        eprintln!("These tests are only checked on rust version {expected_rust_ver} because");
        eprintln!("the error message text may change between compiler versions.");
        eprintln!("");
        eprintln!("Run `cargo +{expected_rust_ver} test` to run these tests.");
        eprintln!("");
    }
}