Skip to content

Commit

Permalink
Merge pull request #1393 from jedwards4b/test_cli
Browse files Browse the repository at this point in the history
Conforming command line

All command line arguments should conform. I have allowed for one exception, the -value option to xmlquery.

Test suite: scripts_regression_tests.py
Test baseline:
Test namelist changes:
Test status: bit for bit

Fixes #428

User interface changes?: YES, now accepting only conforming command line arguments

Code review:
  • Loading branch information
jgfouca authored May 2, 2017
2 parents c1e5a38 + b552281 commit 505ce67
Show file tree
Hide file tree
Showing 58 changed files with 91 additions and 171 deletions.
4 changes: 1 addition & 3 deletions config/acme/machines/template.case.run
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter
parser.add_argument("--caseroot",
help="Case directory to build")

args = parser.parse_args()

CIME.utils.handle_standard_logging_options(args)
CIME.utils.parse_args_and.parse_args_and_handle_standard_logging_options(args, parser)

if args.caseroot is not None:
os.chdir(args.caseroot)
Expand Down
4 changes: 1 addition & 3 deletions config/acme/machines/template.case.test
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter
parser.add_argument("--caseroot",
help="Case directory to build")

args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)
CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

if args.caseroot is not None:
os.chdir(args.caseroot)
Expand Down
4 changes: 1 addition & 3 deletions config/acme/machines/template.lt_archive
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter
parser.add_argument("--caseroot", default=os.getcwd(),
help="Case directory to build")

args = parser.parse_args()

CIME.utils.handle_standard_logging_options(args)
CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

if args.caseroot is not None:
os.chdir(args.caseroot)
Expand Down
4 changes: 1 addition & 3 deletions config/acme/machines/template.st_archive
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter
parser.add_argument("--caseroot", default=os.getcwd(),
help="Case directory to build")

args = parser.parse_args()

CIME.utils.handle_standard_logging_options(args)
CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

if args.caseroot is not None:
os.chdir(args.caseroot)
Expand Down
4 changes: 1 addition & 3 deletions config/cesm/machines/template.case.run
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter
parser.add_argument("--caseroot",
help="Case directory to build")

args = parser.parse_args()

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

if args.caseroot is not None:
os.chdir(args.caseroot)
Expand Down
4 changes: 1 addition & 3 deletions config/cesm/machines/template.case.test
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter
parser.add_argument("--caseroot",
help="Case directory to build")

args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

if args.caseroot is not None:
os.chdir(args.caseroot)
Expand Down
4 changes: 1 addition & 3 deletions config/cesm/machines/template.lt_archive
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter
parser.add_argument("--caseroot", default=os.getcwd(),
help="Case directory to build")

args = parser.parse_args()

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

if args.caseroot is not None:
os.chdir(args.caseroot)
Expand Down
4 changes: 1 addition & 3 deletions config/cesm/machines/template.st_archive
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter
parser.add_argument("--caseroot", default=os.getcwd(),
help="Case directory to build")

args = parser.parse_args()

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

if args.caseroot is not None:
os.chdir(args.caseroot)
Expand Down
4 changes: 1 addition & 3 deletions scripts/Tools/acme_check_env
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter

CIME.utils.setup_standard_logging_options(parser)

args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

###############################################################################
def check_sh():
Expand Down
4 changes: 1 addition & 3 deletions scripts/Tools/bless_test_results
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter
parser.add_argument("bless_tests", nargs="*",
help="When blessing, limit the bless to tests matching these regex")

args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

expect(not (args.report_only and args.force),
"Makes no sense to use -r and -f simultaneously")
Expand Down
4 changes: 1 addition & 3 deletions scripts/Tools/case.build
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ OR
parser.add_argument("--clean-all", action="store_true",
help="clean all objects including sharedlibobjects that may be used by other builds")

args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

cleanlist = args.clean if args.clean is None or len(args.clean) else comps

Expand Down
4 changes: 1 addition & 3 deletions scripts/Tools/case.cmpgen_namelists
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ OR
help="Force generation to use baselines with this name. "
"Default will be to follow the case specification")

args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

return args.caseroot, args.compare, args.generate, args.compare_name, args.generate_name

Expand Down
4 changes: 1 addition & 3 deletions scripts/Tools/case.setup
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ OR
parser.add_argument("-r", "--reset", action="store_true",
help="Does a clean followed by setup")

args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

return args.caseroot, args.clean, args.test_mode, args.reset

Expand Down
4 changes: 1 addition & 3 deletions scripts/Tools/case.submit
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,10 @@ OR
parser.add_argument("-a", "--batch-args",
help="Used to pass additional arguments to batch system. ")

args = parser.parse_args(args[1:])
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

CIME.utils.expect(args.prereq is None, "--prereq not currently supported")

CIME.utils.handle_standard_logging_options(args)

return args.caseroot, args.job, args.no_batch, args.resubmit, args.batch_args

###############################################################################
Expand Down
4 changes: 1 addition & 3 deletions scripts/Tools/case_diff
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter
parser.add_argument("-b", "--show-binary", action="store_true",
help="Show binary diffs")

args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

return args.case1, args.case2, args.show_binary, args.skip_list

Expand Down
5 changes: 1 addition & 4 deletions scripts/Tools/check_case
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter

CIME.utils.setup_standard_logging_options(parser)

args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

###############################################################################
def _main_func(description):
Expand Down Expand Up @@ -68,4 +66,3 @@ def _main_func(description):

if __name__ == "__main__":
_main_func(__doc__)

5 changes: 1 addition & 4 deletions scripts/Tools/check_input_data
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter
parser.add_argument("--download", action="store_true",
help="Attempt to download missing input files")

args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

return args.svn_loc, args.input_data_root, args.data_list_dir, args.download

