diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-06-29 16:36:31 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-29 16:36:31 +0200 |
| commit | f00db43e97dc9a4138686e5fca0fdb0be0775eed (patch) | |
| tree | a143c85fcfcc7d7af6f4882abc7586ee8c80dfe7 /tests/run-coverage/inline.coverage | |
| parent | 93a97c7a2a7d6ddcc40254331ce81f2fc1fe0790 (diff) | |
| parent | 7b4e75b98965f45dd35a31968d388c7deca997a2 (diff) | |
Rollup merge of #112300 - Zalathar:run-coverage, r=wesleywiser
Convert `run-make/coverage-reports` tests to use a custom compiletest mode I was frustrated by the fact that most of the coverage tests are glued together with makefiles and shell scripts, so I tried my hand at converting most of them over to a newly-implemented `run-coverage` mode/suite in compiletest. This ~~*mostly*~~ resolves #85009, ~~though I've left a small number of the existing tests as-is because they would require more work to fix/support~~. --- I had time to go back and add support for the more troublesome tests that I had initially skipped over, so this PR now manages to completely get rid of `run-make/coverage-reports`. --- The patches are arranged as follows: - Declare the new mode/suite in bootstrap - Small changes to compiletest that will be used by the new mode - Implement the new mode in compiletest - Migrate most of the tests over - Add more code to bootstrap and compiletest to support the remaining tests - Migrate the remaining tests (with some temporary hacks to avoid re-blessing them) - Remove the temporary hacks and re-bless the migrated tests - Remove the unused remnants of `run-make/coverage-reports`
Diffstat (limited to 'tests/run-coverage/inline.coverage')
| -rw-r--r-- | tests/run-coverage/inline.coverage | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/run-coverage/inline.coverage b/tests/run-coverage/inline.coverage new file mode 100644 index 00000000000..6f5d1544fa0 --- /dev/null +++ b/tests/run-coverage/inline.coverage @@ -0,0 +1,54 @@ + 1| |// compile-flags: -Zinline-mir + 2| | + 3| |use std::fmt::Display; + 4| | + 5| 1|fn main() { + 6| 1| permutations(&['a', 'b', 'c']); + 7| 1|} + 8| | + 9| |#[inline(always)] + 10| 1|fn permutations<T: Copy + Display>(xs: &[T]) { + 11| 1| let mut ys = xs.to_owned(); + 12| 1| permutate(&mut ys, 0); + 13| 1|} + 14| | + 15| 16|fn permutate<T: Copy + Display>(xs: &mut [T], k: usize) { + 16| 16| let n = length(xs); + 17| 16| if k == n { + 18| 6| display(xs); + 19| 10| } else if k < n { + 20| 15| for i in k..n { + ^10 + 21| 15| swap(xs, i, k); + 22| 15| permutate(xs, k + 1); + 23| 15| swap(xs, i, k); + 24| 15| } + 25| 0| } else { + 26| 0| error(); + 27| 0| } + 28| 16|} + 29| | + 30| 16|fn length<T>(xs: &[T]) -> usize { + 31| 16| xs.len() + 32| 16|} + 33| | + 34| |#[inline] + 35| 30|fn swap<T: Copy>(xs: &mut [T], i: usize, j: usize) { + 36| 30| let t = xs[i]; + 37| 30| xs[i] = xs[j]; + 38| 30| xs[j] = t; + 39| 30|} + 40| | + 41| 6|fn display<T: Display>(xs: &[T]) { + 42| 24| for x in xs { + ^18 + 43| 18| print!("{}", x); + 44| 18| } + 45| 6| println!(); + 46| 6|} + 47| | + 48| |#[inline(always)] + 49| 0|fn error() { + 50| 0| panic!("error"); + 51| 0|} + |
