Browse code

* run-tests.py, testsuite.tar.gz: Keep the testsuite in SVN as a tarball. There's too many "strange" things in the directory for it to be kept in SVN.

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

Michal Ludvig authored on 2010/10/26 21:02:35
Showing 22 changed files
... ...
@@ -1,5 +1,11 @@
1 1
 2010-10-27  Michal Ludvig  <mludvig@logix.net.nz>
2 2
 
3
+	* run-tests.py, testsuite.tar.gz: Keep the testsuite in
4
+	  SVN as a tarball. There's too many "strange" things 
5
+	  in the directory for it to be kept in SVN.
6
+
7
+2010-10-27  Michal Ludvig  <mludvig@logix.net.nz>
8
+
3 9
 	* TODO: Updated.
4 10
 	* upload-to-sf.sh: Updated for new SF.net system
5 11
 
... ...
@@ -11,6 +11,7 @@ import os
11 11
 import re
12 12
 from subprocess import Popen, PIPE, STDOUT
13 13
 import locale
14
+import pwd
14 15
 
15 16
 count_pass = 0
16 17
 count_fail = 0
... ...
@@ -30,6 +31,17 @@ else:
30 30
 	print "Unknown platform: %s" % os.name
31 31
 	sys.exit(1)
32 32
 
33
+## Unpack testsuite/ directory
34
+if not os.path.isdir('testsuite') and os.path.isfile('testsuite.tar.gz'):
35
+	os.system("tar -xz -f testsuite.tar.gz")
36
+if not os.path.isdir('testsuite'):
37
+	print "Something went wrong while unpacking testsuite.tar.gz"
38
+	sys.exit(1)
39
+
40
+## Fix up permissions for permission-denied tests
41
+os.chmod("testsuite/permission-tests/permission-denied-dir", 0444)
42
+os.chmod("testsuite/permission-tests/permission-denied.txt", 0000)
43
+
33 44
 ## Patterns for Unicode tests
34 45
 patterns = {}
35 46
 patterns['UTF-8'] = u"ŪņЇЌœđЗ/☺ unicode € rocks ™"
... ...
@@ -58,10 +70,6 @@ if not os.path.isdir('testsuite/crappy-file-name'):
58 58
 	# TODO: also unpack if the tarball is newer than the directory timestamp
59 59
 	#       for instance when a new version was pulled from SVN.
60 60
 
61
-## Fix up permissions for permission-denied tests
62
-os.chmod("testsuite/permission-tests/permission-denied-dir", 0444)
63
-os.chmod("testsuite/permission-tests/permission-denied.txt", 0000)
64
-
65 61
 def test(label, cmd_args = [], retcode = 0, must_find = [], must_not_find = [], must_find_re = [], must_not_find_re = []):
66 62
 	def command_output():
67 63
 		print "----"
