about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2016-03-02 10:59:47 -0500
committerNiko Matsakis <niko@alum.mit.edu>2016-03-02 14:26:03 -0500
commit1d76ccd9d45e818e0554c8ce491d5ed20130e9c8 (patch)
tree4b7e08a16341d5eb8f0d5bfeac0117e5f64b000f
parent3fb80e33a89709e3457ad0943f5847eb5800d620 (diff)
downloadrust-1d76ccd9d45e818e0554c8ce491d5ed20130e9c8.tar.gz
rust-1d76ccd9d45e818e0554c8ce491d5ed20130e9c8.zip
Update `COMPILER_TESTS.md` documentation to discuss revisions
-rw-r--r--COMPILER_TESTS.md31
1 files changed, 31 insertions, 0 deletions
diff --git a/COMPILER_TESTS.md b/COMPILER_TESTS.md
index e2a957e3961..08afd2137ba 100644
--- a/COMPILER_TESTS.md
+++ b/COMPILER_TESTS.md
@@ -42,3 +42,34 @@ whole, instead of just a few lines inside the test.
 * `ignore-test` always ignores the test
 * `ignore-lldb` and `ignore-gdb` will skip the debuginfo tests
 * `min-{gdb,lldb}-version`
+
+## Revisions
+
+Certain classes of tests support "revisions" (as of the time of this
+writing, this includes run-pass, compile-fail, run-fail, and
+incremental, though incremental tests are somewhat
+different). Revisions allow a single test file to be used for multiple
+tests. This is done by adding a special header at the top of the file:
+
+```
+// revisions: foo bar baz
+```
+
+This will result in the test being compiled (and tested) three times,
+once with `--cfg foo`, once with `--cfg bar`, and once with `--cfg
+baz`. You can therefore use `#[cfg(foo)]` etc within the test to tweak
+each of these results.
+
+You can also customize headers and expected error messages to a particular
+revision. To do this, add `[foo]` (or `bar`, `baz`, etc) after the `//`
+comment, like so:
+
+```
+// A flag to pass in only for cfg `foo`:
+//[foo]compile-flags: -Z verbose
+
+#[cfg(foo)]
+fn test_foo() {
+    let x: usize = 32_u32; //[foo]~ ERROR mismatched types
+}
+```