diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2012-12-30 14:51:03 +0000 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2012-12-30 14:51:03 +0000 |
commit | 12be928dfb1b08d1209de5558f324413ab6d3d0e (patch) | |
tree | c311b0fd79e4a2881ee1ab9e1a16651fb3cc10f7 /llvm/docs/TestingGuide.rst | |
parent | 749a43d874f06127fa163efff456693e29124aeb (diff) | |
download | bcm5719-llvm-12be928dfb1b08d1209de5558f324413ab6d3d0e.tar.gz bcm5719-llvm-12be928dfb1b08d1209de5558f324413ab6d3d0e.zip |
Documentation: add a section to prevent spurious test failures like the one
fixed in r171243.
llvm-svn: 171258
Diffstat (limited to 'llvm/docs/TestingGuide.rst')
-rw-r--r-- | llvm/docs/TestingGuide.rst | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/llvm/docs/TestingGuide.rst b/llvm/docs/TestingGuide.rst index f66cae1d148..f26d1bf60a7 100644 --- a/llvm/docs/TestingGuide.rst +++ b/llvm/docs/TestingGuide.rst @@ -262,6 +262,43 @@ recommended way to examine output to figure out if the test passes it using the :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 --------------------- |