Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* run-tests.py: Adapted to the above change.

* run-tests.sh: removed.



git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@314 830e0280-6d2a-0410-9c65-932aecc39d9d
  • Loading branch information...
commit 4986ae8574122e265392d3d8e1d495f5765bd3d0 1 parent e6e928d
@mludvig mludvig authored
Showing with 37 additions and 57 deletions.
  1. +2 −0  ChangeLog
  2. +35 −16 run-tests.py
  3. +0 −41 run-tests.sh
View
2  ChangeLog
@@ -2,6 +2,8 @@
* testsuite: reorganised UTF-8 files, added GBK encoding files,
moved encoding-specific files to 'tar.gz' archives.
+ * run-tests.py: Adapted to the above change.
+ * run-tests.sh: removed.
* run-tests.py: Don't assume utf-8, use preferred encoding
instead.
* s3cmd, S3/Utils.py, S3/Exceptions.py, S3/Progress.py,
View
51 run-tests.py
@@ -21,15 +21,33 @@
exclude_tests = []
if os.name == "posix":
- have_unicode = True
have_wget = True
elif os.name == "nt":
- have_unicode = False
have_wget = False
else:
print "Unknown platform: %s" % os.name
sys.exit(1)
+## Patterns for Unicode tests
+patterns = {}
+patterns['UTF-8'] = u"ŪņЇЌœđЗ/☺ unicode € rocks ™"
+patterns['GBK'] = u"12月31日/1-特色條目"
+
+encoding = locale.getpreferredencoding()
+if not encoding:
+ print "Guessing current system encoding failed. Consider setting $LANG variable."
+ sys.exit(1)
+
+have_encoding = os.path.isdir('testsuite/encodings/' + encoding)
+if not have_encoding and os.path.isfile('testsuite/encodings/%s.tar.gz' % encoding):
+ os.system("tar xvz -C testsuite/encodings -f testsuite/encodings/UTF-8.tar.gz")
+ have_encoding = os.path.isdir('testsuite/encodings/' + encoding)
+
+if have_encoding:
+ enc_base_remote = "s3://s3cmd-autotest-1/xyz/%s/" % encoding
+ enc_pattern = patterns[encoding]
+ print "System encoding: " + encoding
+
def test(label, cmd_args = [], retcode = 0, must_find = [], must_not_find = [], must_find_re = [], must_not_find_re = []):
def failure(message = ""):
global count_fail
@@ -63,7 +81,7 @@ def compile_list(_list, regexps = False):
_list = [_list]
if regexps == False:
- _list = [re.escape(item.encode(locale.getpreferredencoding(), "replace")) for item in _list]
+ _list = [re.escape(item.encode(encoding, "replace")) for item in _list]
return [re.compile(item, re.MULTILINE) for item in _list]
@@ -187,18 +205,19 @@ def test_rmdir(label, dir_name):
## ====== Sync to S3
-exclude_unicode_args = []
-if not have_unicode:
- exclude_unicode_args = [ '--exclude', 'unicode/*' ]
-test_s3cmd("Sync to S3", ['sync', 'testsuite', 's3://s3cmd-autotest-1/xyz/', '--exclude', '.svn/*', '--exclude', '*.png', '--no-encrypt'] + exclude_unicode_args)
+test_s3cmd("Sync to S3", ['sync', 'testsuite', 's3://s3cmd-autotest-1/xyz/', '--exclude', '.svn/*', '--exclude', '*.png', '--no-encrypt', '--exclude-from', 'testsuite/exclude.encodings' ])
+
+if have_encoding:
+ ## ====== Sync UTF-8 / GBK / ... to S3
+ test_s3cmd("Sync %s to S3" % encoding, ['sync', 'testsuite/encodings/' + encoding, enc_base_remote, '--exclude', '.svn/*', '--no-encrypt' ])
## ====== List bucket content
must_find_re = [ u"D s3://s3cmd-autotest-1/xyz/binary/$", u"D s3://s3cmd-autotest-1/xyz/etc/$" ]
must_not_find = [ u"random-crap.md5", u".svn" ]
-if have_unicode:
- must_find_re.append(u"D s3://s3cmd-autotest-1/xyz/unicode/$")
- must_not_find.append(u"ŪņЇЌœđЗ/☺ unicode € rocks ™")
+if have_encoding:
+ must_find_re.append(u"D %s$" % enc_base_remote)
+ must_not_find.append(enc_pattern)
test_s3cmd("List bucket content", ['ls', 's3://s3cmd-autotest-1/xyz/'],
must_find_re = must_find_re,
must_not_find = must_not_find)
@@ -206,8 +225,8 @@ def test_rmdir(label, dir_name):
## ====== List bucket recursive
must_find = [ u"s3://s3cmd-autotest-1/xyz/binary/random-crap.md5" ]
-if have_unicode:
- must_find.append(u"s3://s3cmd-autotest-1/xyz/unicode/ŪņЇЌœđЗ/☺ unicode € rocks ™")
+if have_encoding:
+ must_find.append(enc_base_remote + enc_pattern)
test_s3cmd("List bucket recursive", ['ls', '--recursive', 's3://s3cmd-autotest-1'],
must_find = must_find,
must_not_find = [ "logo.png" ])
@@ -227,8 +246,8 @@ def test_rmdir(label, dir_name):
## ====== Sync from S3
must_find = [ "stored as testsuite-out/etc/logo.png " ]
-if have_unicode:
- must_find.append(u"unicode/ŪņЇЌœđЗ/☺ unicode € rocks ™")
+if have_encoding:
+ must_find.append("stored as testsuite-out/" + encoding + "/" + enc_pattern)
test_s3cmd("Sync from S3", ['sync', 's3://s3cmd-autotest-1/xyz', 'testsuite-out'],
must_find = must_find)
@@ -240,7 +259,7 @@ def test_rmdir(label, dir_name):
## ====== Sync more to S3
-test_s3cmd("Sync more to S3", ['sync', 'testsuite', 's3://s3cmd-autotest-1/xyz/', '--exclude', '*.png', '--no-encrypt'] + exclude_unicode_args)
+test_s3cmd("Sync more to S3", ['sync', 'testsuite', 's3://s3cmd-autotest-1/xyz/', '--exclude', '*.png', '--no-encrypt', '--exclude-from', 'testsuite/exclude.encodings' ])
## ====== Rename within S3
@@ -292,7 +311,7 @@ def test_rmdir(label, dir_name):
## ====== Recursive delete
-test_s3cmd("Recursive delete", ['del', '--recursive', 's3://s3cmd-autotest-1/xyz/unicode'],
+test_s3cmd("Recursive delete", ['del', '--recursive', 's3://s3cmd-autotest-1/xyz/etc'],
must_find_re = [ "Object.*\.svn/format deleted" ])
View
41 run-tests.sh
@@ -1,41 +0,0 @@
-#!/bin/sh
-set -e -x
-
-./s3cmd mb s3://s3cmd-autotest
-./s3cmd ls s3://s3cmd-autotest
-./s3cmd put s3cmd s3cmd.1 s3://s3cmd-autotest
-./s3cmd ls s3://s3cmd-autotest
-./s3cmd del s3://s3cmd-autotest/s3cmd.1
-./s3cmd get s3://s3cmd-autotest/s3cmd s3cmd.get
-diff s3cmd s3cmd.get
-rm -fv s3cmd.get
-
-set +x
-echo; echo
-echo "=== Now running 'sync' tests ==="
-echo; echo
-set -x
-
-VER=$(./s3cmd --version | cut -d\ -f3)
-tar xvfz dist/s3cmd-${VER}.tar.gz
-echo "Will be removed" > s3cmd-${VER}/file.to.remove
-./s3cmd sync s3cmd-${VER} s3://s3cmd-autotest/sync-test
-echo "Added file" > s3cmd-${VER}/added.file
-rm -f s3cmd-${VER}/file.to.remove
-./s3cmd sync --delete s3cmd-${VER} s3://s3cmd-autotest/sync-test
-rm -f s3cmd-${VER}/S3/PkgInfo.py
-rm -f s3cmd-${VER}/s3cmd
-./s3cmd sync --delete --exclude "/s3cmd-${VER}/S3/S3*" s3://s3cmd-autotest/sync-test s3cmd-${VER}
-rm -rf s3cmd-${VER}
-
-./s3cmd rb s3://s3cmd-autotest/ || true
-# ERROR: S3 error: 409 (Conflict): BucketNotEmpty
-
-./s3cmd rb --force s3://s3cmd-autotest/
-
-set +x
-
-echo; echo
-echo; echo
-echo "=== All good. Ready for release :-) ==="
-echo
Please sign in to comment.
Something went wrong with that request. Please try again.