2525 re .compile (r"(can'?t|cannot|unable to)\s+(read|open|find).*SConscript" , re .IGNORECASE ),
2626 re .compile (r'FileNotFoundError:.*SConscript' , re .IGNORECASE ),
2727 re .compile (r'scons:\s+\*\*\*' , re .IGNORECASE ),
28+ re .compile (r'RTT_CI_GUARD_TEST_SCONS_FATAL' , re .IGNORECASE ),
2829)
2930
3031def add_summary (text ):
@@ -66,7 +67,11 @@ def check_bsp_build_scripts(bsp_dir):
6667 check whether the BSP has the basic scons build entry files.
6768 """
6869 missing = []
69- for filename in ('SConstruct' , 'SConscript' ):
70+ required_files = ['SConstruct' , 'SConscript' ]
71+ if os .getenv ('RTT_CI_GUARD_TEST_MISSING_SCRIPT' ) == '1' :
72+ required_files .append ('SConscript.ci-guard-test-missing' )
73+
74+ for filename in required_files :
7075 if not os .path .isfile (os .path .join (bsp_dir , filename )):
7176 missing .append (filename )
7277
@@ -86,6 +91,28 @@ def run_cmd(cmd, output_info=True):
8691 res = 0
8792 output_file = f'output_{ os .getpid ()} _{ threading .get_ident ()} .txt'
8893 devnull = os .devnull
94+ if os .getenv ('RTT_CI_GUARD_TEST_INJECT' ) == '1' :
95+ if '--pyconfig-silent' in cmd :
96+ output_str_list = ['RTT_CI_GUARD_TEST: injected pyconfig failure\n ' ]
97+ res = 31
98+ elif cmd .startswith ('pkgs --update-force' ):
99+ output_str_list = ['RTT_CI_GUARD_TEST: injected pkgs update failure\n ' ]
100+ res = 32
101+ elif cmd .startswith ('pkgs --list' ):
102+ output_str_list = ['RTT_CI_GUARD_TEST: injected pkgs list failure\n ' ]
103+ res = 33
104+ elif re .search (r'(^|\s)scons(\s|$)' , cmd ) and '-c' not in cmd :
105+ output_str_list = ['RTT_CI_GUARD_TEST_SCONS_FATAL: injected scons fatal log\n ' ]
106+ res = 0
107+
108+ if output_str_list :
109+ for line in output_str_list :
110+ print (line , end = '' )
111+ if contains_scons_fatal_error (output_str_list ):
112+ print (f"::error::scons fatal error detected while running: { cmd } " )
113+ if res == 0 :
114+ res = 1
115+ return output_str_list , res
89116
90117 if output_info :
91118 res = os .system (cmd + f" > { output_file } 2>&1" )
0 commit comments