[pitivi: 33/65] Specified in Makefile.am which tests should be run and simplified runtests. This change will make su



commit abfa76d4c55a8875b4bea9fdbbac1c4b9c2e8bcd
Author: Alex BÄluÈ <alexandru balut gmail com>
Date:   Thu Jun 9 12:09:27 2011 +0200

    Specified in Makefile.am which tests should be run and simplified runtests.
    This change will make sure that new test files will be added to the list of tests which are included in the distribution package, otherwise now they won't run when running 'make check'.

 tests/Makefile.am |   15 +++++++++------
 tests/runtests.py |   39 ++++++++++-----------------------------
 2 files changed, 19 insertions(+), 35 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5c65fb0..46174dd 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,5 +1,5 @@
 
-# Please keep the test list below ordered.
+# Please keep the test lists below ordered.
 
 tests = \
 	test_action.py \
@@ -15,7 +15,6 @@ tests = \
 	test_factories_file.py \
 	test_factories_operation.py \
 	test_gap.py \
-	test_integration.py \
 	test_pipeline_action.py \
 	test_pipeline.py \
 	test_projectmanager.py \
@@ -23,7 +22,6 @@ tests = \
 	test_settings.py \
 	test_signallable.py \
 	test_sourcelist.py \
-	test_still_image.py \
 	test_stream.py \
 	test_timeline_factory.py \
 	test_timeline.py \
@@ -33,6 +31,10 @@ tests = \
 	test_undo.py \
 	test_utils.py
 
+integration_tests = \
+	test_integration.py \
+	test_still_image.py
+
 EXTRA_DIST = \
 	__init__.py \
 	common.py \
@@ -43,11 +45,12 @@ clean-local:
 	rm -f testProject.ptv testproject.xptv testproject2.xptv
 
 check-local:
-	@PYTHONPATH=$(top_srcdir):$(PYTHONPATH) $(PYTHON) $(srcdir)/runtests.py
+	@PYTHONPATH=$(top_srcdir):$(PYTHONPATH) $(PYTHON) $(srcdir)/runtests.py \
+		$(tests)
 
 %.check: %
 	@PYTHONPATH=$(top_srcdir):$(PYTHONPATH) $(PYTHON) $(srcdir)/runtests.py $*
 
 check-integration:
-	@PYTHONPATH=$(top_srcdir):$(PYTHONPATH) TEST_INTEGRATION=1 $(PYTHON)\
-        $(srcdir)/runtests.py
+	@PYTHONPATH=$(top_srcdir):$(PYTHONPATH) $(PYTHON) $(srcdir)/runtests.py \
+		$(integration_tests)
diff --git a/tests/runtests.py b/tests/runtests.py
index 3eb4742..2a960c2 100644
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -1,44 +1,25 @@
-import glob
 import os
 import sys
 import unittest
-import tests
 
-SKIP_FILES = ['common', 'runtests']  # They are not testsuites
-#Those files need sample files, and therefore shoud not be tested
-#when running distcheck
-INTEGRATION_FILES = ['test_still_image', 'test_integration']
 
+def gettestnames(file_names):
+    test_names = [file_name[:-3] for file_name in file_names]
+    return test_names
 
-def gettestnames(which):
-    if os.getenv("TEST_INTEGRATION"):
-        return INTEGRATION_FILES
-    else:
-        SKIP_FILES.extend(INTEGRATION_FILES)
-
-    if not which:
-        dir = os.path.split(os.path.abspath(__file__))[0]
-        which = [os.path.basename(p) for p in glob.glob('%s/test_*.py' % dir)]
-
-    names = map(lambda x: x[:-3], which)
-    for f in SKIP_FILES:
-        if f in names:
-            names.remove(f)
-    return names
-
-suite = unittest.TestSuite()
 loader = unittest.TestLoader()
 
+# Pick which tests to run.
 TEST_CASE = os.getenv("TESTCASE")
-
 if TEST_CASE:
-    suite.addTest(loader.loadTestsFromName(TEST_CASE))
-    if not suite._tests:
-        raise Exception("could not find test case %r" % TEST_CASE)
+    test_names = [TEST_CASE]
 else:
-    for name in gettestnames(sys.argv[1:]):
-        suite.addTest(loader.loadTestsFromName(name))
+    test_names = gettestnames(sys.argv[1:])
+suite = loader.loadTestsFromNames(test_names)
+if not list(suite):
+    raise Exception("No tests found")
 
+# Set verbosity.
 descriptions = 1
 verbosity = 1
 if 'VERBOSE' in os.environ:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]