check_test_cases: Unify walk_compat_sh and walk_opt_sh into one
walk_compat_sh and walk_opt_sh are basically the same now, so: * Merge them into one function. * Use the --list-test-cases option for both of them. * Rename this merged function as collect_from_script which seems more appropriate as since it isn't iterating the script but calling it. Signed-off-by: Tomás González <tomasagustin.gonzalezorlando@arm.com>
This commit is contained in:
parent
37a8739e4d
commit
4a86da2460
3 changed files with 19 additions and 29 deletions
|
@ -27,7 +27,6 @@ import os
|
|||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
|
||||
class Results:
|
||||
|
@ -99,26 +98,18 @@ state may override this method.
|
|||
data_file_name, line_number, line)
|
||||
in_paragraph = True
|
||||
|
||||
def walk_ssl_opt_sh(self, file_name):
|
||||
"""Iterate over the test cases in ssl-opt.sh or a file with a similar format."""
|
||||
def collect_from_script(self, file_name):
|
||||
"""Collect the test cases in a script by calling its listing test cases
|
||||
option"""
|
||||
descriptions = self.new_per_file_state() # pylint: disable=assignment-from-none
|
||||
listed = subprocess.check_output([file_name, '-l'])
|
||||
listed = subprocess.check_output(['sh', file_name, '--list-test-cases'])
|
||||
# Assume test file is responsible for printing identical format of
|
||||
# test case description between --list-test-cases and its OUTCOME.CSV
|
||||
listed = set(map(lambda x: x.rstrip(), listed.splitlines()))
|
||||
for description in listed:
|
||||
self.process_test_case(descriptions, file_name, None, description)
|
||||
|
||||
def walk_compat_sh(self, file_name):
|
||||
"""Iterate over the test cases compat.sh with a similar format."""
|
||||
descriptions = self.new_per_file_state() # pylint: disable=assignment-from-none
|
||||
compat_cmd = ['sh', file_name, '--list-test-case']
|
||||
compat_output = subprocess.check_output(compat_cmd)
|
||||
# Assume compat.sh is responsible for printing identical format of
|
||||
# test case description between --list-test-case and its OUTCOME.CSV
|
||||
description = compat_output.strip().split(b'\n')
|
||||
# idx indicates the number of test case since there is no line number
|
||||
# in `compat.sh` for each test case.
|
||||
for idx, descrip in enumerate(description):
|
||||
self.process_test_case(descriptions, file_name, idx, descrip)
|
||||
for idx, description in enumerate(listed):
|
||||
self.process_test_case(descriptions, file_name, idx, description)
|
||||
|
||||
@staticmethod
|
||||
def collect_test_directories():
|
||||
|
@ -139,12 +130,11 @@ state may override this method.
|
|||
for data_file_name in glob.glob(os.path.join(directory, 'suites',
|
||||
'*.data')):
|
||||
self.walk_test_suite(data_file_name)
|
||||
ssl_opt_sh = os.path.join(directory, 'ssl-opt.sh')
|
||||
if os.path.exists(ssl_opt_sh):
|
||||
self.walk_ssl_opt_sh(ssl_opt_sh)
|
||||
compat_sh = os.path.join(directory, 'compat.sh')
|
||||
if os.path.exists(compat_sh):
|
||||
self.walk_compat_sh(compat_sh)
|
||||
|
||||
for sh_file in ['ssl-opt.sh', 'compat.sh']:
|
||||
sh_file = os.path.join(directory, sh_file)
|
||||
if os.path.exists(sh_file):
|
||||
self.collect_from_script(sh_file)
|
||||
|
||||
class TestDescriptions(TestDescriptionExplorer):
|
||||
"""Collect the available test cases."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue