[node-patches] Change in ovirt-node[master]: Replace -m doctest with a wrapper in check-local
rbarry at redhat.com
rbarry at redhat.com
Mon Jun 23 21:55:18 UTC 2014
Ryan Barry has uploaded a new change for review.
Change subject: Replace -m doctest with a wrapper in check-local
......................................................................
Replace -m doctest with a wrapper in check-local
Replace -m doctest and fail if doctests fail
Change-Id: I582ef883150cd6d44128ba109b49fcec44300199
Signed-off-by: Ryan Barry <rbarry at redhat.com>
---
M src/Makefile.check
A src/autotest.py
2 files changed, 56 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/95/29095/1
diff --git a/src/Makefile.check b/src/Makefile.check
index c208d36..f7fc56a 100644
--- a/src/Makefile.check
+++ b/src/Makefile.check
@@ -22,7 +22,7 @@
@echo Passed $@
%.doctest:
- python test.py $*
+ python autotest.py $*
check-static-pep8: $(PYTHONSOURCES:%=%.pep8)
@echo Passed $@
diff --git a/src/autotest.py b/src/autotest.py
new file mode 100755
index 0000000..a54894d
--- /dev/null
+++ b/src/autotest.py
@@ -0,0 +1,55 @@
+#!/usr/bin/env python2
+#
+# Copyright (C) 2014, Red Hat, Inc.
+# Written by Ryan Barry <rbarry at redhat.com>
+#
+# 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/>.
+#
+# Convenience wrapper around doctest
+import argparse
+import doctest
+import sys
+import re
+import os
+
+def test():
+ parser = argparse.ArgumentParser(description="Runs doctests on a file")
+ parser.add_argument('FILE')
+ arguments = parser.parse_args()
+
+ testable = False
+ for line in open(arguments.FILE):
+ if ">>>" in line:
+ testable = True
+
+ if not testable:
+ return 0
+
+ else:
+ mod = re.sub(r'\/', r'.', os.path.splitext(arguments.FILE)[0])
+ try:
+ test = __import__(mod, globals(), locals(), ['object'], -1)
+ failures,tests = doctest.testmod(test)
+ if failures > 0:
+ print "Failures from %s: %s" % (mod, failures)
+ return -1
+ else:
+ return 0
+ except ImportError:
+ print "Failed to import %s" % sys.argv[1]
+ return -1
+
+
+if __name__ == "__main__":
+ sys.exit(test())
--
To view, visit http://gerrit.ovirt.org/29095
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I582ef883150cd6d44128ba109b49fcec44300199
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Ryan Barry <rbarry at redhat.com>
More information about the node-patches
mailing list