From bba169c1f4f8ca957d5edeaeae187bee1612141a Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Tue, 13 Mar 2018 15:02:09 -0700 Subject: [PATCH] autorun_post: refactor doc collection function This will be useful for other directories where we only want to keep one copy. Change-Id: Iac3cf964936e03c1164ffd961cf8c35a24db5f31 Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/403739 Reviewed-by: Seth Howell Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris --- autorun_post.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/autorun_post.py b/autorun_post.py index 8467ef67c..5abab6c5f 100755 --- a/autorun_post.py +++ b/autorun_post.py @@ -50,17 +50,19 @@ def generateCoverageReport(output_dir, repo_dir): print(e, file=log_file) -def prepDocumentation(output_dir, repo_dir): - # Find one instance of 'doc' output directory and move it to the top level - docDirs = glob.glob(os.path.join(output_dir, '*', 'doc')) - docDirs.sort() - if len(docDirs) == 0: +def collectOne(output_dir, dir_name): + dirs = glob.glob(os.path.join(output_dir, '*', dir_name)) + dirs.sort() + if len(dirs) == 0: return - print("docDirs: ", docDirs) - docDir = docDirs[0] - print("docDir: ", docDir) - shutil.move(docDir, os.path.join(output_dir, 'doc')) + # Collect first instance of dir_name and move it to the top level + collect_dir = dirs.pop(0) + shutil.move(collect_dir, os.path.join(output_dir, dir_name)) + + # Delete all other instances + for d in dirs: + shutil.rmtree(d) def aggregateCompletedTests(output_dir, repo_dir): @@ -129,7 +131,7 @@ def aggregateCompletedTests(output_dir, repo_dir): def main(output_dir, repo_dir): generateCoverageReport(output_dir, repo_dir) - prepDocumentation(output_dir, repo_dir) + collectOne(output_dir, 'doc') aggregateCompletedTests(output_dir, repo_dir)