Commits

Michał Górny  committed b542a86

Support running doctests.

  • Participants
  • Parent commits ca03da9

Comments (0)

Files changed (1)

 # (c) 2011 Michał Górny <mgorny@gentoo.org>
 # Released under the terms of the 2-clause BSD license.
 
-from distutils.core import setup
+from distutils.core import setup, Command
 
 import os.path, sys
 
 except ImportError:
 	PV = 'unknown'
 
+class TestCommand(Command):
+	user_options = []
+
+	def initialize_options(self):
+		pass
+
+	def finalize_options(self):
+		pass
+
+	def run(self):
+		import unittest, doctest
+
+		tests = unittest.TestSuite()
+
+		r = unittest.TextTestRunner()
+		res = r.run(tests)
+		sys.exit(0 if res.wasSuccessful() else 1)
+
 setup(
 		name = 'smart-live-rebuild',
 		version = PV,
 			'Operating System :: POSIX',
 			'Programming Language :: Python',
 			'Topic :: System :: Installation/Setup'
-		]
+		],
+
+		cmdclass = {
+			'test': TestCommand
+		}
 )