@@ -186,6 +186,36 @@ def setup_contracts(workdir: str, exclude_tests: bool = False) -> None:
186186 copier .process_directory (root , dirs , files )
187187
188188
189+ def get_integration_tests () -> list :
190+ """Get all integration tests with their source paths and converted names.
191+
192+ Returns:
193+ List of tuples: (src_file_path, converted_name)
194+ """
195+ src_testdata = "tests/integration/testdata"
196+
197+ if not os .path .exists (src_testdata ):
198+ return []
199+
200+ tests = []
201+ for root , _ , files in os .walk (src_testdata ):
202+ for file in files :
203+ if file .endswith (".txtar" ):
204+ src_file = os .path .abspath (os .path .join (root , file ))
205+ rel_dir = os .path .relpath (root , src_testdata )
206+ name_without_ext = file .replace (".txtar" , "" )
207+
208+ if rel_dir != "." :
209+ prefix = rel_dir .replace (os .sep , "_" ) + "_"
210+ converted_name = prefix + name_without_ext
211+ else :
212+ converted_name = name_without_ext
213+
214+ tests .append ((src_file , converted_name ))
215+
216+ return tests
217+
218+
189219def copy_integration_tests (workdir : str ) -> None :
190220 """Copy integration test files from tests/integration to gno/gno.land/pkg/integration."""
191221 module_manager = GnoModuleManager (workdir )
@@ -206,32 +236,16 @@ def copy_integration_tests(workdir: str) -> None:
206236
207237 print (f"Copying integration tests from { src_testdata } to { dest_testdata } " )
208238
209- # Walk through all directories and find txtar files
210- for root , _ , files in os .walk (src_testdata ):
211- for file in files :
212- if file .endswith (".txtar" ):
213- src_file = os .path .abspath (os .path .join (root , file ))
214-
215- # Calculate relative path from src_testdata
216- rel_dir = os .path .relpath (root , src_testdata )
217-
218- # If file is in a subdirectory, add directory name as prefix
219- if rel_dir != "." :
220- # Convert nested paths to prefix (e.g., "gov/governance" -> "gov_governance_")
221- prefix = rel_dir .replace (os .sep , "_" ) + "_"
222- dest_filename = prefix + file
223- else :
224- dest_filename = file
225-
226- dest_file = os .path .join (dest_testdata , dest_filename )
239+ for src_file , converted_name in get_integration_tests ():
240+ dest_file = os .path .join (dest_testdata , converted_name + ".txtar" )
227241
228- # Remove existing file/link if present
229- if os .path .exists (dest_file ) or os .path .islink (dest_file ):
230- os .unlink (dest_file )
242+ # Remove existing file/link if present
243+ if os .path .exists (dest_file ) or os .path .islink (dest_file ):
244+ os .unlink (dest_file )
231245
232- # Create symlink
233- os .symlink (src_file , dest_file )
234- print (f" Linked: { file } -> { dest_filename } " )
246+ # Create symlink
247+ os .symlink (src_file , dest_file )
248+ print (f" Linked: { os . path . basename ( src_file ) } -> { converted_name } .txtar " )
235249
236250 # Copy bless directory
237251 src_bless = "tests/integration/bless"
@@ -264,33 +278,32 @@ def copy_integration_tests(workdir: str) -> None:
264278 print (f" Linked: { file } " )
265279
266280
267- def list_integration_tests () -> None :
281+ def load_skip_tests (skip_file : str ) -> set :
282+ """Load skip list from file."""
283+ skip_tests = set ()
284+ if os .path .exists (skip_file ):
285+ with open (skip_file ) as f :
286+ for line in f :
287+ line = line .strip ()
288+ if line and not line .startswith ("#" ):
289+ skip_tests .add (line )
290+ return skip_tests
291+
292+
293+ def list_integration_tests (skip : bool = False ) -> None :
268294 """List all integration tests with their converted names."""
269- src_testdata = "tests/integration/testdata"
295+ skip_file = "tests/integration/testdata-skip.txt "
270296
271- if not os .path .exists (src_testdata ):
297+ tests = get_integration_tests ()
298+ if not tests :
272299 print ("Error: Test directory not found" , file = sys .stderr )
273300 sys .exit (1 )
274301
275- tests = []
276- for root , _ , files in os .walk (src_testdata ):
277- for file in files :
278- if file .endswith (".txtar" ):
279- # Get relative directory from testdata root
280- rel_dir = os .path .relpath (root , src_testdata )
281- name_without_ext = file .replace (".txtar" , "" )
302+ skip_tests = load_skip_tests (skip_file ) if skip else set ()
282303
283- # If in subdirectory, add prefix
284- if rel_dir != "." :
285- prefix = rel_dir .replace (os .sep , "_" ) + "_"
286- converted_name = prefix + name_without_ext
287- else :
288- converted_name = name_without_ext
289-
290- tests .append (converted_name )
291-
292- for test in sorted (tests ):
293- print (test )
304+ for _ , converted_name in sorted (tests , key = lambda x : x [1 ]):
305+ if converted_name not in skip_tests :
306+ print (converted_name )
294307
295308
296309def main () -> None :
@@ -315,11 +328,16 @@ def main() -> None:
315328 action = "store_true" ,
316329 help = "List all integration tests with converted names" ,
317330 )
331+ parser .add_argument (
332+ "--skip" ,
333+ action = "store_true" ,
334+ help = "Exclude tests listed in testdata-skip.txt" ,
335+ )
318336
319337 args = parser .parse_args ()
320338
321339 if args .list_tests :
322- list_integration_tests ()
340+ list_integration_tests (skip = args . skip )
323341 return
324342
325343 if args .clone :
0 commit comments