From 1c2d0b271c7a9b3eb970abdd8dca43e23370d5b6 Mon Sep 17 00:00:00 2001
From: Andreas Jaeger <aj@suse.de>
Date: Sat, 2 Nov 2013 17:19:15 +0100
Subject: [PATCH] Cleanup for test.py

Remove validate.py from special files since it does not exist anymore
Update comments
Only remove ~/.fop once per test.py invocation and not for every
build

Change-Id: I7ea037ba6fe1f3132a454df6636ff701a1e39c13
---
 tools/test.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/tools/test.py b/tools/test.py
index 220547d594..90e5cca11a 100755
--- a/tools/test.py
+++ b/tools/test.py
@@ -142,7 +142,6 @@ def error_message(error_log):
     return "\n".join(errs)
 
 
-# Check whether only files in www got updated
 def only_www_touched():
     """Check whether only files in www directory are touched"""
 
@@ -164,7 +163,6 @@ def only_www_touched():
     return www_changed and not other_changed
 
 
-# Check whether only files in www got updated
 def ha_guide_touched():
     """Check whether files in high-availability-guide directory are touched"""
 
@@ -200,7 +198,6 @@ def check_modified_affects_all(rootdir, verbose):
         sys.exit(1)
 
     special_files = [
-        "tools/validate.py",
         "tools/test.py",
         "doc/pom.xml"
     ]
@@ -431,13 +428,14 @@ def logging_build_book(result):
 def build_book(book):
     """Build book(s) in directory book"""
 
+    # Note that we cannot build in parallel several books in the same
+    # directory like the Install Guide. Thus we build sequentially per
+    # directory.
     os.chdir(book)
     result = True
     returncode = 0
     base_book = os.path.basename(book)
     try:
-        shutil.rmtree(os.path.expanduser("~/.fop"),
-                      ignore_errors=True)
         # Clean first and then build so that the output of all guides
         # is available
         output = subprocess.check_output(
@@ -648,6 +646,11 @@ def build_affected_books(rootdir, book_exceptions,
 
     books = find_affected_books(rootdir, book_exceptions,
                                 verbose, force)
+
+    # Remove cache content which can cause build failures
+    shutil.rmtree(os.path.expanduser("~/.fop"),
+                  ignore_errors=True)
+
     maxjobs = multiprocessing.cpu_count()
     # Jenkins fails sometimes with errors if too many jobs run, artificially
     # limit to 4 for now.