run-tests can now skip certain tests when run under Travis CI

See the `skip_travis_tests` variable. Fixes #495
(also tidied up usage of os.path.basename() function)
This commit is contained in:
Andrew Scheller 2014-04-16 03:28:40 +01:00
parent 2822d4e6ce
commit 1b997d5244
2 changed files with 23 additions and 16 deletions

View File

@ -1,11 +1,6 @@
# this test for MemoryError can be difficult to reproduce l = list(range(10000))
# on different machine configurations (notably Travis CI) try:
# so we disable it 100000000 * l
# TODO is there a way of testing that we are on Travis CI? except MemoryError:
if False: print('MemoryError')
l = list(range(10000)) print(len(l), l[0], l[-1])
try:
100000000 * l
except MemoryError:
print('MemoryError')
print(len(l), l[0], l[-1])

View File

@ -15,6 +15,9 @@ else:
CPYTHON3 = os.getenv('MICROPY_CPYTHON3', 'python3') CPYTHON3 = os.getenv('MICROPY_CPYTHON3', 'python3')
MP_PY = '../unix/micropython' MP_PY = '../unix/micropython'
# Set of tests that we shouldn't run under Travis CI
skip_travis_tests = set(['basics/memoryerror.py'])
def rm_f(fname): def rm_f(fname):
if os.path.exists(fname): if os.path.exists(fname):
os.remove(fname) os.remove(fname)
@ -36,8 +39,12 @@ if test_on_pyboard:
pyb = pyboard.Pyboard('/dev/ttyACM0') pyb = pyboard.Pyboard('/dev/ttyACM0')
pyb.enter_raw_repl() pyb.enter_raw_repl()
running_under_travis = os.environ.get('TRAVIS', 'false') == 'true'
for test_file in tests: for test_file in tests:
test_name = os.path.splitext(os.path.basename(test_file))[0] if running_under_travis and test_file in skip_travis_tests:
print("skip ", test_file)
continue
# run CPython # run CPython
try: try:
@ -64,15 +71,20 @@ for test_file in tests:
testcase_count += len(output_expected.splitlines()) testcase_count += len(output_expected.splitlines())
test_basename = os.path.basename(test_file)
test_name = os.path.splitext(test_basename)[0]
filename_expected = test_basename + ".exp"
filename_mupy = test_basename + ".out"
if output_expected == output_mupy: if output_expected == output_mupy:
print("pass ", test_file) print("pass ", test_file)
passed_count += 1 passed_count += 1
rm_f(os.path.basename(test_file + ".exp")) rm_f(filename_expected)
rm_f(os.path.basename(test_file + ".out")) rm_f(filename_mupy)
else: else:
with open(os.path.basename(test_file + ".exp"), "w") as f: with open(filename_expected, "w") as f:
f.write(str(output_expected, "ascii")) f.write(str(output_expected, "ascii"))
with open(os.path.basename(test_file + ".out"), "w") as f: with open(filename_mupy, "w") as f:
f.write(str(output_mupy, "ascii")) f.write(str(output_mupy, "ascii"))
print("FAIL ", test_file) print("FAIL ", test_file)
failed_tests.append(test_name) failed_tests.append(test_name)