Permalink
Browse files

* 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
  • Loading branch information...
ludvigm
ludvigm committed Oct 26, 2010
1 parent 11e5b41 commit 0765f3c417a59d6dfd8fc769ad1d6e6cc730d8b9
View
@@ -1,3 +1,9 @@
+2010-10-27 Michal Ludvig <mludvig@logix.net.nz>
+
+ * 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.
+
2010-10-27 Michal Ludvig <mludvig@logix.net.nz>
* TODO: Updated.
View
@@ -11,6 +11,7 @@
import re
from subprocess import Popen, PIPE, STDOUT
import locale
+import pwd
count_pass = 0
count_fail = 0
@@ -30,6 +31,17 @@
print "Unknown platform: %s" % os.name
sys.exit(1)
+## Unpack testsuite/ directory
+if not os.path.isdir('testsuite') and os.path.isfile('testsuite.tar.gz'):
+ os.system("tar -xz -f testsuite.tar.gz")
+if not os.path.isdir('testsuite'):
+ print "Something went wrong while unpacking testsuite.tar.gz"
+ sys.exit(1)
+
+## Fix up permissions for permission-denied tests
+os.chmod("testsuite/permission-tests/permission-denied-dir", 0444)
+os.chmod("testsuite/permission-tests/permission-denied.txt", 0000)
+
## Patterns for Unicode tests
patterns = {}
patterns['UTF-8'] = u"ŪņЇЌœđЗ/☺ unicode € rocks ™"
@@ -58,10 +70,6 @@
# TODO: also unpack if the tarball is newer than the directory timestamp
# for instance when a new version was pulled from SVN.
-## Fix up permissions for permission-denied tests
-os.chmod("testsuite/permission-tests/permission-denied-dir", 0444)
-os.chmod("testsuite/permission-tests/permission-denied.txt", 0000)
-
def test(label, cmd_args = [], retcode = 0, must_find = [], must_not_find = [], must_find_re = [], must_not_find_re = []):
def command_output():
print "----"
@@ -96,9 +104,6 @@ def skip(message = ""):
count_skip += 1
return 0
def compile_list(_list, regexps = False):
- if type(_list) not in [ list, tuple ]:
- _list = [_list]
-
if regexps == False:
_list = [re.escape(item.encode(encoding, "replace")) for item in _list]
@@ -120,6 +125,11 @@ def compile_list(_list, regexps = False):
if retcode != p.returncode:
return failure("retcode: %d, expected: %d" % (p.returncode, retcode))
+ if type(must_find) not in [ list, tuple ]: must_find = [must_find]
+ if type(must_find_re) not in [ list, tuple ]: must_find_re = [must_find_re]
+ if type(must_not_find) not in [ list, tuple ]: must_not_find = [must_not_find]
+ if type(must_not_find_re) not in [ list, tuple ]: must_not_find_re = [must_not_find_re]
+
find_list = []
find_list.extend(compile_list(must_find))
find_list.extend(compile_list(must_find_re, regexps = True))
@@ -179,13 +189,19 @@ def test_flushdir(label, dir_name):
test_rmdir(label + "(rm)", dir_name)
return test_mkdir(label + "(mk)", dir_name)
-bucket_prefix = ''
+try:
+ pwd = pwd.getpwuid(os.getuid())
+ bucket_prefix = "%s.%s-" % (pwd.pw_name, pwd.pw_uid)
+except:
+ bucket_prefix = ''
+print "Using bucket prefix: '%s'" % bucket_prefix
+
argv = sys.argv[1:]
while argv:
arg = argv.pop(0)
- if arg.startswith('--bucket-prefix='):
- print "Usage: '--bucket-prefix PREFIX', not '--bucket-prefix=PREFIX'"
- sys.exit(0)
+ if arg.startswith('--bucket-prefix='):
+ print "Usage: '--bucket-prefix PREFIX', not '--bucket-prefix=PREFIX'"
+ sys.exit(0)
if arg in ("-h", "--help"):
print "%s A B K..O -N" % sys.argv[0]
print "Run tests number A, B and K through to O, except for N"
@@ -196,13 +212,13 @@ def test_flushdir(label, dir_name):
if arg in ("-v", "--verbose"):
verbose = True
continue
- if arg in ("-p", "--bucket-prefix"):
- try:
- bucket_prefix = argv.pop(0)
- except IndexError:
- print "Bucket prefix option must explicitly supply a bucket name prefix"
- sys.exit(0)
- continue
+ if arg in ("-p", "--bucket-prefix"):
+ try:
+ bucket_prefix = argv.pop(0)
+ except IndexError:
+ print "Bucket prefix option must explicitly supply a bucket name prefix"
+ sys.exit(0)
+ continue
if arg.find("..") >= 0:
range_idx = arg.find("..")
range_start = arg[:range_idx] or 0
@@ -223,6 +239,7 @@ def bucket(tail):
if str(tail) == '3':
label = 'Autotest'
return '%ss3cmd-%s-%s' % (bucket_prefix, label, tail)
+
def pbucket(tail):
'''Like bucket(), but prepends "s3://" for you'''
return 's3://' + bucket(tail)
@@ -258,30 +275,29 @@ def pbucket(tail):
## ====== Sync to S3
-test_s3cmd("Sync to S3", ['sync', 'testsuite/', pbucket(1) + '/xyz/', '--exclude', '.svn/*', '--exclude', '*.png', '--no-encrypt', '--exclude-from', 'testsuite/exclude.encodings' ],
+test_s3cmd("Sync to S3", ['sync', 'testsuite/', pbucket(1) + '/xyz/', '--exclude', 'demo/*', '--exclude', '*.png', '--no-encrypt', '--exclude-from', 'testsuite/exclude.encodings' ],
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",
"WARNING: File can not be uploaded: testsuite/permission-tests/permission-denied.txt: Permission denied",
"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) ],
- must_not_find_re = [ "\.svn/", "\.png$", "permission-denied-dir" ])
+ must_not_find_re = [ "demo/", "\.png$", "permission-denied-dir" ])
if have_encoding:
## ====== Sync UTF-8 / GBK / ... to S3
- test_s3cmd("Sync %s to S3" % encoding, ['sync', 'testsuite/encodings/' + encoding, '%s/xyz/encodings/' % pbucket(1), '--exclude', '.svn/*', '--no-encrypt' ],
+ test_s3cmd("Sync %s to S3" % encoding, ['sync', 'testsuite/encodings/' + encoding, '%s/xyz/encodings/' % pbucket(1), '--exclude', 'demo/*', '--no-encrypt' ],
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)} ])
## ====== List bucket content
-must_find_re = [ u"DIR %s/xyz/binary/$" % pbucket(1) , u"DIR %s/xyz/etc/$" % pbucket(1) ]
-must_not_find = [ u"random-crap.md5", u".svn" ]
test_s3cmd("List bucket content", ['ls', '%s/xyz/' % pbucket(1) ],
- must_find_re = must_find_re,
- must_not_find = must_not_find)
+ must_find_re = [ u"DIR %s/xyz/binary/$" % pbucket(1) , u"DIR %s/xyz/etc/$" % pbucket(1) ],
+ must_not_find = [ u"random-crap.md5", u"/demo" ])
## ====== List bucket recursive
must_find = [ u"%s/xyz/binary/random-crap.md5" % pbucket(1) ]
if have_encoding:
must_find.append(u"%(pbucket)s/xyz/encodings/%(encoding)s/%(pattern)s" % { 'encoding' : encoding, 'pattern' : enc_pattern, 'pbucket' : pbucket(1) })
+
test_s3cmd("List bucket recursive", ['ls', '--recursive', pbucket(1)],
must_find = must_find,
must_not_find = [ "logo.png" ])
@@ -303,16 +319,16 @@ def pbucket(tail):
## ====== Remove 'demo' directory
-test_rmdir("Remove 'demo/'", "testsuite-out/xyz/demo/")
+test_rmdir("Remove 'dir-test/'", "testsuite-out/xyz/dir-test/")
## ====== Create dir with name of a file
-test_mkdir("Create some-file.xml dir", "testsuite-out/xyz/demo/some-file.xml")
+test_mkdir("Create file-dir dir", "testsuite-out/xyz/dir-test/file-dir")
## ====== Skip dst dirs
test_s3cmd("Skip over dir", ['sync', '%s/xyz' % pbucket(1), 'testsuite-out'],
- must_find = "WARNING: testsuite-out/xyz/demo/some-file.xml is a directory - skipping over")
+ must_find = "WARNING: testsuite-out/xyz/dir-test/file-dir is a directory - skipping over")
## ====== Clean up local destination dir
@@ -355,7 +371,7 @@ def pbucket(tail):
## ====== Sync more to S3
test_s3cmd("Sync more to S3", ['sync', 'testsuite/', 's3://%s/xyz/' % bucket(1), '--no-encrypt' ],
- must_find = [ "File 'testsuite/.svn/entries' stored as '%s/xyz/.svn/entries' " % pbucket(1) ],
+ must_find = [ "File 'testsuite/demo/some-file.xml' stored as '%s/xyz/demo/some-file.xml' " % pbucket(1) ],
must_not_find = [ "File 'testsuite/etc/linked.png' stored as '%s/xyz/etc/linked.png" % pbucket(1) ])
@@ -376,7 +392,7 @@ def pbucket(tail):
test_s3cmd("Sync more from S3", ['sync', '--delete-removed', '%s/xyz' % pbucket(1), 'testsuite-out'],
must_find = [ "deleted: testsuite-out/logo.png",
"File '%s/xyz/etc2/Logo.PNG' stored as 'testsuite-out/xyz/etc2/Logo.PNG' (22059 bytes" % pbucket(1),
- "File '%s/xyz/.svn/entries' stored as 'testsuite-out/xyz/.svn/entries' " % pbucket(1) ],
+ "File '%s/xyz/demo/some-file.xml' stored as 'testsuite-out/xyz/demo/some-file.xml' " % pbucket(1) ],
must_not_find_re = [ "not-deleted.*etc/logo.png" ])
@@ -407,11 +423,11 @@ def pbucket(tail):
must_find = [ "File %s/xyz/etc2/Logo.PNG copied to %s/xyz/etc2/logo.png" % (pbucket(1), pbucket(3)) ])
## ====== Recursive copy
-test_s3cmd("Recursive copy, set ACL", ['cp', '-r', '--acl-public', '%s/xyz/' % pbucket(1), '%s/copy' % pbucket(2), '--exclude', '.svn/*', '--exclude', 'non-printables*'],
+test_s3cmd("Recursive copy, set ACL", ['cp', '-r', '--acl-public', '%s/xyz/' % pbucket(1), '%s/copy' % pbucket(2), '--exclude', 'demo/*', '--exclude', 'non-printables*'],
must_find = [ "File %s/xyz/etc2/Logo.PNG copied to %s/copy/etc2/Logo.PNG" % (pbucket(1), pbucket(2)),
"File %s/xyz/blahBlah/Blah.txt copied to %s/copy/blahBlah/Blah.txt" % (pbucket(1), pbucket(2)),
"File %s/xyz/blahBlah/blah.txt copied to %s/copy/blahBlah/blah.txt" % (pbucket(1), pbucket(2)) ],
- must_not_find = [ ".svn" ])
+ must_not_find = [ "demo/" ])
## ====== Don't Put symbolic link
test_s3cmd("Don't put symbolic links", ['put', 'testsuite/etc/linked1.png', 's3://%s/xyz/' % bucket(1),],
@@ -460,7 +476,7 @@ def pbucket(tail):
## ====== Recursive delete
test_s3cmd("Recursive delete", ['del', '--recursive', '--exclude', 'Atomic*', '%s/xyz/etc' % pbucket(1)],
must_find = [ "File %s/xyz/etc/TypeRa.ttf deleted" % pbucket(1) ],
- must_find_re = [ "File .*\.svn/entries deleted" ],
+ must_find_re = [ "File .*/etc/logo.png deleted" ],
must_not_find = [ "AtomicClockRadio.ttf" ])
## ====== Recursive delete all
View
Binary file not shown.
Binary file not shown.
@@ -1 +0,0 @@
-cb76ecee9a834eadd96b226493acac28 random-crap
@@ -1 +0,0 @@
-Blah
@@ -1 +0,0 @@
-blah
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
Binary file not shown.
View
View
Binary file not shown.
No changes.
@@ -1 +0,0 @@
-encodings/*
@@ -1,3 +0,0 @@
-## Run 'svn propset svn:ignore -F .svnignore .' after you change this list
-permission-denied-dir
-
@@ -1 +0,0 @@
-inaccessible
@@ -1 +0,0 @@
-permission denied

0 comments on commit 0765f3c

Please sign in to comment.