-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The compiletest crate requires lots of flaming hoops, doesn't work if you change features between cargo runs, and currently doesn't work in macOS at all (see Manishearth/compiletest-rs#179). The trybuild crate, on the other hand, seems to work quite well everywhere and gives nice diagnostics. Let's use that instead.
- Loading branch information
Showing
8 changed files
with
28 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
error[E0599]: no method named `as_nonzero_unchecked` found for type `i32` in the current scope | ||
--> $DIR/negative_i32.rs:8:26 | ||
| | ||
8 | let _a: NonZeroU32 = nonzero!(-2i32); | ||
| ^^^^^^^^^^^^^^^ method not found in `i32` | ||
| | ||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
error[E0080]: evaluation of constant value failed | ||
--> $DIR/zero_u8.rs:8:25 | ||
| | ||
8 | let _a: NonZeroU8 = nonzero!(0u8); | ||
| ^^^^^^^^^^^^^ attempt to subtract with overflow | ||
| | ||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
error[E0080]: evaluation of constant value failed | ||
--> $DIR/zero_usize.rs:8:28 | ||
| | ||
8 | let _a: NonZeroUsize = nonzero!(0usize); | ||
| ^^^^^^^^^^^^^^^^ attempt to subtract with overflow | ||
| | ||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,6 @@ | ||
#![cfg(feature = "compiletest_rs")] | ||
|
||
extern crate compiletest_rs as compiletest; | ||
use std::fs::{read_dir, remove_file}; | ||
use std::path::PathBuf; | ||
|
||
fn clean_rlibs(config: &compiletest_rs::Config) { | ||
if config.target_rustcflags.is_some() { | ||
for directory in config | ||
.target_rustcflags | ||
.as_ref() | ||
.unwrap() | ||
.split_whitespace() | ||
{ | ||
if let Ok(mut entries) = read_dir(directory) { | ||
while let Some(Ok(entry)) = entries.next() { | ||
let f = entry.file_name().clone().into_string().unwrap(); | ||
if f.ends_with(".rmeta") { | ||
let prefix = &f[..f.len() - 5]; | ||
let _ = remove_file(entry.path()); | ||
if let Ok(mut entries) = read_dir(directory) { | ||
while let Some(Ok(entry)) = entries.next() { | ||
let f = entry.file_name().clone().into_string().unwrap(); | ||
if f.starts_with(prefix) && !f.ends_with(".rmeta") { | ||
let _ = remove_file(entry.path()); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
fn run_mode(mode: &'static str) { | ||
let mut config = compiletest::Config::default().tempdir(); | ||
let cfg_mode = mode.parse().expect("Invalid mode"); | ||
|
||
config.mode = cfg_mode; | ||
config.src_base = PathBuf::from(format!("tests/{}", mode)); | ||
// config.target_rustcflags = Some("-L target/debug -L target/debug/deps".to_string()); | ||
config.link_deps(); | ||
config.clean_rmeta(); | ||
clean_rlibs(&config); | ||
|
||
compiletest::run_tests(&config); | ||
} | ||
|
||
#[test] | ||
fn compile_test() { | ||
// Don't run compile-fail tests under nightly: Error messages are unstable. | ||
#[cfg(feature = "stable")] | ||
run_mode("compile-fail"); | ||
|
||
run_mode("run-pass"); | ||
let t = trybuild::TestCases::new(); | ||
t.compile_fail("tests/compile-fail/*.rs"); | ||
t.pass("tests/run-pass/*.rs"); | ||
} |