# $Id$
-if HAVE_PYTHON
PYBINDING_DEPS = tools/python-yasm/bytecode.pxi
PYBINDING_DEPS += tools/python-yasm/coretype.pxi
EXTRA_DIST += tools/python-yasm/yasm.pyx
EXTRA_DIST += $(PYBINDING_DEPS)
+if HAVE_PYTHON
+
yasm_python.c: $(srcdir)/tools/python-yasm/yasm.pyx $(PYBINDING_DEPS)
$(PYTHON) -c "from Pyrex.Compiler.Main import main; main(command_line=1)" \
-o $@ `test -f tools/python-yasm/yasm.pyx || echo '$(srcdir)/'`tools/python-yasm/yasm.pyx
python-uninstall:
endif
+
+EXTRA_DIST += tools/python-yasm/tests/Makefile.inc
+include tools/python-yasm/tests/Makefile.inc
--- /dev/null
+# Test wrapper from Quod Libet
+# http://www.sacredchao.net/quodlibet/
+# $Id$
+import unittest, sys
+suites = []
+add = registerCase = suites.append
+from unittest import TestCase
+
+class Mock(object):
+ # A generic mocking object.
+ def __init__(self, **kwargs): self.__dict__.update(kwargs)
+
+import test_symrec
+
+class Result(unittest.TestResult):
+
+ separator1 = '=' * 70
+ separator2 = '-' * 70
+
+ def addSuccess(self, test):
+ unittest.TestResult.addSuccess(self, test)
+ sys.stdout.write('.')
+
+ def addError(self, test, err):
+ unittest.TestResult.addError(self, test, err)
+ sys.stdout.write('E')
+
+ def addFailure(self, test, err):
+ unittest.TestResult.addFailure(self, test, err)
+ sys.stdout.write('F')
+
+ def printErrors(self):
+ succ = self.testsRun - (len(self.errors) + len(self.failures))
+ v = "%3d" % succ
+ count = 50 - self.testsRun
+ sys.stdout.write((" " * count) + v + "\n")
+ self.printErrorList('ERROR', self.errors)
+ self.printErrorList('FAIL', self.failures)
+
+ def printErrorList(self, flavour, errors):
+ for test, err in errors:
+ sys.stdout.write(self.separator1 + "\n")
+ sys.stdout.write("%s: %s\n" % (flavour, str(test)))
+ sys.stdout.write(self.separator2 + "\n")
+ sys.stdout.write("%s\n" % err)
+
+class Runner:
+ def run(self, test):
+ suite = unittest.makeSuite(test)
+ pref = '%s (%d): ' % (test.__name__, len(suite._tests))
+ print pref + " " * (25 - len(pref)),
+ result = Result()
+ suite(result)
+ result.printErrors()
+ return bool(result.failures + result.errors)
+
+def unit(run = []):
+ runner = Runner()
+ failures = False
+ for test in suites:
+ if not run or test.__name__ in run:
+ failures |= runner.run(test)
+ return failures
+
+if __name__ == "__main__":
+ raise SystemExit(unit(sys.argv[1:]))
+
--- /dev/null
+#!/bin/sh
+# Based on _sanity.sh from Quod Libet
+# http://www.sacredchao.net/quodlibet/
+# $Id$
+
+set -e
+
+if test "$1" = "--help" -o "$1" = "-h"; then
+ echo "Usage: $0 --sanity | [TestName] ..."
+ exit 0
+elif [ "$1" = "--sanity" ]; then
+ echo "Running static sanity checks."
+ grep "except None:" ${srcdir}/tools/python-yasm/tests/*.py
+else
+ python -c "import sys; import glob; sys.path.insert(0, '${srcdir}/tools/python-yasm'); sys.path.insert(0, glob.glob('build/lib.*')[0]); import tests; raise SystemExit(tests.unit('$*'.split()))"
+fi
+
--- /dev/null
+# $Id$
+from tests import TestCase, add
+from yasm import SymbolTable
+
+class TSymbolTable(TestCase):
+ def test_keys(self):
+ symtab = SymbolTable()
+ self.failUnlessEqual(len(symtab.keys()), 0)
+ symtab.declare("foo")
+ keys = symtab.keys()
+ self.failUnlessEqual(len(keys), 1)
+ self.failUnlessEqual(keys[0], "foo")