Files
langkit/testsuite/tests/contrib/python_parse_1/test.py
Raphael Amiard 94b9f4e5d8 Add test for python parser - #11 no-tn-check
Change-Id: I85ce20524b553437518784f4399fb227088c4332
2018-01-21 14:51:15 +01:00

36 lines
931 B
Python

"""
This tests that the Langkit based python parser can be compiled and can parse a
simple python program without errors.
TODO: This is hackish and minimalistic. Since Langkit's python parser is a
fully fledged Langkit generated lib, it would make sense to reuse Libadalang's
parser test driver.
"""
from __future__ import absolute_import, division, print_function
import os
from os import path as P
import subprocess
import sys
LK_PYTHON_LIB_DIR = P.join(os.environ['LANGKIT_ROOT_DIR'], 'contrib', 'python')
o = subprocess.check_output(
[sys.executable, P.join(LK_PYTHON_LIB_DIR, 'manage.py'), 'make'],
# CWD is the lib's directory so that lib is generated in the lib's dir, not
# in the test dir.
cwd=LK_PYTHON_LIB_DIR
)
test_py = '''
def test(a, b):
"""
Return the sum of a + b
"""
return a + b
'''
subprocess.check_call(
[P.join(LK_PYTHON_LIB_DIR, 'build', 'bin', 'parse'), test_py]
)