Module: check_mk
Branch: master
Commit: 1658cb10cd06ef043f9d79b73fe5c4419f381867
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1658cb10cd06ef…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Sep 6 14:25:06 2016 +0200
Moved print debug code detection from git hook to tests
---
tests/general/test_find_debug_print.py | 44 ++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/tests/general/test_find_debug_print.py
b/tests/general/test_find_debug_print.py
new file mode 100644
index 0000000..771cfe8
--- /dev/null
+++ b/tests/general/test_find_debug_print.py
@@ -0,0 +1,44 @@
+#!/usr/bin/python
+# encoding: utf-8
+
+import os
+import glob
+from testlib import cmk_path, cmc_path
+
+check_paths = [
+ "bin",
+ "modules",
+ "lib",
+ "checks",
+ "inventory",
+ "notifications",
+ "doc/treasures/active_checks",
+ # CMC specific
+ "agents/bakery",
+ # TODO: Update all agent plugins to use sys.stdout.write instead of print
+ #"agents/plugins",
+]
+
+def test_find_debug_code():
+ scanned = 0
+ for base_path in [ cmk_path(), cmc_path() ]:
+ for dir_path in check_paths:
+ path = "%s/%s" % (base_path, dir_path)
+ if not os.path.exists(path):
+ continue
+
+ for dirpath, dirnames, filenames in os.walk(path):
+ scanned += 1
+ for filename in filenames:
+ file_path = "%s/%s" % (dirpath, filename)
+
+ for nr, line in enumerate(open(file_path)):
+ l = line.lstrip()
+ assert not l.startswith("print("), \
+ "Found \"print(...)\" call in %s:%d" % \
+ (file_path, nr)
+ assert not l.startswith("print "), \
+ "Found \"print ...\" call in %s:%d" % \
+ (file_path, nr)
+
+ assert scanned > 0