summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2009-03-15 08:01:09 -0400
committerNed Batchelder <ned@nedbatchelder.com>2009-03-15 08:01:09 -0400
commit89969a52ac0ac3ebd6271ed302d93738f7ddb781 (patch)
tree7058791cc35bef062df585305f4b243250367402
parent9dee3b9cfe4182e9ccf8d4bd548b7fa267abef00 (diff)
downloadpython-coveragepy-git-89969a52ac0ac3ebd6271ed302d93738f7ddb781.tar.gz
Farm tests can be run in clean_only mode, to get rid of junk.
-rw-r--r--Makefile1
-rw-r--r--test/test_farm.py34
2 files changed, 27 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index fa62ba6b..0899d1fe 100644
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,7 @@ clean:
-rm -f .coverage .coverage.*
-rm -f $(TEST_ZIP)
-rm -f setuptools-*.egg
+ python test/test_farm.py clean
lint: clean
python -x /Python25/Scripts/pylint.bat --rcfile=.pylintrc coverage
diff --git a/test/test_farm.py b/test/test_farm.py
index 5967bb85..12d90775 100644
--- a/test/test_farm.py
+++ b/test/test_farm.py
@@ -4,17 +4,18 @@ import filecmp, fnmatch, glob, os, shutil, sys
from coverage.files import FileLocator
-def test_farm():
+def test_farm(clean_only=False):
"""A test-generating function for nose to find and run."""
for fname in glob.glob("test/farm/*/*.py"):
- case = FarmTestCase(fname)
+ case = FarmTestCase(fname, clean_only)
yield (case.execute,)
-
+
class FarmTestCase(object):
- def __init__(self, runpy):
+ def __init__(self, runpy, clean_only=False):
self.dir, self.runpy = os.path.split(runpy)
-
+ self.clean_only = clean_only
+
def cd(self, newdir):
cwd = os.getcwd()
os.chdir(newdir)
@@ -23,8 +24,14 @@ class FarmTestCase(object):
def execute(self):
cwd = self.cd(self.dir)
+ # Prepare a dictionary of globals for the run.py files to use.
fns = "copy run compare clean".split()
- glo = dict([(fn, getattr(self, fn)) for fn in fns])
+ if self.clean_only:
+ glo = dict([(fn, self.noop) for fn in fns])
+ glo['clean'] = self.clean
+ else:
+ glo = dict([(fn, getattr(self, fn)) for fn in fns])
+
execfile(self.runpy, glo)
self.cd(cwd)
@@ -36,6 +43,10 @@ class FarmTestCase(object):
# Functions usable inside farm run.py files
+ def noop(self, *args, **kwargs):
+ """A no-op function to stub out run, copy, etc, when only cleaning."""
+ pass
+
def copy(self, src, dst):
"""Copy a directory."""
@@ -71,5 +82,12 @@ class FarmTestCase(object):
# So that we can run just one farm run.py at a time.
if __name__ == '__main__':
- case = FarmTestCase(sys.argv[1])
- case.execute()
+ op = sys.argv[1]
+ if op == 'run':
+ case = FarmTestCase(sys.argv[2])
+ case.execute()
+ elif op == 'clean':
+ for test in test_farm(clean_only=True):
+ test[0](*test[1:])
+ else:
+ print "Need an operation: run, clean"