git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@314 830e0280-6d2a-0410-9c65-932aecc39d9d
Michal Ludvig authored on 2008/12/31 13:09:24... | ... |
@@ -2,6 +2,8 @@ |
2 | 2 |
|
3 | 3 |
* testsuite: reorganised UTF-8 files, added GBK encoding files, |
4 | 4 |
moved encoding-specific files to 'tar.gz' archives. |
5 |
+ * run-tests.py: Adapted to the above change. |
|
6 |
+ * run-tests.sh: removed. |
|
5 | 7 |
* run-tests.py: Don't assume utf-8, use preferred encoding |
6 | 8 |
instead. |
7 | 9 |
* s3cmd, S3/Utils.py, S3/Exceptions.py, S3/Progress.py, |
... | ... |
@@ -21,15 +21,33 @@ run_tests = [] |
21 | 21 |
exclude_tests = [] |
22 | 22 |
|
23 | 23 |
if os.name == "posix": |
24 |
- have_unicode = True |
|
25 | 24 |
have_wget = True |
26 | 25 |
elif os.name == "nt": |
27 |
- have_unicode = False |
|
28 | 26 |
have_wget = False |
29 | 27 |
else: |
30 | 28 |
print "Unknown platform: %s" % os.name |
31 | 29 |
sys.exit(1) |
32 | 30 |
|
31 |
+## Patterns for Unicode tests |
|
32 |
+patterns = {} |
|
33 |
+patterns['UTF-8'] = u"ŪņЇЌœđЗ/☺ unicode € rocks ™" |
|
34 |
+patterns['GBK'] = u"12月31日/1-特色條目" |
|
35 |
+ |
|
36 |
+encoding = locale.getpreferredencoding() |
|
37 |
+if not encoding: |
|
38 |
+ print "Guessing current system encoding failed. Consider setting $LANG variable." |
|
39 |
+ sys.exit(1) |
|
40 |
+ |
|
41 |
+have_encoding = os.path.isdir('testsuite/encodings/' + encoding) |
|
42 |
+if not have_encoding and os.path.isfile('testsuite/encodings/%s.tar.gz' % encoding): |
|
43 |
+ os.system("tar xvz -C testsuite/encodings -f testsuite/encodings/UTF-8.tar.gz") |
|
44 |
+ have_encoding = os.path.isdir('testsuite/encodings/' + encoding) |
|
45 |
+ |
|
46 |
+if have_encoding: |
|
47 |
+ enc_base_remote = "s3://s3cmd-autotest-1/xyz/%s/" % encoding |
|
48 |
+ enc_pattern = patterns[encoding] |
|
49 |
+ print "System encoding: " + encoding |
|
50 |
+ |
|
33 | 51 |
def test(label, cmd_args = [], retcode = 0, must_find = [], must_not_find = [], must_find_re = [], must_not_find_re = []): |
34 | 52 |
def failure(message = ""): |
35 | 53 |
global count_fail |
... | ... |
@@ -63,7 +81,7 @@ def test(label, cmd_args = [], retcode = 0, must_find = [], must_not_find = [], |
63 | 63 |
_list = [_list] |
64 | 64 |
|
65 | 65 |
if regexps == False: |
66 |
- _list = [re.escape(item.encode(locale.getpreferredencoding(), "replace")) for item in _list] |
|
66 |
+ _list = [re.escape(item.encode(encoding, "replace")) for item in _list] |
|
67 | 67 |
|
68 | 68 |
return [re.compile(item, re.MULTILINE) for item in _list] |
69 | 69 |
|
... | ... |
@@ -187,18 +205,19 @@ test_s3cmd("Buckets list", ["ls"], |
187 | 187 |
|
188 | 188 |
|
189 | 189 |
## ====== Sync to S3 |
190 |
-exclude_unicode_args = [] |
|
191 |
-if not have_unicode: |
|
192 |
- exclude_unicode_args = [ '--exclude', 'unicode/*' ] |
|
193 |
-test_s3cmd("Sync to S3", ['sync', 'testsuite', 's3://s3cmd-autotest-1/xyz/', '--exclude', '.svn/*', '--exclude', '*.png', '--no-encrypt'] + exclude_unicode_args) |
|
190 |
+test_s3cmd("Sync to S3", ['sync', 'testsuite', 's3://s3cmd-autotest-1/xyz/', '--exclude', '.svn/*', '--exclude', '*.png', '--no-encrypt', '--exclude-from', 'testsuite/exclude.encodings' ]) |
|
191 |
+ |
|
192 |
+if have_encoding: |
|
193 |
+ ## ====== Sync UTF-8 / GBK / ... to S3 |
|
194 |
+ test_s3cmd("Sync %s to S3" % encoding, ['sync', 'testsuite/encodings/' + encoding, enc_base_remote, '--exclude', '.svn/*', '--no-encrypt' ]) |
|
194 | 195 |
|
195 | 196 |
|
196 | 197 |
## ====== List bucket content |
197 | 198 |
must_find_re = [ u"D s3://s3cmd-autotest-1/xyz/binary/$", u"D s3://s3cmd-autotest-1/xyz/etc/$" ] |
198 | 199 |
must_not_find = [ u"random-crap.md5", u".svn" ] |
199 |
-if have_unicode: |
|
200 |
- must_find_re.append(u"D s3://s3cmd-autotest-1/xyz/unicode/$") |
|
201 |
- must_not_find.append(u"ŪņЇЌœđЗ/☺ unicode € rocks ™") |
|
200 |
+if have_encoding: |
|
201 |
+ must_find_re.append(u"D %s$" % enc_base_remote) |
|
202 |
+ must_not_find.append(enc_pattern) |
|
202 | 203 |
test_s3cmd("List bucket content", ['ls', 's3://s3cmd-autotest-1/xyz/'], |
203 | 204 |
must_find_re = must_find_re, |
204 | 205 |
must_not_find = must_not_find) |
... | ... |
@@ -206,8 +225,8 @@ test_s3cmd("List bucket content", ['ls', 's3://s3cmd-autotest-1/xyz/'], |
206 | 206 |
|
207 | 207 |
## ====== List bucket recursive |
208 | 208 |
must_find = [ u"s3://s3cmd-autotest-1/xyz/binary/random-crap.md5" ] |
209 |
-if have_unicode: |
|
210 |
- must_find.append(u"s3://s3cmd-autotest-1/xyz/unicode/ŪņЇЌœđЗ/☺ unicode € rocks ™") |
|
209 |
+if have_encoding: |
|
210 |
+ must_find.append(enc_base_remote + enc_pattern) |
|
211 | 211 |
test_s3cmd("List bucket recursive", ['ls', '--recursive', 's3://s3cmd-autotest-1'], |
212 | 212 |
must_find = must_find, |
213 | 213 |
must_not_find = [ "logo.png" ]) |
... | ... |
@@ -227,8 +246,8 @@ test_rmdir("Removing local target", 'testsuite-out') |
227 | 227 |
|
228 | 228 |
## ====== Sync from S3 |
229 | 229 |
must_find = [ "stored as testsuite-out/etc/logo.png " ] |
230 |
-if have_unicode: |
|
231 |
- must_find.append(u"unicode/ŪņЇЌœđЗ/☺ unicode € rocks ™") |
|
230 |
+if have_encoding: |
|
231 |
+ must_find.append("stored as testsuite-out/" + encoding + "/" + enc_pattern) |
|
232 | 232 |
test_s3cmd("Sync from S3", ['sync', 's3://s3cmd-autotest-1/xyz', 'testsuite-out'], |
233 | 233 |
must_find = must_find) |
234 | 234 |
|
... | ... |
@@ -240,7 +259,7 @@ if have_wget: |
240 | 240 |
|
241 | 241 |
|
242 | 242 |
## ====== Sync more to S3 |
243 |
-test_s3cmd("Sync more to S3", ['sync', 'testsuite', 's3://s3cmd-autotest-1/xyz/', '--exclude', '*.png', '--no-encrypt'] + exclude_unicode_args) |
|
243 |
+test_s3cmd("Sync more to S3", ['sync', 'testsuite', 's3://s3cmd-autotest-1/xyz/', '--exclude', '*.png', '--no-encrypt', '--exclude-from', 'testsuite/exclude.encodings' ]) |
|
244 | 244 |
|
245 | 245 |
|
246 | 246 |
## ====== Rename within S3 |
... | ... |
@@ -292,7 +311,7 @@ test_s3cmd("Simple delete", ['del', 's3://s3cmd-autotest-1/xyz/etc2/Logo.PNG'], |
292 | 292 |
|
293 | 293 |
|
294 | 294 |
## ====== Recursive delete |
295 |
-test_s3cmd("Recursive delete", ['del', '--recursive', 's3://s3cmd-autotest-1/xyz/unicode'], |
|
295 |
+test_s3cmd("Recursive delete", ['del', '--recursive', 's3://s3cmd-autotest-1/xyz/etc'], |
|
296 | 296 |
must_find_re = [ "Object.*\.svn/format deleted" ]) |
297 | 297 |
|
298 | 298 |
|
299 | 299 |
deleted file mode 100755 |
... | ... |
@@ -1,41 +0,0 @@ |
1 |
-#!/bin/sh |
|
2 |
-set -e -x |
|
3 |
- |
|
4 |
-./s3cmd mb s3://s3cmd-autotest |
|
5 |
-./s3cmd ls s3://s3cmd-autotest |
|
6 |
-./s3cmd put s3cmd s3cmd.1 s3://s3cmd-autotest |
|
7 |
-./s3cmd ls s3://s3cmd-autotest |
|
8 |
-./s3cmd del s3://s3cmd-autotest/s3cmd.1 |
|
9 |
-./s3cmd get s3://s3cmd-autotest/s3cmd s3cmd.get |
|
10 |
-diff s3cmd s3cmd.get |
|
11 |
-rm -fv s3cmd.get |
|
12 |
- |
|
13 |
-set +x |
|
14 |
-echo; echo |
|
15 |
-echo "=== Now running 'sync' tests ===" |
|
16 |
-echo; echo |
|
17 |
-set -x |
|
18 |
- |
|
19 |
-VER=$(./s3cmd --version | cut -d\ -f3) |
|
20 |
-tar xvfz dist/s3cmd-${VER}.tar.gz |
|
21 |
-echo "Will be removed" > s3cmd-${VER}/file.to.remove |
|
22 |
-./s3cmd sync s3cmd-${VER} s3://s3cmd-autotest/sync-test |
|
23 |
-echo "Added file" > s3cmd-${VER}/added.file |
|
24 |
-rm -f s3cmd-${VER}/file.to.remove |
|
25 |
-./s3cmd sync --delete s3cmd-${VER} s3://s3cmd-autotest/sync-test |
|
26 |
-rm -f s3cmd-${VER}/S3/PkgInfo.py |
|
27 |
-rm -f s3cmd-${VER}/s3cmd |
|
28 |
-./s3cmd sync --delete --exclude "/s3cmd-${VER}/S3/S3*" s3://s3cmd-autotest/sync-test s3cmd-${VER} |
|
29 |
-rm -rf s3cmd-${VER} |
|
30 |
- |
|
31 |
-./s3cmd rb s3://s3cmd-autotest/ || true |
|
32 |
-# ERROR: S3 error: 409 (Conflict): BucketNotEmpty |
|
33 |
- |
|
34 |
-./s3cmd rb --force s3://s3cmd-autotest/ |
|
35 |
- |
|
36 |
-set +x |
|
37 |
- |
|
38 |
-echo; echo |
|
39 |
-echo; echo |
|
40 |
-echo "=== All good. Ready for release :-) ===" |
|
41 |
-echo |