llvm.org GIT mirror llvm / c1bb2d4
Use pipefail when available. This change makes test with RUN lines like RUN: opt ... | FileCheck fail if opt fails, even if it prints what FileCheck wants. Enabling this found some interesting cases of broken tests that were not being noticed because opt (or some other tool) was crashing late. Pipefail is used when the shell supports it or when using the internal python based tester. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187261 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
6 changed file(s) with 18 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
314314 arguments: (1) the parent configuration, (2) the new configuration (which the
315315 *on_clone* function will generally modify), and (3) the test path to the new
316316 directory being scanned.
317
318 **pipefail** Normally a test using a shell pipe fails if any of the commands
319 on the pipe fail. If this is not desired, setting this variable to false
320 makes the test fail only if the last command in the pipe fails.
317321
318322 TEST DISCOVERY
319323 ~~~~~~~~~~~~~~
3939 point (e.g. maybe you would like to give an example of the
4040 functionality, or simply have a lot to talk about), see the `NOTE` below
4141 for adding a new subsection.
42
43 * The regression tests now fail if any command in a pipe fails. To disable it in
44 a directory, just add ``config.pipefail = False`` to its ``lit.local.cfg``.
45 See :doc:`Lit ` for the details.
4246
4347 * Support for exception handling has been removed from the old JIT. Use MCJIT
4448 if you need EH support.
0 REQUIRES: shell
1 RUN: ((false | true) && echo true || echo false) | grep false
165165 ###
166166
167167 class ShParser:
168 def __init__(self, data, win32Escapes = False):
168 def __init__(self, data, win32Escapes = False, pipefail = False):
169169 self.data = data
170 self.pipefail = pipefail
170171 self.tokens = ShLexer(data, win32Escapes = win32Escapes).lex()
171172
172173 def lex(self):
223224 while self.look() == ('|',):
224225 self.lex()
225226 commands.append(self.parse_command())
226 return Pipeline(commands, negate)
227 return Pipeline(commands, negate, self.pipefail)
227228
228229 def parse(self):
229230 lhs = self.parse_pipeline()
244244 cmds = []
245245 for ln in commands:
246246 try:
247 cmds.append(ShUtil.ShParser(ln, litConfig.isWindows).parse())
247 cmds.append(ShUtil.ShParser(ln, litConfig.isWindows,
248 test.config.pipefail).parse())
248249 except:
249250 return (Test.FAIL, "shell parser error on: %r" % ln)
250251
283284 if isWin32CMDEXE:
284285 f.write('\nif %ERRORLEVEL% NEQ 0 EXIT\n'.join(commands))
285286 else:
287 if test.config.pipefail:
288 f.write('set -o pipefail;')
286289 f.write('{ ' + '; } &&\n{ '.join(commands) + '; }')
287290 f.write('\n')
288291 f.close()
9191 self.test_source_root = test_source_root
9292 self.excludes = set(excludes)
9393 self.available_features = set(available_features)
94 self.pipefail = True
9495
9596 def clone(self, path):
9697 # FIXME: Chain implementations?