rust/src/test/mir-opt
bors af7de7b677 Auto merge of #45162 - chrisvittal:mir-testing, r=nikomatsakis
Modify MIR testing to require consecutive lines

MIR testing now requires that lines be consecutive. To achive this,
instead of collecting the expected mir as a string, it is now wrapped in
an `ExpectedLine` enum, that is either `Elision` or `Text(T)` where `T:
AsRef<str>`. `Text` lines must be matched in order, unless separated by
`Elision` lines. Elision occurs lazily, that is, an Elision will skip
as few lines as possible.

To add a new elision marker. Put a comment containing only "..." and
whitespace in any MIR testing block. Like so:

```
// fn write_42(_1: *mut i32) -> bool {
//     ...
//     bb0: {
//         Validate(Acquire, [_1: *mut i32]);
//         Validate(Release, [_1: *mut i32]);
//         ...
//         return;
//     }
// }
```

Right now, all input before the line right after `// START` is elided,
and all input after the line right before `// END` is also not tested.

Many tests need to be updated. That will follow in the next commit.

cc #45153
r? @nikomatsakis
2017-10-14 11:22:46 +00:00
..
basic_assignment.rs rustc_mir::transform::simplify - remove nops first 2017-08-01 00:12:31 +03:00
box_expr.rs Update README and tests for new infrastructure 2017-10-09 23:22:34 -04:00
copy_propagation.rs Update README and tests for new infrastructure 2017-10-09 23:22:34 -04:00
deaggregator_test.rs Update README and tests for new infrastructure 2017-10-09 23:22:34 -04:00
deaggregator_test_enum.rs Update README and tests for new infrastructure 2017-10-09 23:22:34 -04:00
deaggregator_test_enum_2.rs Update README and tests for new infrastructure 2017-10-09 23:22:34 -04:00
deaggregator_test_multiple.rs Update README and tests for new infrastructure 2017-10-09 23:22:34 -04:00
end_region_1.rs Update README and tests for new infrastructure 2017-10-09 23:22:34 -04:00
end_region_2.rs Update README and tests for new infrastructure 2017-10-09 23:22:34 -04:00
end_region_3.rs Update README and tests for new infrastructure 2017-10-09 23:22:34 -04:00
end_region_4.rs Update README and tests for new infrastructure 2017-10-09 23:22:34 -04:00
end_region_5.rs Update README and tests for new infrastructure 2017-10-09 23:22:34 -04:00
end_region_6.rs Update README and tests for new infrastructure 2017-10-09 23:22:34 -04:00
end_region_7.rs Update README and tests for new infrastructure 2017-10-09 23:22:34 -04:00
end_region_8.rs Update README and tests for new infrastructure 2017-10-09 23:22:34 -04:00
end_region_9.rs Update README and tests for new infrastructure 2017-10-09 23:22:34 -04:00
end_region_cyclic.rs Update README and tests for new infrastructure 2017-10-09 23:22:34 -04:00
end_region_destruction_extents_1.rs Test case illustrating some destruction code extent stuff. 2017-09-13 12:55:03 +02:00
issue-38669.rs simplify the MirPass traits and passes dramatically 2017-05-02 14:01:01 -04:00
issue-41110.rs Update README and tests for new infrastructure 2017-10-09 23:22:34 -04:00
issue-41697.rs remove compile-flags 2017-05-15 21:12:40 -04:00
issue-41888.rs move "ADT master drop flag" logic to open_drop_for_adt_contents 2017-05-28 10:43:24 +03:00
issue-43457.rs Update regression test to explicit enable EndRegion emission. 2017-09-05 15:19:55 +02:00
README.md Update README and tests for new infrastructure 2017-10-09 23:22:34 -04:00
return_an_array.rs add mir optimization tests, dump-mir-dir option 2016-07-20 19:41:39 -07:00
simplify_if.rs simplify the MirPass traits and passes dramatically 2017-05-02 14:01:01 -04:00
storage_live_dead_in_statics.rs Update README and tests for new infrastructure 2017-10-09 23:22:34 -04:00
storage_ranges.rs Update README and tests for new infrastructure 2017-10-09 23:22:34 -04:00
validate_1.rs Auto merge of #45162 - chrisvittal:mir-testing, r=nikomatsakis 2017-10-14 11:22:46 +00:00
validate_2.rs Update README and tests for new infrastructure 2017-10-09 23:22:34 -04:00
validate_3.rs Update README and tests for new infrastructure 2017-10-09 23:22:34 -04:00
validate_4.rs Auto merge of #45162 - chrisvittal:mir-testing, r=nikomatsakis 2017-10-14 11:22:46 +00:00
validate_5.rs Auto merge of #45162 - chrisvittal:mir-testing, r=nikomatsakis 2017-10-14 11:22:46 +00:00

This folder contains tests for MIR optimizations.

The test format is:

(arbitrary rust code)
// END RUST SOURCE
// START $file_name_of_some_mir_dump_0
//  $expected_line_0
// (lines or elision)
// $expected_line_N
// END $file_name_of_some_mir_dump_0
// (lines or elision)
// START $file_name_of_some_mir_dump_N
//  $expected_line_0
// (lines or elision)
// $expected_line_N
// END $file_name_of_some_mir_dump_N

All the test information is in comments so the test is runnable.

For each $file_name, compiletest expects [$expected_line_0, ..., $expected_line_N] to appear in the dumped MIR in order. Currently it allows other non-matched lines before and after, but not between $expected_lines, should you want to skip lines, you must include an elision comment, of the form (as a regex) //\s*...\s*. The lines will be skipped lazily, that is, if there are two identical lines in the output that match the line after the elision comment, the first one wil be matched.

Examples:

The following blocks will not match the one after it.

bb0: {
    StorageLive(_1);
    _1 = const true;
    StorageDead(_1);
}
bb0: {
    StorageLive(_1);
    _1 = const true;
    goto -> bb1
}
bb1: {
    StorageDead(_1);
    return;
}

But this will match the one above,

bb0: {
    StorageLive(_1);
    _1 = const true;
    ...
    StorageDead(_1);
    ...
}

Lines match ignoring whitespace, and the prefix "//" is removed.

It also currently strips trailing comments -- partly because the full file path in "scope comments" is unpredictable and partly because tidy complains about the lines being too long.

compiletest handles dumping the MIR before and after every pass for you. The test writer only has to specify the file names of the dumped files (not the full path to the file) and what lines to expect. There is an option to rustc that tells it to dump the mir into some directly (rather then always dumping to the current directory).