[Checkins] SVN: grokproject/trunk/ Merge changes from ulif-shorttest into trunk.

Uli Fouquet uli at gnufix.de
Sat Jan 24 08:52:04 EST 2009


Log message for revision 94979:
  Merge changes from ulif-shorttest into trunk.

Changed:
  A   grokproject/trunk/README-shorttests.txt
  U   grokproject/trunk/tests.py
  U   grokproject/trunk/tests_paste.txt
  U   grokproject/trunk/tests_zopectl.txt

-=-
Copied: grokproject/trunk/README-shorttests.txt (from rev 94978, grokproject/branches/ulif-shorttests/README-shorttests.txt)
===================================================================
--- grokproject/trunk/README-shorttests.txt	                        (rev 0)
+++ grokproject/trunk/README-shorttests.txt	2009-01-24 13:52:03 UTC (rev 94979)
@@ -0,0 +1,28 @@
+Shortening test runs
+********************
+
+By default testruns of `grokproject` take a huge amount of time.
+
+This is primarily caused by eggs, which are downloaded and installed
+in freshly created eggs directories during test runs. A complete set
+of eggs is downloaded and installed at least two times during each
+run.
+
+Most time is taken by compiling and installing all the eggs.
+
+We can reduce this large amount of time by skipping recreation of
+eggs-directories between single tests and between test runs.
+
+This can be forced by creating a file 'shorttests' in this directory,
+which, if it exists, cares for leaving an existing eggs dir
+untouched. You can create such a file like this::
+
+  $ touch shorttests
+
+Note, that the first run, however, will take much time but subsequent
+runs will be much shorter (by factor 10 or more).
+
+Before submitting to the repository you might want to run the 'full'
+tests again, which can be done by removing the marker file::
+
+  $ rm shorttests

Modified: grokproject/trunk/tests.py
===================================================================
--- grokproject/trunk/tests.py	2009-01-24 13:48:29 UTC (rev 94978)
+++ grokproject/trunk/tests.py	2009-01-24 13:52:03 UTC (rev 94979)
@@ -69,6 +69,57 @@
     filename = os.path.join(*args)
     open(filename, 'w').write(kwargs.get('data',''))
 
+def shorttests(show_message=False):
+    shorttestfile = os.path.join(
+        os.path.dirname(__file__), 'shorttests')
+    if not show_message:
+        return os.path.exists(shorttestfile)
+    if os.path.exists(shorttestfile):
+        print
+        print "WARNING: running shorttests."
+        print "  This reduces the runtime of testruns by making use of"
+        print "  a once filled eggs directory."
+        print "  If you want clean test runs with an empty eggs directory,"
+        print "  remove the file"
+        print "    " + os.path.join(__file__, 'shorttests')
+        print "  Running shorttests might lead to failing tests. Please run"
+        print "  the full tests before submitting code."
+        print
+    else:
+        print
+        print "NOTE: running full tests."
+        print "  If you want to reuse a prefilled eggs directory between"
+        print "  test runs (which dramatically reduces runtime), create a"
+        print "  file "
+        print "    " + shorttestfile
+        print "  and rerun the tests."
+        print
+    return os.path.exists(shorttestfile)
+
+def maybe_mkdir(path):
+    """Create a directory `path` conditionally.
+
+    If the dir already exists and `shorttest()` is ``True`` we leave
+    the directory untouched.
+
+    Otherwise any old file/directory with path `path` is removed and
+    recreated.
+    """
+    if shorttests() and os.path.isdir(path):
+        return
+    rmdir(path)
+    os.makedirs(path)
+
+def maybe_rmdir(path):
+    """Remove a directory conditionally.
+
+    If `shorttest()` is True, we do not remove the directory.
+    """
+    if shorttests() and os.path.isdir(path):
+        return
+    rmdir(path)
+    
+
 execdir = os.path.abspath(os.path.dirname(sys.executable))
 tempdir = os.getenv('TEMP','/tmp')
 
@@ -98,6 +149,7 @@
 
 def test_suite():
     """returns the test suite"""
+    short = shorttests(show_message=True)
     return doc_suite(current_dir)
 
 if __name__ == '__main__':

Modified: grokproject/trunk/tests_paste.txt
===================================================================
--- grokproject/trunk/tests_paste.txt	2009-01-24 13:48:29 UTC (rev 94978)
+++ grokproject/trunk/tests_paste.txt	2009-01-24 13:52:03 UTC (rev 94979)
@@ -11,12 +11,12 @@
 
 Create an empty eggs directory. So we make sure that we don't have to
 care for arbitrary eggs, that were installed in the user's environment
-before::
+before. If this directory contains a file ``shorttests`` and the eggs
+directory exists already, then we leave it untouched::
 
     >>> tempeggs = 'grokexample-eggs'
     >>> eggsdir = os.path.join(tempdir, tempeggs)
-    >>> rmdir(eggsdir)
-    >>> os.makedirs(eggsdir)
+    >>> maybe_mkdir(eggsdir)
 
 Then use paster. Eggs are placed in our freshly created eggs directory::
 
@@ -250,4 +250,4 @@
 
     >>> cd(tempdir)
     >>> rmdir('GrokExample')
-    >>> rmdir(eggsdir)
+    >>> maybe_rmdir(eggsdir)

Modified: grokproject/trunk/tests_zopectl.txt
===================================================================
--- grokproject/trunk/tests_zopectl.txt	2009-01-24 13:48:29 UTC (rev 94978)
+++ grokproject/trunk/tests_zopectl.txt	2009-01-24 13:52:03 UTC (rev 94979)
@@ -11,12 +11,12 @@
 
 Create an empty eggs directory. So we make sure that we don't have to
 care for arbitrary eggs, that were installed in the user's environment
-before::
+before. If a file ``shorttests`` exists in this directory, we do not
+create a new dir but make only sure it exists and leave it untouched::
 
     >>> tempeggs = 'grokexample-eggs'
     >>> eggsdir = os.path.join(tempdir, tempeggs)
-    >>> rmdir(eggsdir)
-    >>> os.makedirs(eggsdir)
+    >>> maybe_mkdir(eggsdir)
 
 Then use paster. Eggs are placed in our freshly created eggs directory::
 
@@ -217,4 +217,4 @@
 
     >>> cd(tempdir)
     >>> rmdir('grokexample')
-    >>> rmdir(eggsdir)
+    >>> maybe_rmdir(eggsdir)



More information about the Checkins mailing list