... ...
@@ -96,9 +104,6 @@ def test(label, cmd_args = [], retcode = 0, must_find = [], must_not_find = [],
96 96
 		count_skip += 1
97 97
 		return 0
98 98
 	def compile_list(_list, regexps = False):
99
-		if type(_list) not in [ list, tuple ]:
100
-			_list = [_list]
101
-
102 99
 		if regexps == False:
103 100
 			_list = [re.escape(item.encode(encoding, "replace")) for item in _list]
104 101
 
... ...
@@ -120,6 +125,11 @@ def test(label, cmd_args = [], retcode = 0, must_find = [], must_not_find = [],
120 120
 	if retcode != p.returncode:
121 121
 		return failure("retcode: %d, expected: %d" % (p.returncode, retcode))
122 122
 
123
+	if type(must_find) not in [ list, tuple ]: must_find = [must_find]
124
+	if type(must_find_re) not in [ list, tuple ]: must_find_re = [must_find_re]
125
+	if type(must_not_find) not in [ list, tuple ]: must_not_find = [must_not_find]
126
+	if type(must_not_find_re) not in [ list, tuple ]: must_not_find_re = [must_not_find_re]
127
+
123 128
 	find_list = []
124 129
 	find_list.extend(compile_list(must_find))
125 130
 	find_list.extend(compile_list(must_find_re, regexps = True))
... ...
@@ -179,13 +189,19 @@ def test_flushdir(label, dir_name):
179 179
 	test_rmdir(label + "(rm)", dir_name)
180 180
 	return test_mkdir(label + "(mk)", dir_name)
181 181
 
182
-bucket_prefix = ''
182
+try:
183
+	pwd = pwd.getpwuid(os.getuid())
184
+	bucket_prefix = "%s.%s-" % (pwd.pw_name, pwd.pw_uid)
185
+except:
186
+	bucket_prefix = ''
187
+print "Using bucket prefix: '%s'" % bucket_prefix
188
+
183 189
 argv = sys.argv[1:]
184 190
 while argv:
185 191
 	arg = argv.pop(0)
186
-        if arg.startswith('--bucket-prefix='):
187
-                print "Usage: '--bucket-prefix PREFIX', not '--bucket-prefix=PREFIX'"
188
-                sys.exit(0)
192
+	if arg.startswith('--bucket-prefix='):
193
+		print "Usage: '--bucket-prefix PREFIX', not '--bucket-prefix=PREFIX'"
194
+		sys.exit(0)
189 195
 	if arg in ("-h", "--help"):
190 196
 		print "%s A B K..O -N" % sys.argv[0]
191 197
 		print "Run tests number A, B and K through to O, except for N"
... ...
@@ -196,13 +212,13 @@ while argv:
196 196
 	if arg in ("-v", "--verbose"):
197 197
 		verbose = True
198 198
 		continue
199
-        if arg in ("-p", "--bucket-prefix"):
200
-                try:
201
-                        bucket_prefix = argv.pop(0)
202
-                except IndexError:
203
-                        print "Bucket prefix option must explicitly supply a bucket name prefix"
204
-                        sys.exit(0)
205
-                continue
199
+	if arg in ("-p", "--bucket-prefix"):
200
+		try:
201
+			bucket_prefix = argv.pop(0)
202
+		except IndexError:
203
+			print "Bucket prefix option must explicitly supply a bucket name prefix"
204
+			sys.exit(0)
205
+		continue
206 206
 	if arg.find("..") >= 0:
207 207
 		range_idx = arg.find("..")
208 208
 		range_start = arg[:range_idx] or 0
... ...
@@ -223,6 +239,7 @@ def bucket(tail):
223 223
         if str(tail) == '3':
224 224
                 label = 'Autotest'
225 225
         return '%ss3cmd-%s-%s' % (bucket_prefix, label, tail)
226
+
226 227
 def pbucket(tail):
227 228
         '''Like bucket(), but prepends "s3://" for you'''
228 229
         return 's3://' + bucket(tail)
... ...
@@ -258,30 +275,29 @@ test_s3cmd("Buckets list", ["ls"],
258 258
 
259 259
 
260 260
 ## ====== Sync to S3
261
-test_s3cmd("Sync to S3", ['sync', 'testsuite/', pbucket(1) + '/xyz/', '--exclude', '.svn/*', '--exclude', '*.png', '--no-encrypt', '--exclude-from', 'testsuite/exclude.encodings' ],
261
+test_s3cmd("Sync to S3", ['sync', 'testsuite/', pbucket(1) + '/xyz/', '--exclude', 'demo/*', '--exclude', '*.png', '--no-encrypt', '--exclude-from', 'testsuite/exclude.encodings' ],
262 262
 	must_find = [ "WARNING: 32 non-printable characters replaced in: crappy-file-name/non-printables ^A^B^C^D^E^F^G^H^I^J^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_^? +-[\]^<>%%\"'#{}`&?.end",
263 263
 				  "WARNING: File can not be uploaded: testsuite/permission-tests/permission-denied.txt: Permission denied",
264 264
 	              "stored as '%s/xyz/crappy-file-name/non-printables ^A^B^C^D^E^F^G^H^I^J^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_^? +-[\\]^<>%%%%\"'#{}`&?.end'" % pbucket(1) ],
265
-	must_not_find_re = [ "\.svn/", "\.png$", "permission-denied-dir" ])
265
+	must_not_find_re = [ "demo/", "\.png$", "permission-denied-dir" ])
266 266
 
267 267
 if have_encoding:
268 268
 	## ====== Sync UTF-8 / GBK / ... to S3
269
-	test_s3cmd("Sync %s to S3" % encoding, ['sync', 'testsuite/encodings/' + encoding, '%s/xyz/encodings/' % pbucket(1), '--exclude', '.svn/*', '--no-encrypt' ],
269
+	test_s3cmd("Sync %s to S3" % encoding, ['sync', 'testsuite/encodings/' + encoding, '%s/xyz/encodings/' % pbucket(1), '--exclude', 'demo/*', '--no-encrypt' ],
270 270
 		must_find = [ u"File 'testsuite/encodings/%(encoding)s/%(pattern)s' stored as '%(pbucket)s/xyz/encodings/%(encoding)s/%(pattern)s'" % { 'encoding' : encoding, 'pattern' : enc_pattern , 'pbucket' : pbucket(1)} ])
271 271
 
272 272
 
273 273
 ## ====== List bucket content
274
-must_find_re = [ u"DIR   %s/xyz/binary/$" % pbucket(1) , u"DIR   %s/xyz/etc/$" % pbucket(1) ]
275
-must_not_find = [ u"random-crap.md5", u".svn" ]
276 274
 test_s3cmd("List bucket content", ['ls', '%s/xyz/' % pbucket(1) ],
277
-	must_find_re = must_find_re,
278
-	must_not_find = must_not_find)
275
+	must_find_re = [ u"DIR   %s/xyz/binary/$" % pbucket(1) , u"DIR   %s/xyz/etc/$" % pbucket(1) ],
276
+	must_not_find = [ u"random-crap.md5", u"/demo" ])
279 277
 
280 278
 
281 279
 ## ====== List bucket recursive
282 280
 must_find = [ u"%s/xyz/binary/random-crap.md5" % pbucket(1) ]
283 281
 if have_encoding:
284 282
 	must_find.append(u"%(pbucket)s/xyz/encodings/%(encoding)s/%(pattern)s" % { 'encoding' : encoding, 'pattern' : enc_pattern, 'pbucket' : pbucket(1) })
283
+
285 284
 test_s3cmd("List bucket recursive", ['ls', '--recursive', pbucket(1)],
286 285
 	must_find = must_find,
287 286
 	must_not_find = [ "logo.png" ])
... ...
@@ -303,16 +319,16 @@ test_s3cmd("Sync from S3", ['sync', '%s/xyz' % pbucket(1), 'testsuite-out'],
303 303
 
304 304
 
305 305
 ## ====== Remove 'demo' directory
306
-test_rmdir("Remove 'demo/'", "testsuite-out/xyz/demo/")
306
+test_rmdir("Remove 'dir-test/'", "testsuite-out/xyz/dir-test/")
307 307
 
308 308
 
309 309
 ## ====== Create dir with name of a file
310
-test_mkdir("Create some-file.xml dir", "testsuite-out/xyz/demo/some-file.xml")
310
+test_mkdir("Create file-dir dir", "testsuite-out/xyz/dir-test/file-dir")
311 311
 
312 312
 
313 313
 ## ====== Skip dst dirs
314 314
 test_s3cmd("Skip over dir", ['sync', '%s/xyz' % pbucket(1), 'testsuite-out'],
315
-	must_find = "WARNING: testsuite-out/xyz/demo/some-file.xml is a directory - skipping over")
315
+	must_find = "WARNING: testsuite-out/xyz/dir-test/file-dir is a directory - skipping over")
316 316
 
317 317
 
318 318
 ## ====== Clean up local destination dir
... ...
@@ -355,7 +371,7 @@ if have_wget:
355 355
 
356 356
 ## ====== Sync more to S3
357 357
 test_s3cmd("Sync more to S3", ['sync', 'testsuite/', 's3://%s/xyz/' % bucket(1), '--no-encrypt' ],
358
-	must_find = [ "File 'testsuite/.svn/entries' stored as '%s/xyz/.svn/entries' " % pbucket(1) ],
358
+	must_find = [ "File 'testsuite/demo/some-file.xml' stored as '%s/xyz/demo/some-file.xml' " % pbucket(1) ],
359 359
 	must_not_find = [ "File 'testsuite/etc/linked.png' stored as '%s/xyz/etc/linked.png" % pbucket(1) ])
360 360
            
361 361
 
... ...
@@ -376,7 +392,7 @@ test_s3cmd("Rename (NoSuchKey)", ['mv', '%s/xyz/etc/logo.png' % pbucket(1), '%s/
376 376
 test_s3cmd("Sync more from S3", ['sync', '--delete-removed', '%s/xyz' % pbucket(1), 'testsuite-out'],
377 377
 	must_find = [ "deleted: testsuite-out/logo.png",
378 378
 	              "File '%s/xyz/etc2/Logo.PNG' stored as 'testsuite-out/xyz/etc2/Logo.PNG' (22059 bytes" % pbucket(1), 
379
-	              "File '%s/xyz/.svn/entries' stored as 'testsuite-out/xyz/.svn/entries' " % pbucket(1) ],
379
+	              "File '%s/xyz/demo/some-file.xml' stored as 'testsuite-out/xyz/demo/some-file.xml' " % pbucket(1) ],
380 380
 	must_not_find_re = [ "not-deleted.*etc/logo.png" ])
381 381
 
382 382
 
... ...
@@ -407,11 +423,11 @@ test_s3cmd("Copy between buckets", ['cp', '%s/xyz/etc2/Logo.PNG' % pbucket(1), '
407 407
 	must_find = [ "File %s/xyz/etc2/Logo.PNG copied to %s/xyz/etc2/logo.png" % (pbucket(1), pbucket(3)) ])
408 408
 
409 409
 ## ====== Recursive copy
410
-test_s3cmd("Recursive copy, set ACL", ['cp', '-r', '--acl-public', '%s/xyz/' % pbucket(1), '%s/copy' % pbucket(2), '--exclude', '.svn/*', '--exclude', 'non-printables*'],
410
+test_s3cmd("Recursive copy, set ACL", ['cp', '-r', '--acl-public', '%s/xyz/' % pbucket(1), '%s/copy' % pbucket(2), '--exclude', 'demo/*', '--exclude', 'non-printables*'],
411 411
 	must_find = [ "File %s/xyz/etc2/Logo.PNG copied to %s/copy/etc2/Logo.PNG" % (pbucket(1), pbucket(2)),
412 412
 	              "File %s/xyz/blahBlah/Blah.txt copied to %s/copy/blahBlah/Blah.txt" % (pbucket(1), pbucket(2)),
413 413
 	              "File %s/xyz/blahBlah/blah.txt copied to %s/copy/blahBlah/blah.txt" % (pbucket(1), pbucket(2)) ],
414
-	must_not_find = [ ".svn" ])
414
+	must_not_find = [ "demo/" ])
415 415
 
416 416
 ## ====== Don't Put symbolic link
417 417
 test_s3cmd("Don't put symbolic links", ['put', 'testsuite/etc/linked1.png', 's3://%s/xyz/' % bucket(1),],
... ...
@@ -460,7 +476,7 @@ test_s3cmd("Simple delete", ['del', '%s/xyz/etc2/Logo.PNG' % pbucket(1)],
460 460
 ## ====== Recursive delete
461 461
 test_s3cmd("Recursive delete", ['del', '--recursive', '--exclude', 'Atomic*', '%s/xyz/etc' % pbucket(1)],
462 462
 	must_find = [ "File %s/xyz/etc/TypeRa.ttf deleted" % pbucket(1) ],
463
-	must_find_re = [ "File .*\.svn/entries deleted" ],
463
+	must_find_re = [ "File .*/etc/logo.png deleted" ],
464 464
 	must_not_find = [ "AtomicClockRadio.ttf" ])
465 465
 
466 466
 ## ====== Recursive delete all
467 467
new file mode 100644
468 468
Binary files /dev/null and b/testsuite.tar.gz differ
469 469
deleted file mode 100644
470 470
Binary files a/testsuite/binary/random-crap and /dev/null differ
471 471
deleted file mode 100644
... ...
@@ -1 +0,0 @@
1
-cb76ecee9a834eadd96b226493acac28  random-crap
2 1
deleted file mode 100644
... ...
@@ -1 +0,0 @@
1
-Blah
2 1
deleted file mode 100644
... ...
@@ -1 +0,0 @@
1
-blah
2 1
deleted file mode 100644
3 2
Binary files a/testsuite/crappy-file-name.tar.gz and /dev/null differ
4 3
deleted file mode 100644
5 4
Binary files a/testsuite/encodings/GBK.tar.gz and /dev/null differ
6 5
deleted file mode 100644
7 6
Binary files a/testsuite/encodings/UTF-8.tar.gz and /dev/null differ
8 7
deleted file mode 100644
9 8
Binary files a/testsuite/etc/AtomicClockRadio.ttf and /dev/null differ
10 9
deleted file mode 100644
11 10
Binary files a/testsuite/etc/TypeRa.ttf and /dev/null differ
12 11
deleted file mode 120000
... ...
@@ -1 +0,0 @@
1
-no-such-image.png
2 1
\ No newline at end of file
3 2
deleted file mode 120000
... ...
@@ -1 +0,0 @@
1
-logo.png
2 1
\ No newline at end of file
3 2
deleted file mode 120000
... ...
@@ -1 +0,0 @@
1
-logo.png
2 1
\ No newline at end of file
3 2
deleted file mode 100644
4 3
Binary files a/testsuite/etc/logo.png and /dev/null differ
5 4
deleted file mode 100644
6 5
deleted file mode 120000
... ...
@@ -1 +0,0 @@
1
-../../etc
2 1
\ No newline at end of file
3 2
deleted file mode 100644
... ...
@@ -1 +0,0 @@
1
-encodings/*
2 1
deleted file mode 100644
... ...
@@ -1,3 +0,0 @@
1
-## Run 'svn propset svn:ignore -F .svnignore .' after you change this list
2
-permission-denied-dir
3
-
4 1
deleted file mode 100644
... ...
@@ -1 +0,0 @@
1
-inaccessible
2 1
deleted file mode 100644
... ...
@@ -1 +0,0 @@
1
-permission denied