Skip to content

Commit

Permalink
get clean working for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards4b committed Feb 14, 2017
1 parent 28f88da commit 718af25
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
4 changes: 3 additions & 1 deletion scripts/Tools/case.build
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ OR

CIME.utils.handle_standard_logging_options(args)

return args.caseroot, args.sharedlib_only, args.model_only, args.clean, args.clean_all
cleanlist = args.clean if args.clean is None or len(args.clean) else comps

return args.caseroot, args.sharedlib_only, args.model_only, cleanlist, args.clean_all

###############################################################################
def _main_func(description):
Expand Down
2 changes: 1 addition & 1 deletion utils/python/CIME/SystemTests/system_tests_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def build_indv(self, sharedlib_only=False, model_only=False):
sharedlib_only=sharedlib_only, model_only=model_only)

def clean_build(self, comps=None):
build.clean(self._case, cleanlist=comps)
build.clean(self._case, cleanlist=comps if comps is not None else [])

def run(self):
"""
Expand Down
23 changes: 17 additions & 6 deletions utils/python/CIME/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,21 +508,32 @@ def _build_model_thread(config_dir, compclass, caseroot, libroot, bldroot, incro
for mod_file in glob.glob(os.path.join(bldroot, "*_[Cc][Oo][Mm][Pp]_*.mod")):
shutil.copy(mod_file, incroot)

def cleantree(base, ignoredirs=None):
"""
clean all files below base level, leave directories and top level files
"""
ignoredirs.append(base)
for root, _, files in os.walk(base, topdown=False):
if root not in ignoredirs:
for name in files:
os.remove(os.path.join(root, name))


###############################################################################
def clean(case, cleanlist=None, clean_all=False):
###############################################################################
caseroot = case.get_value("CASEROOT")
if clean_all or cleanlist is not None and len(cleanlist) == 0:
if clean_all:
# If cleanlist is empty just remove the bld directory
exeroot = case.get_value("EXEROOT")
if os.path.isdir(exeroot):
logging.info("removing directory %s" %exeroot)
shutil.rmtree(case.get_value("EXEROOT"))
logging.info("cleaning directory %s" %exeroot)
cleantree(exeroot, ignoredirs=[os.path.join(exeroot,"lib")])
# if clean_all is True also remove the sharedlibpath
sharedlibroot = case.get_value("SHAREDLIBROOT")
if clean_all and os.path.isdir(sharedlibroot):
logging.info("removing directory %s" %sharedlibroot)
shutil.rmtree(sharedlibroot)
if sharedlibroot != exeroot and os.path.isdir(sharedlibroot):
logging.warn("cleaning directory %s" %sharedlibroot)
cleantree(sharedlibroot)
else:
debug = case.get_value("DEBUG")
use_esmf_lib = case.get_value("USE_ESMF_LIB")
Expand Down

0 comments on commit 718af25

Please sign in to comment.