[llvm-commits] [llvm] r171258 - /llvm/trunk/docs/TestingGuide.rst
Dmitri Gribenko
gribozavr at gmail.com
Sun Dec 30 06:51:03 PST 2012
Author: gribozavr
Date: Sun Dec 30 08:51:03 2012
New Revision: 171258
URL: http://llvm.org/viewvc/llvm-project?rev=171258&view=rev
Log:
Documentation: add a section to prevent spurious test failures like the one
fixed in r171243.
Modified:
llvm/trunk/docs/TestingGuide.rst
Modified: llvm/trunk/docs/TestingGuide.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/TestingGuide.rst?rev=171258&r1=171257&r2=171258&view=diff
==============================================================================
--- llvm/trunk/docs/TestingGuide.rst (original)
+++ llvm/trunk/docs/TestingGuide.rst Sun Dec 30 08:51:03 2012
@@ -262,6 +262,43 @@
:doc:`FileCheck tool <CommandGuide/FileCheck>`. The usage of ``grep`` in RUN
lines is discouraged.
+Fragile tests
+-------------
+
+It is easy to write a fragile test that would fail spuriously if the tool being
+tested outputs a full path to the input file. For example, :program:`opt` by
+default outputs a ``ModuleID``:
+
+.. code-block:: console
+
+ $ cat example.ll
+ define i32 @main() nounwind {
+ ret i32 0
+ }
+
+ $ opt -S /path/to/example.ll
+ ; ModuleID = '/path/to/example.ll'
+
+ define i32 @main() nounwind {
+ ret i32 0
+ }
+
+``ModuleID`` can unexpetedly match against ``CHECK`` lines. For example:
+
+.. code-block:: llvm
+
+ ; RUN: opt -S %s | FileCheck
+
+ define i32 @main() nounwind {
+ ; CHECK-NOT: load
+ ret i32 0
+ }
+
+This test will fail if placed into a ``download`` directory.
+
+To make your tests robust, always use ``opt ... < %s`` in the RUN line.
+:program:`opt` does not output a ``ModuleID`` when input comes from stdin.
+
The FileCheck utility
---------------------
More information about the llvm-commits
mailing list