1212from tool .html import assert_html_valid
1313from tool .junit import generate_junit
1414from tool .merge import merge_covdata
15- from tool .remote import load_remote_binaries , load_remote_for_unit_test , TestType , get_flag_str
15+ from tool .process import run_process
16+ from tool .remote import load_remote_binaries_as_test , load_remote_for_unit_test , TestType , get_flag_str
1617from tool .utils import log , get_project_root , ensure_dir , format_time , load_skip , get_covdata_integration_dir , \
1718 find_unused_port , init_dirs , write_github_summary
1819
@@ -173,12 +174,12 @@ def run_integration_tests(typ: str, gsa_path: str):
173174
174175 targets = []
175176 match typ :
176- case "web" :
177+ case "web" | "flag" :
177178 pass # analyze itself, nothing to do
178179 case "example" :
179- targets = load_remote_binaries (lambda x : x .startswith ("bin-" ))
180+ targets = load_remote_binaries_as_test (lambda x : x .startswith ("bin-" ))
180181 case "real" :
181- targets = load_remote_binaries (lambda x : not x .startswith ("bin-" ))
182+ targets = load_remote_binaries_as_test (lambda x : not x .startswith ("bin-" ))
182183 case _:
183184 raise Exception (f"Unknown integration test type: { typ } " )
184185
@@ -191,6 +192,9 @@ def run_integration_tests(typ: str, gsa_path: str):
191192 run_web_test (gsa_path )
192193 return
193194
195+ if typ == "flag" :
196+ run_version_and_help_test (gsa_path )
197+
194198 all_tests = len (targets )
195199 completed_tests = 0
196200
@@ -222,13 +226,45 @@ def report_typ(rtyp: TestType):
222226 completed_tests += 1
223227
224228 if scope_failed_count == 0 :
225- log ("Integration tests passed." )
229+ log (f "Integration tests { typ } passed." )
226230 else :
227- log (f"{ scope_failed_count } integration tests failed." )
231+ log (f"{ scope_failed_count } { typ } integration tests failed." )
228232 global global_failed
229233 global_failed += scope_failed_count
230234
231235
236+ def run_version_and_help_test (entry : str ):
237+ log ("Running flag test..." )
238+
239+ def get_file (n : str ):
240+ d = os .path .join (get_project_root (), "results" , n )
241+ ensure_dir (d )
242+ return os .path .join (d , f"{ n } .output.txt" )
243+
244+ try :
245+ [out , _ ] = run_process ([entry , "--version" ],
246+ "version" ,
247+ profiler_dir = os .path .join (get_project_root (), "results" , "version" , "profiler" ),
248+ timeout = 2 ,
249+ draw = False )
250+
251+ with open (get_file ("version" ), "w" , encoding = "utf-8" ) as f :
252+ f .write (out )
253+
254+ [out , _ ] = run_process ([entry , "--help" ],
255+ "help" ,
256+ profiler_dir = os .path .join (get_project_root (), "results" , "help" , "profiler" ),
257+ timeout = 2 ,
258+ draw = False )
259+
260+ with open (get_file ("help" ), "w" , encoding = "utf-8" ) as f :
261+ f .write (out )
262+
263+ except Exception as e :
264+ log (f"flag test failed: { e } " )
265+ exit (1 )
266+
267+
232268def run_web_test (entry : str ):
233269 log ("Running web test..." )
234270
@@ -345,6 +381,7 @@ def get_parser() -> ArgumentParser:
345381 with build_gsa () as gsa :
346382 if args .integration_example :
347383 run_integration_tests ("web" , gsa )
384+ run_integration_tests ("flag" , gsa )
348385 run_integration_tests ("example" , gsa )
349386 if args .integration_real :
350387 run_integration_tests ("real" , gsa )
0 commit comments