From ed8bd56bc23923cdf6a8a32c3ea6a0d7646e85bd Mon Sep 17 00:00:00 2001 From: Joel Andres Granados Date: Mon, 2 Jun 2008 18:48:31 +0200 Subject: Add the testsuite controler (test) and some tests. --- test | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 test (limited to 'test') diff --git a/test b/test new file mode 100755 index 0000000..785e4c7 --- /dev/null +++ b/test @@ -0,0 +1,49 @@ +#!/usr/bin/python -tt +# First Aid Kit - diagnostic and repair tool for Linux +# Copyright (C) 2008 Joel Granados +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +import unittest, imp, sys +from testsuite import modnames +testloader = unittest.defaultTestLoader + +testsuitedir = "testsuite" +flawless = True + +for modname in modnames: + modinfo = imp.find_module(modname, [testsuitedir]) + modfile = open(modinfo[1], 'r') + modload = imp.load_module(modname, modfile, modinfo[1], modinfo[2]) + + result = unittest.TestResult() + suite = testloader.loadTestsFromModule(modload) + suite.run(result) + if len(result.failures) == 0 and len(result.errors) == 0: + # Nothing to worry about + continue + else: + flawless = False + if len(result.failures) > 0: + for failure in result.failures: + print failure + if len(result.errors) > 0: + for error in result.errors: + print error + +if flawless: + sys.exit(0) +else: + sys.exit(1) -- cgit