29 lines
847 B
Python
29 lines
847 B
Python
import os.path
|
|
import subprocess
|
|
import unittest
|
|
|
|
|
|
class TestAPICompat(unittest.TestCase):
|
|
|
|
# path to dump-api script
|
|
SCRIPT = os.path.relpath(os.path.dirname(__file__) + '/../../devtools/check-api')
|
|
|
|
# base api data, as generated by dump-api
|
|
BASE = os.path.relpath(os.path.dirname(__file__) + '/data/api.json')
|
|
|
|
def test_api_compat(self):
|
|
cmd = [self.SCRIPT, self.BASE]
|
|
proc = subprocess.Popen(cmd, stderr=subprocess.PIPE)
|
|
(_, err) = proc.communicate()
|
|
status = proc.wait()
|
|
errors = 0
|
|
for line in err.decode().splitlines():
|
|
if line.startswith('ERROR'):
|
|
print(line)
|
|
errors += 1
|
|
if errors or status != 0:
|
|
print('Command failed: %s' % ' '.join(cmd))
|
|
raise Exception('API verification failed')
|
|
|
|
|
|
# the end
|