before the daemon is stopped, making it clearer where the failure was.
Add tests/fail.py, a test that always fails. Naturally this is not
normally run, it's only there to test failure cleanup!
clean-local:
rm -rf testroot *.log *.pyc
-EXTRA_DIST=dtest.py ${TESTS}
+EXTRA_DIST=dtest.py ${TESTS} fail.py
CLEANFILES=*.gcda *.gcov *.gcno *.c.html index.html
#-*-python-*-
#
# This file is part of DisOrder.
-# Copyright (C) 2007, 2008 Richard Kettlewell
+# Copyright (C) 2007-2009 Richard Kettlewell
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
"""Utility module used by tests"""
-import os,os.path,subprocess,sys,re,time,unicodedata,random,socket
+import os,os.path,subprocess,sys,re,time,unicodedata,random,socket,traceback
def fatal(s):
"""Write an error message and exit"""
Run the test in MODULE. This can be a string (in which case the module
will be imported) or a module object."""
- global tests
+ global tests, failures
tests += 1
# Locate the test module
if module is None:
stdtracks()
try:
module.test()
- finally:
- stop_daemon()
+ except:
+ traceback.print_exc(None, sys.stderr)
+ failures += 1
+ stop_daemon()
if report:
if failures:
print " FAILED"
--- /dev/null
+#! /usr/bin/env python
+#
+# This file is part of DisOrder.
+# Copyright (C) 2009 Richard Kettlewell
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+import dtest
+
+def test():
+ """Create a daemon and fail"""
+ dtest.start_daemon()
+ dtest.create_user()
+ assert True == False, "forcing failure"
+
+if __name__ == '__main__':
+ dtest.run()