Use compiletest to check Repacketizer lifetimes

This commit is contained in:
Tad Hardesty 2016-10-15 02:16:47 -07:00
parent 09f9d16148
commit 9a0430620f
No known key found for this signature in database
GPG Key ID: AEFCC915C75ACC47
3 changed files with 34 additions and 0 deletions

View File

@ -13,3 +13,6 @@ repository = "https://github.com/SpaceManiac/opus-rs"
[dependencies]
opus-sys = "0.2.0"
libc = "0.2"
[dev-dependencies]
compiletest_rs = "0.2.4"

View File

@ -0,0 +1,10 @@
extern crate opus;
fn main() {
let mut rp = opus::Repacketizer::new().unwrap();
let mut wip = rp.begin().cat_move(
&[1, 2, 3]
//~^ ERROR borrowed value does not live long enough
).unwrap();
wip.out(&mut []);
}

21
tests/compiletests.rs Normal file
View File

@ -0,0 +1,21 @@
extern crate compiletest_rs as compiletest;
use std::path::PathBuf;
#[cfg(debug_assertions)]
const DEPS: &'static str = "-L target/debug -L target/debug/deps";
#[cfg(not(debug_assertions))]
const DEPS: &'static str = "-L target/release -L target/release/deps";
fn run_mode(mode: &'static str) {
let mut config = compiletest::default_config();
config.mode = mode.parse().ok().expect("Invalid mode");
config.src_base = PathBuf::from(format!("tests/{}", mode));
config.target_rustcflags = Some(DEPS.to_owned());
compiletest::run_tests(&config);
}
#[test]
fn compile_test() {
run_mode("compile-fail");
}