@@ -2920,14 +2920,27 @@ endif
29202920# Test Generation
29212921###############################################################
29222922
2923+ # When using a meson version understanding exclude_suites, define a
2924+ # 'tmp_install' test setup (the default) that excludes tests running against a
2925+ # pre-existing install and a 'running' setup that conflicts with creation of
2926+ # the temporary installation and tap tests (which don't support running
2927+ # against a running server).
2928+
2929+ running_suites= []
2930+ install_suites= []
2931+ if meson .version().version_compare(' >=0.57' )
2932+ runningcheck= true
2933+ else
2934+ runningcheck= false
2935+ endif
2936+
29232937testwrap= files (' src/tools/testwrap' )
29242938
29252939foreach test_dir : tests
29262940 testwrap_base= [
29272941 testwrap,
29282942' --basedir' ,meson .build_root(),
29292943' --srcdir' , test_dir[' sd' ],
2930- ' --testgroup' , test_dir[' name' ],
29312944 ]
29322945
29332946foreach kind,v : test_dir
@@ -2940,55 +2953,94 @@ foreach test_dir : tests
29402953if kindin [' regress' ,' isolation' ,' ecpg' ]
29412954if kind== ' regress'
29422955 runner= pg_regress
2956+ fallback_dbname= ' regression_@0@'
29432957elif kind== ' isolation'
29442958 runner= pg_isolation_regress
2959+ fallback_dbname= ' isolation_regression_@0@'
29452960elif kind== ' ecpg'
29462961 runner= pg_regress_ecpg
2962+ fallback_dbname= ' ecpg_regression_@0@'
29472963endif
29482964
2949- test_output= test_result_dir/ test_dir[' name' ]/ kind
2965+ test_group= test_dir[' name' ]
2966+ test_group_running= test_dir[' name' ]+ ' -running'
29502967
2951- test_command= [
2968+ test_output= test_result_dir/ test_group/ kind
2969+ test_output_running= test_result_dir/ test_group_running/ kind
2970+
2971+ # Unless specified by the test, choose a non-conflicting database name,
2972+ # to avoid conflicts when running against existing server.
2973+ dbname= t.get(' dbname' ,
2974+ fallback_dbname.format(test_dir[' name' ]))
2975+
2976+ test_command_base= [
29522977 runner.full_path(),
29532978' --inputdir' , t.get(' inputdir' , test_dir[' sd' ]),
29542979' --expecteddir' , t.get(' expecteddir' , test_dir[' sd' ]),
2955- ' --outputdir' , test_output,
2956- ' --temp-instance' , test_output/ ' tmp_check' ,
29572980' --bindir' ,'' ,
29582981' --dlpath' , test_dir[' bd' ],
29592982' --max-concurrent-tests=20' ,
2960- ' --port ' ,testport.to_string() ,
2983+ ' --dbname ' ,dbname ,
29612984 ]+ t.get(' regress_args' , [])
29622985
2986+ test_selection= []
29632987if t.has_key(' schedule' )
2964- test_command += [' --schedule' , t[' schedule' ],]
2988+ test_selection += [' --schedule' , t[' schedule' ],]
29652989endif
29662990
29672991if kind== ' isolation'
2968- test_command += t.get(' specs' , [])
2992+ test_selection += t.get(' specs' , [])
29692993else
2970- test_command += t.get(' sql' , [])
2994+ test_selection += t.get(' sql' , [])
29712995endif
29722996
29732997 env= test_env
29742998 env.prepend(' PATH' , temp_install_bindir, test_dir[' bd' ])
29752999
29763000 test_kwargs= {
2977- ' suite' : [test_dir[' name' ]],
29783001' priority' :10 ,
29793002' timeout' :1000 ,
29803003' depends' : test_deps+ t.get(' deps' , []),
29813004' env' : env,
29823005 }+ t.get(' test_kwargs' , {})
29833006
2984- test (test_dir[ ' name ' ] / kind,
3007+ test (test_group / kind,
29853008 python,
2986- args : testwrap_base+ [
3009+ args : [
3010+ testwrap_base,
3011+ ' --testgroup' , test_group,
29873012' --testname' , kind,
2988- ' --' , test_command,
3013+ ' --' ,
3014+ test_command_base,
3015+ ' --outputdir' , test_output,
3016+ ' --temp-instance' , test_output/ ' tmp_check' ,
3017+ ' --port' , testport.to_string(),
3018+ test_selection,
29893019 ],
3020+ suite : test_group,
29903021kwargs : test_kwargs,
29913022 )
3023+ install_suites+= test_group
3024+
3025+ # some tests can't support running against running DB
3026+ if runningcheckand t.get(' runningcheck' ,true )
3027+ test (test_group_running/ kind,
3028+ python,
3029+ args : [
3030+ testwrap_base,
3031+ ' --testgroup' , test_group_running,
3032+ ' --testname' , kind,
3033+ ' --' ,
3034+ test_command_base,
3035+ ' --outputdir' , test_output_running,
3036+ test_selection,
3037+ ],
3038+ is_parallel : t.get(' runningcheck-parallel' ,true ),
3039+ suite : test_group_running,
3040+ kwargs : test_kwargs,
3041+ )
3042+ running_suites+= test_group_running
3043+ endif
29923044
29933045 testport+= 1
29943046elif kind== ' tap'
@@ -3011,9 +3063,10 @@ foreach test_dir : tests
30113063 env.set(name, value)
30123064endforeach
30133065
3066+ test_group= test_dir[' name' ]
30143067 test_kwargs= {
30153068' protocol' :' tap' ,
3016- ' suite' :[test_dir[ ' name ' ]] ,
3069+ ' suite' :test_group ,
30173070' timeout' :1000 ,
30183071' depends' : test_deps+ t.get(' deps' , []),
30193072' env' : env,
@@ -3033,12 +3086,14 @@ foreach test_dir : tests
30333086 python,
30343087kwargs : test_kwargs,
30353088args : testwrap_base+ [
3089+ ' --testgroup' , test_dir[' name' ],
30363090' --testname' , onetap_p,
30373091' --' , test_command,
30383092 test_dir[' sd' ]/ onetap,
30393093 ],
30403094 )
30413095endforeach
3096+ install_suites+= test_group
30423097else
30433098error (' unknown kind @0@ of test in @1@' .format(kind, test_dir[' sd' ]))
30443099endif
@@ -3047,6 +3102,14 @@ foreach test_dir : tests
30473102
30483103endforeach # directories with tests
30493104
3105+ # repeat condition so meson realizes version dependency
3106+ if meson .version().version_compare(' >=0.57' )
3107+ add_test_setup (' tmp_install' ,
3108+ is_default :true ,
3109+ exclude_suites : running_suites)
3110+ add_test_setup (' running' ,
3111+ exclude_suites : [' setup' ]+ install_suites)
3112+ endif
30503113
30513114
30523115###############################################################