Browse code

* run-tests.py: Added --verbose mode.

git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@388 830e0280-6d2a-0410-9c65-932aecc39d9d

Michal Ludvig authored on 2009/05/27 21:10:03
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+2009-05-28  Michal Ludvig  <michal@logix.cz>
2
+
3
+	* run-tests.py: Added --verbose mode.
4
+
1 5
 2009-05-27  Michal Ludvig  <michal@logix.cz>
2 6
 
3 7
 	* NEWS: Added info about --verbatim.
... ...
@@ -20,6 +20,8 @@ test_counter = 0
20 20
 run_tests = []
21 21
 exclude_tests = []
22 22
 
23
+verbose = False
24
+
23 25
 if os.name == "posix":
24 26
 	have_wget = True
25 27
 elif os.name == "nt":
... ...
@@ -52,17 +54,20 @@ else:
52 52
 	print encoding + " specific files not found."
53 53
 
54 54
 def test(label, cmd_args = [], retcode = 0, must_find = [], must_not_find = [], must_find_re = [], must_not_find_re = []):
55
+	def command_output():
56
+		print "----"
57
+		print " ".join([arg.find(" ")>=0 and "'%s'" % arg or arg for arg in cmd_args])
58
+		print "----"
59
+		print stdout
60
+		print "----"
61
+
55 62
 	def failure(message = ""):
56 63
 		global count_fail
57 64
 		if message:
58 65
 			message = "  (%r)" % message
59 66
 		print "\x1b[31;1mFAIL%s\x1b[0m" % (message)
60 67
 		count_fail += 1
61
-		print "----"
62
-		print " ".join([arg.find(" ")>=0 and "'%s'" % arg or arg for arg in cmd_args])
63
-		print "----"
64
-		print stdout
65
-		print "----"
68
+		command_output()
66 69
 		#return 1
67 70
 		sys.exit(1)
68 71
 	def success(message = ""):
... ...
@@ -71,6 +76,8 @@ def test(label, cmd_args = [], retcode = 0, must_find = [], must_not_find = [],
71 71
 			message = "  (%r)" % message
72 72
 		print "\x1b[32;1mOK\x1b[0m%s" % (message)
73 73
 		count_pass += 1
74
+		if verbose:
75
+			command_output()
74 76
 		return 0
75 77
 	def skip(message = ""):
76 78
 		global count_skip
... ...
@@ -123,6 +130,7 @@ def test(label, cmd_args = [], retcode = 0, must_find = [], must_not_find = [],
123 123
 		match = not_find_list[index].search(stdout)
124 124
 		if match:
125 125
 			return failure("pattern found: %s (match: %s)" % (not_find_list_patterns[index], match.group(0)))
126
+
126 127
 	return success()
127 128
 
128 129
 def test_s3cmd(label, cmd_args = [], **kwargs):
... ...
@@ -167,6 +175,9 @@ while argv:
167 167
 	if arg in ("-l", "--list"):
168 168
 		exclude_tests = range(0, 999)
169 169
 		break
170
+	if arg in ("-v", "--verbose"):
171
+		verbose = True
172
+		continue
170 173
 	if arg.find("..") >= 0:
171 174
 		range_idx = arg.find("..")
172 175
 		range_start = arg[:range_idx] or 0