xref: /llvm-project/llvm/utils/lit/lit/formats/shtest.py (revision b71edfaa4ec3c998aadb35255ce2f60bba2940b0)
1from __future__ import absolute_import
2
3import lit.TestRunner
4import lit.util
5
6from .base import FileBasedTest
7
8
9class ShTest(FileBasedTest):
10    """ShTest is a format with one file per test.
11
12    This is the primary format for regression tests as described in the LLVM
13    testing guide:
14
15        http://llvm.org/docs/TestingGuide.html
16
17    The ShTest files contain some number of shell-like command pipelines, along
18    with assertions about what should be in the output.
19    """
20
21    def __init__(
22        self, execute_external=False, extra_substitutions=[], preamble_commands=[]
23    ):
24        self.execute_external = execute_external
25        self.extra_substitutions = extra_substitutions
26        self.preamble_commands = preamble_commands
27
28    def execute(self, test, litConfig):
29        return lit.TestRunner.executeShTest(
30            test,
31            litConfig,
32            self.execute_external,
33            self.extra_substitutions,
34            self.preamble_commands,
35        )
36