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
* Fixes#1279.
This starts testing in CI on aarch64 macOS, our first aarch64 target to
test.
Varargs are broken on aarch64 (#1281), so this PR also disables varargs
tests on aarch64.
However, doing this didn't work with the current `test_translator.py`,
which textually searches the Rust test file for `fn test_*`s.
`#[cfg(not(target_arch = "aarch64"))]` is the simplest and most
straightforward way to disable such tests on aarch64, but parsing this
from Python and generating a test runner in `main.rs` that's
platform-dependent is tricky. Since Rust's built-in test runner already
does much of this, and does it better, I switched `test_translator.py`
to simply run `cargo test`. This means marking all of the test functions
with `#[test]` and generating a mostly empty `lib.rs` instead of a
`main.rs`. We also lose the ability to distinguish between expected
failures and successes, as `cargo test` treats them the same, but I
think this is fine. It also means we can use the idiomatic
`#[should_panic]` instead of parsing the non-standard `// xfail`
ourselves.
I can also break this part out into a separate PR if you think that'd be
helpful.
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