You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tests: use the Rust test runner instead of our manually generated one
This way, things like `#[cfg]` and `#[should_panic]` work.
This seems simpler than trying to parse the `#[cfg]`s from Python
and keeping the old way.
This generates a much simpler `lib.rs` instead of a `main.rs`
that tries to be its own simple test runner.
Rust's test runner doesn't distinguish between expected and unexpected failures
(it should counts an expected failure as a success),
so we lose this output information, but an expected failure really is a success so this should be fine.
Copy file name to clipboardExpand all lines: tests/README.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,7 @@ extern "C" {
23
23
// The length can be any value
24
24
const BUFFER_SIZE: usize = 1024;
25
25
26
+
#[test]
26
27
pub fn test_example() {
27
28
let mut buffer = [0; BUFFER_SIZE];
28
29
let mut rust_buffer = [0; BUFFER_SIZE];
@@ -42,7 +43,8 @@ The C code can do one of two things: modify some sort of buffer or return a valu
42
43
43
44
To completely skip the translation of a C file, you must add the comment `//! skip_translation` at the top of the file. That will prevent the case from showing up as red in the console output.
44
45
45
-
You can also mark a Rust file as unexpected to compile, by adding `//! xfail` to the top of the file, or just expect an individual test function to fail to run by adding `// xfail` prior to the function definition.
46
+
You can also mark a Rust file as unexpected to compile by adding `//! xfail` to the top of the file.
47
+
For an individual test function, use the normal Rust `#[should_panic]` for `#[test]`s.
46
48
47
49
Adding `//! extern_crate_X` to the top of a test file will ensure `extern crate X;` gets added to the main binary driver.
0 commit comments