meson/meson_test.py

51 lines
1.7 KiB
Python
Raw Normal View History

2013-03-03 19:29:13 +08:00
#!/usr/bin/env python3 -tt
2013-02-09 02:02:42 +08:00
# Copyright 2013 Jussi Pakkanen
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import sys, subprocess
from optparse import OptionParser
2013-02-09 02:02:42 +08:00
parser = OptionParser()
parser.add_option('--wrapper', default=None, dest='wrapper',
help='wrapper to run tests (e.g. valgrind')
def run_tests(options, datafilename):
if options.wrapper is None:
wrap = []
else:
wrap = [options.wrapper]
2013-02-09 02:02:42 +08:00
for line in open(datafilename, 'r'):
line = line.strip()
if line == '':
continue
cmd = wrap + [line]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
2013-02-09 02:02:42 +08:00
(stdo, stde) = p.communicate()
if p.returncode != 0:
print('Error running test.')
2013-03-02 05:02:06 +08:00
print('Stdout:\n' + stdo.decode())
print('Stderr:\n' + stde.decode())
2013-02-09 02:02:42 +08:00
sys.exit(1)
print('Test "%s": OK' % line)
if __name__ == '__main__':
(options, args) = parser.parse_args(sys.argv)
if len(args) != 2:
print('Test runner for Meson. Do not run on your own, mmm\'kay?')
2013-02-09 02:02:42 +08:00
print('%s [data file]' % sys.argv[0])
datafile = args[1]
run_tests(options, datafile)