diff options
author | Markus Siemens <siemens1993@gmail.com> | 2014-01-27 22:53:28 +0100 |
---|---|---|
committer | Markus Siemens <siemens1993@gmail.com> | 2014-01-28 18:21:05 +0100 |
commit | 19ccc6bdc7c761cc94e740c775f13506992ca0d6 (patch) | |
tree | 1c44e4b08c1c6b3f9903d6d0f92fb290fc19e0d1 /tests | |
parent | 9b00dad7bb0125a3459ca4f9c939c7510bd2f77f (diff) | |
download | micropython-19ccc6bdc7c761cc94e740c775f13506992ca0d6.tar.gz micropython-19ccc6bdc7c761cc94e740c775f13506992ca0d6.zip |
Added Windows port (see #233)
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/run-tests | 106 |
1 files changed, 51 insertions, 55 deletions
diff --git a/tests/run-tests b/tests/run-tests index 752138ccc6..ed5a3b20ae 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -1,55 +1,51 @@ -#!/usr/bin/env bash - -RM="/bin/rm -f" -CPYTHON3=python3.3 -MP_PY=../unix/micropython - -numtests=0 -numtestcases=0 -numpassed=0 -numfailed=0 -namefailed= - -if [ $# -eq 0 ] -then - tests="basics/*.py io/*.py" -else - tests="$@" -fi - -for infile in $tests -do - basename=`basename $infile .py` - outfile=${basename}.out - expfile=${basename}.exp - - $CPYTHON3 -B $infile > $expfile - $MP_PY $infile > $outfile - ((numtestcases = numtestcases + $(cat $expfile | wc -l))) - - diff --brief $expfile $outfile > /dev/null - - if [ $? -eq 0 ] - then - echo "pass $infile" - $RM $outfile - $RM $expfile - ((numpassed=numpassed + 1)) - else - echo "FAIL $infile" - ((numfailed=numfailed + 1)) - namefailed="$namefailed $basename" - fi - - ((numtests=numtests + 1)) -done - -echo "$numtests tests performed ($numtestcases individual testcases)" -echo "$numpassed tests passed" -if [[ $numfailed != 0 ]] -then - echo "$numfailed tests failed -$namefailed" - exit 1 -else - exit 0 -fi +#! /usr/bin/env python3.3 + +import os +import subprocess +import sys +from glob import glob + +if os.name == 'nt': + CPYTHON3 = 'python3.3.exe' + MP_PY = '../windows/micropython.exe' +else: + CPYTHON3 = 'python3.3' + MP_PY = '../unix/micropython' + + +test_count = 0 +testcase_count = 0 +passed_count = 0 +failed_tests = [] +tests = [] + +if not sys.argv[1:]: + tests = glob('basics/*.py') + glob('io/*.py') +else: + tests = sys.argv[1:] + +for test_file in tests: + test_name = os.path.splitext(os.path.basename(test_file))[0] + + output_expected = subprocess.check_output([CPYTHON3, '-B', test_file]) + output_mypy = subprocess.check_output([MP_PY, test_file]) + + testcase_count += len(output_expected.splitlines()) + + if output_expected != output_mypy: + print("pass ", test_file) + passed_count += 1 + else: + print("FAIL ", test_file) + failed_tests.append(test_name) + + test_count += 1 + +print("{} tests performed ({} individual testcases)".format(test_count, + testcase_count)) +print("{} tests passed".format(passed_count)) + +if len(failed_tests) > 0: + print("{} tests failed: {}".format(len(failed_tests), + ' '.join(failed_tests))) + sys.exit(1) |