Expand All @@ -78,4 +76,3 @@ def _main_func(description):

if (__name__ == "__main__"):
_main_func(__doc__)

4 changes: 1 addition & 3 deletions scripts/Tools/check_lockedfiles
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ OR
parser.add_argument("--caseroot", default=os.getcwd(),
help="Case directory to build")

args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

return args.caseroot

Expand Down
4 changes: 1 addition & 3 deletions scripts/Tools/cime_bisect
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter
parser.add_argument("-a", "--all-commits", action="store_true",
help="Test all commits, not just merges")

args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

if (args.test_root is None):
args.test_root = os.path.join(_MACHINE.get_value("CIME_OUTPUT_ROOT"), "cime_bisect")
Expand Down
4 changes: 1 addition & 3 deletions scripts/Tools/code_checker
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter
parser.add_argument("files", nargs="*",
help="Restrict checking to specific files. Relative name is fine.")

args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

return args.num_procs, args.files

Expand Down
4 changes: 1 addition & 3 deletions scripts/Tools/compare_namelists
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter
parser.add_argument("-c", "--case", action="store", dest="case", default=None,
help="The case base id (<TESTCASE>.<GRID>.<COMPSET>). Helps us normalize data.")

args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

# Normalize case
if (args.case is not None):
Expand Down
4 changes: 1 addition & 3 deletions scripts/Tools/compare_test_results
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter
parser.add_argument("compare_tests", nargs="*",
help="When comparing, limit the comparison to tests matching these regex")

args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

return args.baseline_name, args.baseline_root, args.test_root, args.compiler, args.test_id, args.compare_tests, args.namelists_only, args.hist_only

Expand Down
4 changes: 1 addition & 3 deletions scripts/Tools/component_compare_baseline
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ OR
parser.add_argument("-b", "--baseline-dir",
help="Use custom baseline dir")

args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

return args.caseroot, args.baseline_dir

Expand Down
4 changes: 1 addition & 3 deletions scripts/Tools/component_compare_copy
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ OR
parser.add_argument("caseroot", nargs="?", default=os.getcwd(),
help="Case directory")

args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

return args.suffix, args.caseroot

Expand Down
4 changes: 1 addition & 3 deletions scripts/Tools/component_compare_test
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ OR
parser.add_argument("caseroot", nargs="?", default=os.getcwd(),
help="Case directory")

args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

return args.suffix1, args.suffix2, args.caseroot

Expand Down
4 changes: 1 addition & 3 deletions scripts/Tools/component_generate_baseline
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ OR
"will raise an error. Specifying this option allows "
"existing baseline directories to be silently overwritten.")

args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

return args.caseroot, args.baseline_dir, args.allow_baseline_overwrite

Expand Down
4 changes: 2 additions & 2 deletions scripts/Tools/getTiming
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def parse_command_line(args, description):
default="999999-999999")
parser.add_argument("--caseroot", default=os.getcwd(),
help="Case directory to get timing for")
args = parser.parse_args(args[1:])
CIME.utils.handle_standard_logging_options(args)

args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)
return args.caseroot, args.lid

def __main_func(description):
Expand Down
4 changes: 1 addition & 3 deletions scripts/Tools/jenkins_generic_job
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter
help="Number of tasks create_test should perform simultaneously. Default "
"will be min(num_cores, num_tests).")

args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

expect(not (args.submit_to_cdash and args.generate_baselines),
"Does not make sense to use --generate-baselines and --submit-to-cdash together")
Expand Down
4 changes: 1 addition & 3 deletions scripts/Tools/list_acme_tests
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter
parser.add_argument("categories", nargs="*",
help="The test categories to list. Default will list all. Test categories: %s" % (", ".join(update_acme_tests.get_test_suites())))

args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

if (not args.categories):
args.categories = update_acme_tests.get_test_suites()
Expand Down
4 changes: 1 addition & 3 deletions scripts/Tools/normalize_cases
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter

parser.add_argument("case2", help="Second case. This one will not be changed")

args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

return args.case1, args.case2

Expand Down
4 changes: 1 addition & 3 deletions scripts/Tools/pelayout
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ def parse_command_line(args):
parser.add_argument("-caseroot" , "--caseroot", default=os.getcwd(),
help="Case directory to reference")

args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

if (args.no_header):
args.header = None
Expand Down
4 changes: 1 addition & 3 deletions scripts/Tools/preview_namelists
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ def parse_command_line(args, description):
parser.add_argument('--test', action='store_true',
help="Run preview_namelist in test mode.")

args = parser.parse_args()

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

return args

Expand Down
4 changes: 1 addition & 3 deletions scripts/Tools/save_provenance
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ OR
parser.add_argument("-l", "--lid",
help="Force system to save provenance with this LID")

args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

return args.mode, args.caseroot, args.lid

Expand Down
4 changes: 1 addition & 3 deletions scripts/Tools/simple_compare
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter
parser.add_argument("-c", "--case", action="store", dest="case", default=None,
help="The case base id (<TESTCASE>.<GRID>.<COMPSET>). Helps us normalize data.")

args = parser.parse_args(args[1:])

CIME.utils.handle_standard_logging_options(args)
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)

# Normalize case
if (args.case is not None):
Expand Down
2 changes: 1 addition & 1 deletion scripts/Tools/testreporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def parse_command_line(args):
parser.add_argument("--dumpxml",action="store_true",
help="Dump XML test results to sceen.")
args = parser.parse_args()
CIME.utils.handle_standard_logging_options(args)
CIME.utils.parse_args_and_handle_standard_logging_options(args)


return args.testroot, args.testid, args.tagname, args.testtype, args.dryrun, args.dumpxml
Expand Down
Loading

0 comments on commit 505ce67

Please sign in to comment.