Skip to content

Commit

Permalink
actually run python3 for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shaform committed Dec 7, 2016
1 parent 289465a commit 35ee5d1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ before_script:
- sleep 4 # give minio some time to start
# command to run tests
## Tests stopped at test 23 because minio doesn't support "quote_plus" used in signatures.
script: ./run-tests-minio.py -c .travis.s3cfg -p baseauto 1..23
script: python ./run-tests-minio.py -c .travis.s3cfg -p baseauto 1..23
after_script:
- killall minio
52 changes: 27 additions & 25 deletions run-tests-minio.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
## License: GPL Version 2
## Copyright: TGRMN Software and contributors

from __future__ import print_function

import sys
import os
import re
Expand Down Expand Up @@ -62,17 +64,17 @@ def is_exe(fpath):
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"
print("Something went wrong while unpacking testsuite.tar.gz")
sys.exit(1)

os.system("tar -xf testsuite/checksum.tar -C testsuite")
if not os.path.isfile('testsuite/checksum/cksum33.txt'):
print "Something went wrong while unpacking testsuite/checkum.tar"
print("Something went wrong while unpacking testsuite/checkum.tar")
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)
os.chmod("testsuite/permission-tests/permission-denied-dir", 0o444)
os.chmod("testsuite/permission-tests/permission-denied.txt", 0o000)

## Patterns for Unicode tests
patterns = {}
Expand All @@ -81,10 +83,10 @@ def is_exe(fpath):

encoding = locale.getpreferredencoding()
if not encoding:
print "Guessing current system encoding failed. Consider setting $LANG variable."
print("Guessing current system encoding failed. Consider setting $LANG variable.")
sys.exit(1)
else:
print "System encoding: " + encoding
print("System encoding: " + encoding)

have_encoding = os.path.isdir('testsuite/encodings/' + encoding)
if not have_encoding and os.path.isfile('testsuite/encodings/%s.tar.gz' % encoding):
Expand All @@ -95,7 +97,7 @@ def is_exe(fpath):
#enc_base_remote = "%s/xyz/%s/" % (pbucket(1), encoding)
enc_pattern = patterns[encoding]
else:
print encoding + " specific files not found."
print(encoding + " specific files not found.")
# Minio: disable encoding tests
have_encoding = False

Expand All @@ -106,17 +108,17 @@ def is_exe(fpath):

def test(label, cmd_args = [], retcode = 0, must_find = [], must_not_find = [], must_find_re = [], must_not_find_re = [], stdin = None):
def command_output():
print "----"
print " ".join([" " in arg and "'%s'" % arg or arg for arg in cmd_args])
print "----"
print stdout
print "----"
print("----")
print(" ".join([" " in arg and "'%s'" % arg or arg for arg in cmd_args]))
print("----")
print(stdout)
print("----")

def failure(message = ""):
global count_fail
if message:
message = u" (%r)" % message
print u"\x1b[31;1mFAIL%s\x1b[0m" % (message)
print(u"\x1b[31;1mFAIL%s\x1b[0m" % (message))
count_fail += 1
command_output()
#return 1
Expand All @@ -125,7 +127,7 @@ def success(message = ""):
global count_pass
if message:
message = " (%r)" % message
print "\x1b[32;1mOK\x1b[0m%s" % (message)
print("\x1b[32;1mOK\x1b[0m%s" % (message))
count_pass += 1
if verbose:
command_output()
Expand All @@ -134,7 +136,7 @@ def skip(message = ""):
global count_skip
if message:
message = " (%r)" % message
print "\x1b[33;1mSKIP\x1b[0m%s" % (message)
print("\x1b[33;1mSKIP\x1b[0m%s" % (message))
count_skip += 1
return 0
def compile_list(_list, regexps = False):
Expand All @@ -145,7 +147,7 @@ def compile_list(_list, regexps = False):

global test_counter
test_counter += 1
print ("%3d %s " % (test_counter, label)).ljust(30, "."),
print(("%3d %s " % (test_counter, label)).ljust(30, "."), end=' ')
sys.stdout.flush()

if run_tests.count(test_counter) == 0 or exclude_tests.count(test_counter) > 0:
Expand Down Expand Up @@ -192,7 +194,7 @@ def compile_list(_list, regexps = False):

def test_s3cmd(label, cmd_args = [], **kwargs):
if not cmd_args[0].endswith("s3cmd"):
cmd_args.insert(0, "python2")
cmd_args.insert(0, "python")
cmd_args.insert(1, "s3cmd")
if config_file:
cmd_args.insert(2, "-c")
Expand All @@ -204,7 +206,7 @@ def test_mkdir(label, dir_name):
if os.name in ("posix", "nt"):
cmd = ['mkdir', '-p']
else:
print "Unknown platform: %s" % os.name
print("Unknown platform: %s" % os.name)
sys.exit(1)
cmd.append(dir_name)
return test(label, cmd)
Expand All @@ -216,7 +218,7 @@ def test_rmdir(label, dir_name):
elif os.name == "nt":
cmd = ['rmdir', '/s/q']
else:
print "Unknown platform: %s" % os.name
print("Unknown platform: %s" % os.name)
sys.exit(1)
cmd.append(dir_name)
return test(label, cmd)
Expand All @@ -233,7 +235,7 @@ def test_copy(label, src_file, dst_file):
elif os.name == "nt":
cmd = ['copy']
else:
print "Unknown platform: %s" % os.name
print("Unknown platform: %s" % os.name)
sys.exit(1)
cmd.append(src_file)
cmd.append(dst_file)
Expand All @@ -250,11 +252,11 @@ def test_curl_HEAD(label, src_file, **kwargs):
while argv:
arg = argv.pop(0)
if arg.startswith('--bucket-prefix='):
print "Usage: '--bucket-prefix PREFIX', not '--bucket-prefix=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"
print("%s A B K..O -N" % sys.argv[0])
print("Run tests number A, B and K through to O, except for N")
sys.exit(0)

if arg in ("-c", "--config"):
Expand All @@ -270,7 +272,7 @@ def test_curl_HEAD(label, src_file, **kwargs):
try:
bucket_prefix = argv.pop(0)
except IndexError:
print "Bucket prefix option must explicitly supply a bucket name prefix"
print("Bucket prefix option must explicitly supply a bucket name prefix")
sys.exit(0)
continue
if ".." in arg:
Expand All @@ -283,7 +285,7 @@ def test_curl_HEAD(label, src_file, **kwargs):
else:
run_tests.append(int(arg))

print "Using bucket prefix: '%s'" % bucket_prefix
print("Using bucket prefix: '%s'" % bucket_prefix)

cfg = S3.Config.Config(config_file)

Expand Down

0 comments on commit 35ee5d1

Please sign in to comment.