matches.append(os.path.join(root, filename))
return matches
+# Helper function to build scheme programs and test runners
+def SchemeBuildAndTest(target,sources,tests):
+ # Figure out the target names
+ test_runner = target + '_tests'
+ test_output = target + '_results'
+ test_sources = [e for e in sources if not e.endswith('main.scm')] + tests
+ # Create the targets
+ scheme.Program( target, sources )
+ scheme.Program( test_runner, test_sources )
+ RunTest( test_output, test_runner )
+
+# Helper function to run a test suite and generate a log file
+def RunTest( output, runner ):
+ runner_exe = runner + ('.exe' if (platform.system() == 'Windows') else '')
+ cmd = os.path.basename(runner_exe)
+ scheme.Command( output, runner_exe, cmd + ' > $TARGET')
+
#------------------------------------------------------------------------------
# Compiler Environments
#------------------------------------------------------------------------------
src_suffix = '.o',
src_builder = [ scheme_compiler ])
-# Scheme Test Linker
-scheme_tester = Builder(
- action = 'csc $LDFLAGS -o $TARGET $SOURCES && $TARGET',
- suffix = "$PROGSUFFIX",
- src_suffix = '.o',
- src_builder = [ scheme_compiler ])
-
# Create the Environment for this project
scheme = Environment(
ENV = os.environ,
CCFLAGS = [ '-explicit-use', '-I', 'inc'],
LDFLAGS = [],
TOOLS = [ 'mingw' ],
- BUILDERS = {
- 'Program': scheme_linker,
- 'TestRunner': scheme_tester })
+ BUILDERS = { 'Program': scheme_linker })
+scheme.PrependENVPath('PATH', './build')
#------------------------------------------------------------------------------
# SCLPL Targets
readsof.Depends('readsof', 'sof')
# SCLPL Compiler
-scheme.Program('build/slc', find_files('source/compiler/','*.scm'))
+SchemeBuildAndTest( 'build/slc',
+ find_files('source/compiler/','*.scm'),
+ find_files('tests/compiler/','*.scm') )
# SCLPL Package Manager
-scheme.Program('build/slpkg', find_files('source/slpkg/','*.scm'))
+SchemeBuildAndTest( 'build/slpkg',
+ find_files('source/slpkg/','*.scm'),
+ find_files('tests/slpkg/','*.scm') )
# SCLPL Assembler
-scheme.Program('build/slas', find_files('source/slas/','*.scm'))
+SchemeBuildAndTest( 'build/slas',
+ find_files('source/slas/','*.scm'),
+ find_files('tests/slas/','*.scm') )
# SCLPL Virtual Machine
c_cpp.Program('build/slvm', find_files('source/slvm/','*.c'))
+++ /dev/null
-(declare (unit test))
-
-(define unit-tests '())
-
-(define (register-test! test)
- (set! unit-tests (cons test unit-tests)))
-
-(define (print-summary pass fail)
- (if (zero? fail)
- (print "Success: " pass " tests passed.")
- (print "Failure: " fail " / " (+ pass fail) " tests failed.")))
-
-(define (run-all-unit-tests)
- (run-tests 0 0 (reverse unit-tests)))
-
-(define (run-tests pass fail tests)
- (if (null? tests)
- (print-summary pass fail)
- (if (run-test (car tests))
- (run-tests (+ 1 pass) fail (cdr tests))
- (run-tests pass (+ 1 fail) (cdr tests)))))
-
-(define (run-test test)
- (if (null? test)
- (error "Invalid test definition")
- (case (run-test-fn (cdr test))
- ('pass #t)
- ('fail (print "FAIL: " (car test)) #f)
- ('error (print "ERROR: " (car test)) #f)
- ('exception (print "EXCEPTION: " (car test)) #f)
- (else (print "UNKNOWN: " (car test)) #f))))
-
-(define (run-test-fn fn)
- (define preverr error)
- (define result
- (call/cc
- (lambda (cont)
- (set! error (lambda (x) (cont 'error)))
- (with-exception-handler
- (lambda (x) (cont 'exception))
- (lambda () (cont (if (fn) 'pass 'fail)))))))
- (set! error preverr)
- result)
-