2020-01-19 21:42:59 -06:00
# 19 january 2020
2020-01-20 17:18:58 -06:00
2020-02-16 17:31:53 -06:00
# Using files() is the cleanest way to ensure the python script below gets the right filenames regardless of how meson sandboxes the command it's running.
libui_test_sources = files ( [
2020-02-17 14:01:20 -06:00
'events.c' ,
2020-02-23 16:36:10 -06:00
# 'events_errors.cpp',
2020-01-20 19:17:44 -06:00
'initmain.c' ,
2020-02-23 16:36:10 -06:00
# 'noinitwrongthread.c',
2020-02-16 17:31:53 -06:00
] )
2020-01-20 17:18:58 -06:00
2020-01-21 13:19:52 -06:00
libui_test_sources_without_cases = [
2020-01-26 19:02:03 -06:00
'errors.c' ,
2020-01-21 13:19:52 -06:00
'main.c' ,
]
2020-01-20 17:18:58 -06:00
if libui_OS == 'windows'
libui_test_sources_without_cases + = [
2020-01-21 13:19:52 -06:00
'thread_windows.c' ,
2020-01-20 17:18:58 -06:00
windows . compile_resources ( 'resources_' + libui_mode + '.rc' ,
args : libui_manifest_args ,
depend_files : [ 'test_' + libui_mode + '.manifest' ] ) ,
]
2020-01-21 13:19:52 -06:00
else
libui_test_sources_without_cases + = [
'thread_notwindows.c' ,
]
endif
libui_test_deps = [
dependency ( 'threads' ,
required : true ) ,
]
if libui_OS == 'windows'
# static mode already gives us these dependencies
if libui_mode != 'static'
libui_test_deps + = [
meson . get_compiler ( 'c' ) . find_library ( 'kernel32' ,
required : true ) ,
meson . get_compiler ( 'c' ) . find_library ( 'user32' ,
required : true ) ,
]
endif
2020-01-20 17:18:58 -06:00
endif
2020-02-16 17:31:53 -06:00
pymod = import ( 'python' )
python = pymod . find_installation ( )
# Likewise, use files() here to make sure the Python script itself will always have the right path.
libui_testlist_py = files ( [ 'testlist.py' ] )
libui_testlist_h = custom_target (
'testlist.h' ,
input : libui_test_sources ,
output : [ 'testlist.h' ] ,
command : [ python , libui_testlist_py , 'header' , '@OUTPUT@' , '@INPUT@' ] )
libui_testlist_c = custom_target (
'testlist.c' ,
input : libui_test_sources ,
output : [ 'testlist.c' ] ,
command : [ python , libui_testlist_py , 'source' , '@OUTPUT@' , '@INPUT@' ] )
2020-01-20 17:18:58 -06:00
# TODO once we upgrade to 0.49.0, add pie: true
# TODO once we upgrade to 0.50.0, add protocol: 'exitcode'
2020-02-16 17:31:53 -06:00
libui_testparent = executable ( 'testparent' , libui_test_sources + libui_test_sources_without_cases + [ libui_testlist_c , libui_testlist_h ] ,
2020-01-21 13:19:52 -06:00
dependencies : libui_binary_deps + libui_test_deps ,
2020-01-20 17:18:58 -06:00
link_with : libui_libui ,
gui_app : false ,
install : false )
2020-02-16 17:31:53 -06:00
runresult = run_command ( python , libui_testlist_py + [ 'list' ] + libui_test_sources )
2020-01-20 17:18:58 -06:00
if runresult . returncode ( ) != 0
error ( 'testlist.py failed; cannot compute list of test cases. Exit code @0@; stderr:\n@1@' . format ( runresult . returncode ( ) , runresult . stderr ( ) ) )
endif
foreach casename : runresult . stdout ( ) . split ( )
2020-01-20 19:55:37 -06:00
test ( casename , libui_testparent ,
2020-01-20 17:18:58 -06:00
args : [ casename ] ,
is_parallel : false ,
should_fail : false )
endforeach