[Avida-cvs] [avida-svn] r710 - development/source/testsuites

kaben@myxo.css.msu.edu kaben at myxo.css.msu.edu
Sat May 27 00:33:44 PDT 2006


Author: kaben
Date: 2006-05-27 03:33:44 -0400 (Sat, 27 May 2006)
New Revision: 710

Modified:
   development/source/testsuites/SConscript
Log:

Some cleanups of unit testing under SCons.
To run full unit tests, type "./BuildAvida.py test-full-unit-tests".
(yeah, it's redundant...)



Modified: development/source/testsuites/SConscript
===================================================================
--- development/source/testsuites/SConscript	2006-05-27 07:05:19 UTC (rev 709)
+++ development/source/testsuites/SConscript	2006-05-27 07:33:44 UTC (rev 710)
@@ -3,46 +3,44 @@
 import tempfile
 
 
-def PhonyTarget(alias, action, depends = None):
-  """Returns an alias to a command that performs the action.
-  Implementated by a Command with a nonexistant file target.  This command will
-  run on every build, and will never be considered 'up to date'. Acts like a
-  'phony' target in make.
-  """
-  phony_file = os.path.normpath(tempfile.mktemp(prefix="phony_%s_" % alias, dir="."))
-  Depends(phony_file, depends)
-  return Alias(alias, Command(target=phony_file, source=None, action=action))
+def Test(env, name, *args, **kw):
+  """Creates unit test.
 
-def Test(env, prg):
-  """Creates unit test from given program.
-  When unit test passes, a file stamp is made. If it ran successfully and there
-  is nothing changed, the unit test can be skipped next time.
+  env: an SCons environment.
+  remaining parameters: are passed directly to SCons 'Program' builder,
+  and typically include first a program name, then a list of source
+  files, and then optional arguments such as library specifications.
 
-  Makes three alii: the name of program, force-test, and test-changed:
-  - First can be used to run individual unit test.
-  - Second forces all unit tests to run.
-  - Third is used to run unit tests that changed or whose dependencies changed.
+  Makes two alii: 'test-' plus the name of the test program, and
+  'test-all':
+  - first can be used to run individual unit test.
+  - second runs all test programs.
   """
-  name = str(prg[0])
-  stamp = name + '.passed'
-  env.UnitTest(stamp, prg)
-  alias = PhonyTarget(name, [prg], stamp)
-  env.Alias('force-test', name)
-  env.Alias('test-changed', stamp)
+  prg = env.Program(name, *args, **kw)
+  name = 'test-' + str(prg[0])
+  path = prg[0].path
+  env.AlwaysBuild(env.Alias(name, [prg], path))
+  env.AlwaysBuild(env.Alias('test-all', [prg], path))
 
-
-
-
 Import('environment')
 
-full_unit_tests = environment.Program('full-unit-tests', 'full-unit-tests.cc',
-  LIBS = [ 'main', 'classification', 'cpu', 'event', 'analyze', 'drivers', 'analyze', 'cpu', 'tools', 'actions', 'main', 'archive', 'boost_serialization', ],
-)
-Test(environment, full_unit_tests)
+all_libs = [
+  'main',
+  'classification',
+  'cpu',
+  'event',
+  'analyze',
+  'drivers',
+  'analyze',
+  'cpu',
+  'tools',
+  'actions',
+  'main',
+  'archive',
+  'boost_serialization',
+]
 
-cInitFile_unit_tests = environment.Program('cInitFile-unit-tests', 'cInitFile-unit-tests.cc',
-  LIBS = [ 'main', 'classification', 'cpu', 'event', 'analyze', 'drivers', 'analyze', 'cpu', 'tools', 'actions', 'main', 'archive', 'boost_serialization', ],
-)
-Test(environment, cInitFile_unit_tests)
+Test(environment, 'full-unit-tests', 'full-unit-tests.cc', LIBS = all_libs)
+Test(environment, 'cInitFile-unit-tests', 'cInitFile-unit-tests.cc', LIBS = all_libs)
 
 # vim: set ft=python:




More information about the Avida-cvs mailing list