sourcemod/sourcepawn/compiler/tests/runtests.py
David Anderson 63ad5eff18 Introduce basic methodmaps (PR #38).
commit 1e5213d43f
Author: David Anderson <dvander@alliedmods.net>
Date:   Sat Jun 21 04:09:27 2014 -0700

    Quell MSVC C99 bugs.

commit f2e166c592
Author: David Anderson <dvander@alliedmods.net>
Date:   Sat Jun 21 03:59:23 2014 -0700

    Fix varying levels of stupid memory errors.

commit b0773d7be4
Author: David Anderson <dvander@alliedmods.net>
Date:   Sat Jun 21 03:36:39 2014 -0700

    Fix memory leak in parsing some control flow structures.

commit 5aca55713c
Author: David Anderson <dvander@alliedmods.net>
Date:   Sat Jun 21 03:35:17 2014 -0700

    Fix memory leak in struct parsing.

commit b46ec5cd28
Author: David Anderson <dvander@alliedmods.net>
Date:   Sat Jun 21 03:32:03 2014 -0700

    Fix build.

commit 17bbbb9a46
Merge: c083409 2107599
Author: David Anderson <dvander@alliedmods.net>
Date:   Sat Jun 21 01:26:27 2014 -0700

    Merge branch 'master' into methodmaps

commit c083409b56
Author: David Anderson <dvander@alliedmods.net>
Date:   Fri Jun 20 23:49:36 2014 -0700

    Add VS2k13 support.

commit b799377849
Author: David Anderson <dvander@alliedmods.net>
Date:   Fri Jun 20 01:28:08 2014 -0700

    Implement destructors.

commit 1a340dec26
Author: David Anderson <dvander@alliedmods.net>
Date:   Fri Jun 20 00:08:04 2014 -0700

    Add some tests.

commit 12db52ee64
Author: David Anderson <dvander@alliedmods.net>
Date:   Fri Jun 20 00:05:49 2014 -0700

    Initial implementation of constructors.

commit 074669a658
Author: David Anderson <dvander@alliedmods.net>
Date:   Thu Jun 19 22:42:35 2014 -0700

    Add simple test harness.

commit 27c1e3cf14
Author: David Anderson <dvander@alliedmods.net>
Date:   Thu Jun 19 22:15:42 2014 -0700

    Big refactoring for new syntax.

commit f3c37fdc91
Author: David Anderson <dvander@alliedmods.net>
Date:   Thu Jun 19 22:12:54 2014 -0700

    Refactor tests for the new syntax.

commit 6211f392f8
Author: David Anderson <dvander@alliedmods.net>
Date:   Wed Jun 18 22:25:48 2014 -0700

    Make lexer tokens an enum.

commit 5210b01375
Author: David Anderson <dvander@alliedmods.net>
Date:   Tue Jun 17 06:48:15 2014 -0700

    Add comment.

commit 06688ff4ac
Author: David Anderson <dvander@alliedmods.net>
Date:   Tue Jun 17 06:46:10 2014 -0700

    Allow |this| to be a base type of the methodmap.

commit 05cf368202
Author: David Anderson <dvander@alliedmods.net>
Date:   Mon Jun 16 22:11:58 2014 -0700

    Unify duplicate typesymbol checking.

commit 09161bf269
Author: David Anderson <dvander@alliedmods.net>
Date:   Mon Jun 16 19:53:36 2014 -0700

    Close loophole that allowed methodmaps for enums.

commit 5bb4aeba89
Author: David Anderson <dvander@alliedmods.net>
Date:   Mon Jun 16 01:50:42 2014 -0700

    Add tests and dbi/handle changes.

commit b9203e2491
Author: David Anderson <dvander@alliedmods.net>
Date:   Mon Jun 16 01:38:29 2014 -0700

    Ensure methodmap tags are fixed.

commit 878b80fd87
Author: David Anderson <dvander@alliedmods.net>
Date:   Mon Jun 16 01:36:04 2014 -0700

    Implement inheritance.

commit 6ba9e004fb
Author: David Anderson <dvander@alliedmods.net>
Date:   Mon Jun 16 01:31:00 2014 -0700

    Refactor matchtag() to not be insane.

commit 4ede6343b0
Author: David Anderson <dvander@alliedmods.net>
Date:   Mon Jun 16 01:20:50 2014 -0700

    Fix indenting.

commit e3ddef8916
Author: David Anderson <dvander@alliedmods.net>
Date:   Mon Jun 16 01:20:27 2014 -0700

    Initial prototype.
2014-06-21 04:10:15 -07:00

75 lines
2.2 KiB
Python

# vim: set ts=4 sw=4 tw=99 et:
import os, sys
import argparse
import subprocess
def run_tests(args):
testdir = os.path.dirname(os.path.abspath(__file__))
tests = []
for filename in os.listdir(testdir):
base, ext = os.path.splitext(filename)
if ext == '.sp':
tests += [base]
failed = False
for test in tests:
print('Testing {0}...'.format(test))
if test.startswith('fail-'):
kind = 'fail'
elif test.startswith('warn-'):
kind = 'warn'
elif test.startswith('ok-'):
kind = 'pass'
try:
argv = [args.spcomp, os.path.join(testdir, test + '.sp')]
p = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
stdout = stdout.decode('utf-8')
stderr = stderr.decode('utf-8')
smx_path = test + '.smx'
compiled = os.path.exists(smx_path)
if compiled:
os.unlink(smx_path)
status = 'ok'
if compiled and kind == 'fail':
status = 'fail'
elif not compiled and kind != 'fail':
status = 'fail'
if status == 'ok' and kind != 'pass':
with open(os.path.join(testdir, test + '.txt')) as fp:
text = fp.read()
if text not in stdout:
print('Expected to find text in stdout: >>>')
print(text)
print('<<<')
status = 'fail'
if status == 'fail':
failed = True
print('FAILED! Dumping stdout/stderr:')
print(stdout)
print(stderr)
else:
print('... OK!')
except Exception as exn:
raise
sys.stderr.write('FAILED! {0}\n'.format(exn.message))
if failed:
sys.exit(1)
def main():
parser = argparse.ArgumentParser()
parser.add_argument('spcomp', type=str, help='Path to spcomp')
args = parser.parse_args()
run_tests(args)
if __name__ == '__main__':
main()