Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions testing_and_setup/compass/clean_testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
It will remove directories / driver scripts that were generated as part of
setting up a test case.
"""

from __future__ import absolute_import, division, print_function, \
unicode_literals

import sys
import os
import shutil
Expand All @@ -21,7 +25,7 @@
description=__doc__, formatter_class=argparse.RawTextHelpFormatter)

parser.add_argument("-o", "--core", dest="core",
help="Core that conatins configurations to clean",
help="Core that contains configurations to clean",
metavar="CORE")
parser.add_argument("-c", "--configuration", dest="configuration",
help="Configuration to clean", metavar="CONFIG")
Expand Down Expand Up @@ -51,16 +55,16 @@
if not args.case_num and (not args.core and not args.configuration and
not args.resolution and not args.test) \
and not args.clean_all:
print 'Must be run with either the --case_number argument, the ' \
'--all argument, or all of the core, configuration, ' \
'resolution, and test arguments.'
print('Must be run with either the --case_number argument, the '
'--all argument, or all of the core, configuration, '
'resolution, and test arguments.')
parser.error(' Invalid configuration. Exiting...')

if args.case_num and args.core and args.configuration and args.resoltuion \
and args.test and args.clean_all:
print 'Can only be configured with either --case_number (-n), --all ' \
'(-a), or all of --core (-o), --configuration (-c), ' \
'--resolution (-r), and --test (-t).'
print('Can only be configured with either --case_number (-n), --all '
'(-a), or all of --core (-o), --configuration (-c), '
'--resolution (-r), and --test (-t).')
parser.error(' Invalid configuration. Too many options used. '
'Exiting...')

Expand Down Expand Up @@ -153,8 +157,8 @@
if os.path.isdir('{}/{}'.format(work_dir, case_base)):
shutil.rmtree('{}/{}'.format(work_dir, case_base))
write_history = True
print ' -- Removed case {}/{}'.format(work_dir,
case_base)
print(' -- Removed case {}/{}'.format(work_dir,
case_base))

# Process <driver_script> files
elif config_root.tag == 'driver_script':
Expand All @@ -164,8 +168,8 @@
if os.path.exists('{}/{}'.format(work_dir, script_name)):
os.remove('{}/{}'.format(work_dir, script_name))
write_history = True
print ' -- Removed driver script ' \
'{}/{}'.format(work_dir, script_name)
print(' -- Removed driver script '
'{}/{}'.format(work_dir, script_name))

del config_tree
del config_root
Expand Down
50 changes: 20 additions & 30 deletions testing_and_setup/compass/list_testcases.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@
it will only print the flags needed to setup that specific test case.
"""

from __future__ import absolute_import, division, print_function, \
unicode_literals

import os
import fnmatch
import argparse
import xml.etree.ElementTree as ET
import re


def print_case(quiet, args, core_dir, config_dir, res_dir, test_dir, case_num,
print_num): # {{{
# Xylar: the indentation got out of hand and I had to make this a function
def print_case(quiet, args, core_dir, config_dir, res_dir, test_dir, case_num):

# Print the options if a case file was found.
if not quiet:
Expand All @@ -30,16 +31,14 @@ def print_case(quiet, args, core_dir, config_dir, res_dir, test_dir, case_num,
config_dir):
if (not args.resolution) or re.match(args.resolution, res_dir):
if (not args.test) or re.match(args.test, test_dir):
print " {:d}: -o {} -c {} -r {} -t {}".format(
case_num, core_dir, config_dir, res_dir, test_dir)
if quiet and case_num == print_num:
print "-o {} -c {} -r {} -t {}".format(
core_dir, config_dir, res_dir, test_dir)
print(" {:d}: -o {} -c {} -r {} -t {}".format(
case_num, core_dir, config_dir, res_dir, test_dir))
if quiet and case_num == args.number:
print("-o {} -c {} -r {} -t {}".format(
core_dir, config_dir, res_dir, test_dir))
case_num += 1
return case_num

# }}}


if __name__ == "__main__":
# Define and process input arguments
Expand All @@ -55,25 +54,16 @@ def print_case(quiet, args, core_dir, config_dir, res_dir, test_dir, case_num,
help="Resolution to search for", metavar="RES")
parser.add_argument("-t", "--test", dest="test",
help="Test name to search for", metavar="TEST")
parser.add_argument("-n", "--number", dest="number",
parser.add_argument("-n", "--number", dest="number", type=int,
help="If set, script will print the flags to use a "
"the N'th configuraiton.")
"the N'th configuration.")

args = parser.parse_args()

quiet = False

try:
print_num = 0
if args.number:
quiet = True
print_num = int(args.number)
except ValueError:
args.number = 0
print_num = 0
quiet = args.number is not None

if not quiet:
print "Available test cases are:"
print("Available test cases are:")

# Start case numbering at 1
case_num = 1
Expand All @@ -82,23 +72,24 @@ def print_case(quiet, args, core_dir, config_dir, res_dir, test_dir, case_num,
os.chdir(script_path)

# Iterate over all cores
for core_dir in os.listdir('.'):
for core_dir in sorted(os.listdir('.')):
if os.path.isdir(core_dir) and core_dir != '.git':
# Iterate over all configurations within a core
for config_dir in os.listdir(core_dir):
for config_dir in sorted(os.listdir(core_dir)):
config_path = '{}/{}'.format(core_dir, config_dir)
if os.path.isdir(config_path):
# Iterate over all resolutions within a configuration
for res_dir in os.listdir(config_path):
for res_dir in sorted(os.listdir(config_path)):
res_path = '{}/{}'.format(config_path, res_dir)
if os.path.isdir(res_path):
# Iterate over all tests within a resolution
for test_dir in os.listdir(res_path):
for test_dir in sorted(os.listdir(res_path)):
test_path = '{}/{}'.format(res_path, test_dir)
if os.path.isdir(test_path):
do_print = False
# Iterate over all files within a test
for case_file in os.listdir(test_path):
for case_file in sorted(
os.listdir(test_path)):
if fnmatch.fnmatch(case_file, '*.xml'):
tree = ET.parse('{}/{}'.format(
test_path, case_file))
Expand All @@ -118,7 +109,6 @@ def print_case(quiet, args, core_dir, config_dir, res_dir, test_dir, case_num,
if do_print:
case_num = print_case(
quiet, args, core_dir, config_dir,
res_dir, test_dir, case_num,
print_num)
res_dir, test_dir, case_num)

# vim: foldmethod=marker ai ts=4 sts=4 et sw=4 ft=python
Loading