| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 | #!/usr/bin/env python3#              Copyright Catch2 Authors# Distributed under the Boost Software License, Version 1.0.#   (See accompanying file LICENSE_1_0.txt or copy at#        https://www.boost.org/LICENSE_1_0.txt)# SPDX-License-Identifier: BSL-1.0"""This test script verifies that the testCasePartial{Starting,Ended} reporterevents fire properly. This is done by calling a test binary compiled withreporter that reports specifically testCase* events, and verifying theoutputs match what we expect."""import subprocessimport sysexpected_section_output = '''\TestCaseStarting: sectionTestCaseStartingPartial: section#0TestCasePartialEnded: section#0TestCaseStartingPartial: section#1TestCasePartialEnded: section#1TestCaseStartingPartial: section#2TestCasePartialEnded: section#2TestCaseStartingPartial: section#3TestCasePartialEnded: section#3TestCaseEnded: section'''expected_generator_output = '''\TestCaseStarting: generatorTestCaseStartingPartial: generator#0TestCasePartialEnded: generator#0TestCaseStartingPartial: generator#1TestCasePartialEnded: generator#1TestCaseStartingPartial: generator#2TestCasePartialEnded: generator#2TestCaseStartingPartial: generator#3TestCasePartialEnded: generator#3TestCaseEnded: generator'''from typing import Listdef get_test_output(test_exe: str, sections: bool) -> List[str]:    cmd = [test_exe, '--reporter', 'partial']    if sections:        cmd.append('section')    else:        cmd.append('generator')    ret = subprocess.run(cmd,                         stdout = subprocess.PIPE,                         stderr = subprocess.PIPE,                         timeout = 10,                         check = True,                         universal_newlines = True)    return ret.stdoutdef main():    test_exe, = sys.argv[1:]    actual_section_output = get_test_output(test_exe, sections = True)    assert actual_section_output == expected_section_output, (    'Sections\nActual:\n{}\nExpected:\n{}\n'.format(actual_section_output, expected_section_output))    actual_generator_output = get_test_output(test_exe, sections = False)    assert actual_generator_output == expected_generator_output, (    'Generators\nActual:\n{}\nExpected:\n{}\n'.format(actual_generator_output, expected_generator_output))if __name__ == '__main__':    sys.exit(main())
 |