diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2016-07-25 21:06:25 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2016-07-25 22:00:38 +0300 |
commit | f3c793b9c1705f4eebbc68755bea7fe7926d123f (patch) | |
tree | 6588d4036bb6dd1a2b0f847b1e6cd870cc8dfb90 /run_tests.py | |
parent | 5942baa2d186bff5a87df72a854ea1d9eac48e0c (diff) | |
download | meson-f3c793b9c1705f4eebbc68755bea7fe7926d123f.zip meson-f3c793b9c1705f4eebbc68755bea7fe7926d123f.tar.gz meson-f3c793b9c1705f4eebbc68755bea7fe7926d123f.tar.bz2 |
Added test for a prebuilt static library and a declare_dependency that uses it.
Diffstat (limited to 'run_tests.py')
-rwxr-xr-x | run_tests.py | 65 |
1 files changed, 45 insertions, 20 deletions
diff --git a/run_tests.py b/run_tests.py index b0d666f..34258d8 100755 --- a/run_tests.py +++ b/run_tests.py @@ -308,7 +308,7 @@ def detect_tests_to_run(): all_tests = [] all_tests.append(('common', gather_tests('test cases/common'), False)) all_tests.append(('failing', gather_tests('test cases/failing'), False)) - all_tests.append(('prebuilt object', gather_tests('test cases/prebuilt object'), False)) + all_tests.append(('prebuilt', gather_tests('test cases/prebuilt'), False)) all_tests.append(('platform-osx', gather_tests('test cases/osx'), False if mesonlib.is_osx() else True)) all_tests.append(('platform-windows', gather_tests('test cases/windows'), False if mesonlib.is_windows() else True)) @@ -405,27 +405,51 @@ def check_format(): fullname = os.path.join(root, file) check_file(fullname) -def generate_prebuilt_object(): - source = 'test cases/prebuilt object/1 basic/source.c' - objectbase = 'test cases/prebuilt object/1 basic/prebuilt.' - if shutil.which('cl'): - objectfile = objectbase + 'obj' - cmd = ['cl', '/nologo', '/Fo'+objectfile, '/c', source] +def pbcompile(compiler, source, objectfile): + if compiler == 'cl': + cmd = [compiler, '/nologo', '/Fo'+objectfile, '/c', source] else: - if mesonlib.is_windows(): - objectfile = objectbase + 'obj' - else: - objectfile = objectbase + 'o' - if shutil.which('cc'): - cmd = 'cc' - elif shutil.which('gcc'): - cmd = 'gcc' - else: - raise RuntimeError("Could not find C compiler.") - cmd = [cmd, '-c', source, '-o', objectfile] + cmd = [compiler, '-c', source, '-o', objectfile] subprocess.check_call(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + +def generate_pb_object(compiler, object_suffix): + source = 'test cases/prebuilt/1 object/source.c' + objectfile = 'test cases/prebuilt/1 object/prebuilt.' + object_suffix + pbcompile(compiler, source, objectfile) return objectfile +def generate_pb_static(compiler, object_suffix, static_suffix): + source = 'test cases/prebuilt/2 static/libdir/best.c' + objectfile = 'test cases/prebuilt/2 static/libdir/best.' + object_suffix + stlibfile = 'test cases/prebuilt/2 static/libdir/libbest.' + static_suffix + pbcompile(compiler, source, objectfile) + if compiler == 'cl': + linker = ['lib', '/NOLOGO', '/OUT:' + stlibfile, objectfile] + else: + linker = ['ar', 'csr', stlibfile, objectfile] + subprocess.check_call(linker) + os.unlink(objectfile) + return stlibfile + +def generate_prebuilt(): + static_suffix = 'a' + if shutil.which('cl'): + compiler = 'cl' + static_suffix = 'lib' + elif shutil.which('cc'): + compiler = 'cc' + elif shutil.which('gcc'): + compiler = 'gcc' + else: + raise RuntimeError("Could not find C compiler.") + if mesonlib.is_windows(): + object_suffix = 'obj' + else: + object_suffix = 'o' + objectfile = generate_pb_object(compiler, object_suffix) + stlibfile = generate_pb_static(compiler, object_suffix, static_suffix) + return (objectfile, stlibfile) + if __name__ == '__main__': parser = argparse.ArgumentParser(description="Run the test suite of Meson.") parser.add_argument('extra_args', nargs='*', @@ -439,12 +463,13 @@ if __name__ == '__main__': if script_dir != '': os.chdir(script_dir) check_format() - pbfile = generate_prebuilt_object() + pbfiles = generate_prebuilt() try: run_tests(options.extra_args) except StopException: pass - os.unlink(pbfile) + for f in pbfiles: + os.unlink(f) print('\nTotal passed tests:', passing_tests) print('Total failed tests:', failing_tests) print('Total skipped tests:', skipped_tests) |