[lit] Fix test that relied on "single process" mode
The shtest-inject test relied on being executed in "single process" mode and started to fail with a `PicklingError` after it was removed: ``` Can't pickle <class 'lit.TestingConfig.CustomFormat'>: attribute lookup lit.TestingConfig.CustomFormat failed ``` This happened because the test config has to be serialized to the worker process, but apparently the `CustomFormat` class defined inline is not serializable. This change allows passing the tested functionality (preamble_commands) directly to `lit.formats.ShTest` so we can use it directly in the test.
This commit is contained in:
parent
f3c329986c
commit
1e8900cc82
|
@ -17,9 +17,14 @@ class ShTest(FileBasedTest):
|
|||
The ShTest files contain some number of shell-like command pipelines, along
|
||||
with assertions about what should be in the output.
|
||||
"""
|
||||
def __init__(self, execute_external=False):
|
||||
def __init__(self, execute_external=False, extra_substitutions=[],
|
||||
preamble_commands=[]):
|
||||
self.execute_external = execute_external
|
||||
self.extra_substitutions = extra_substitutions
|
||||
self.preamble_commands = preamble_commands
|
||||
|
||||
def execute(self, test, litConfig):
|
||||
return lit.TestRunner.executeShTest(test, litConfig,
|
||||
self.execute_external)
|
||||
self.execute_external,
|
||||
self.extra_substitutions,
|
||||
self.preamble_commands)
|
||||
|
|
|
@ -1,17 +1,12 @@
|
|||
import lit
|
||||
|
||||
class CustomFormat(lit.formats.TestFormat):
|
||||
def execute(self, test, litConfig):
|
||||
commands = [
|
||||
'echo "THIS WAS"',
|
||||
'echo "INJECTED"'
|
||||
]
|
||||
return lit.TestRunner.executeShTest(test, litConfig,
|
||||
useExternalSh=False,
|
||||
preamble_commands=commands)
|
||||
preamble_commands = [
|
||||
'echo "THIS WAS"',
|
||||
'echo "INJECTED"'
|
||||
];
|
||||
|
||||
config.name = 'shtest-inject'
|
||||
config.suffixes = ['.txt']
|
||||
config.test_format = CustomFormat()
|
||||
config.test_format = lit.formats.ShTest(preamble_commands=preamble_commands)
|
||||
config.test_source_root = None
|
||||
config.test_exec_root = None
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
# Check that we can inject commands at the beginning of a ShTest using a custom
|
||||
# test format.
|
||||
# Check that we can inject commands at the beginning of a ShTest.
|
||||
|
||||
# RUN: %{lit} -j 1 %{inputs}/shtest-inject/test-empty.txt --show-all | FileCheck --check-prefix=CHECK-TEST1 %s
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue