30
30
TEST_DIR : Final = REPO_ROOT / 'tests/ethereum-tests'
31
31
GOLDEN : Final = (REPO_ROOT / 'tests/templates/output-success-llvm.json' ).read_text ().rstrip ()
32
32
TEST_FILES_WITH_CID_0 : Final = (REPO_ROOT / 'tests/bchain.0.chainId' ).read_text ().splitlines ()
33
+ FAILING_TESTS_FILE : Final = REPO_ROOT / 'tests/failing.llvm'
34
+ SLOW_TESTS_FILE : Final = REPO_ROOT / 'tests/slow.llvm'
33
35
34
36
35
- def _test (gst_file : Path , schedule : str , mode : str , usegas : bool ) -> None :
37
+ def _test (gst_file : Path , * , schedule : str , mode : str , usegas : bool , save_failing : bool ) -> None :
36
38
skipped_gst_tests = SKIPPED_TESTS .get (gst_file , [])
37
39
if '*' in skipped_gst_tests :
38
40
pytest .skip ()
39
41
40
- chainid = 0 if str (gst_file .relative_to (TEST_DIR )) in TEST_FILES_WITH_CID_0 else 1
42
+ failing_tests : list [str ] = []
43
+ gst_file_relative_path : Final [str ] = str (gst_file .relative_to (TEST_DIR ))
44
+ chainid = 0 if gst_file_relative_path in TEST_FILES_WITH_CID_0 else 1
41
45
42
46
with gst_file .open () as f :
43
47
gst_data = json .load (f )
@@ -47,7 +51,24 @@ def _test(gst_file: Path, schedule: str, mode: str, usegas: bool) -> None:
47
51
if test_name in skipped_gst_tests :
48
52
continue
49
53
res = interpret ({test_name : test }, schedule , mode , chainid , usegas , check = False )
50
- _assert_exit_code_zero (res )
54
+
55
+ try :
56
+ _assert_exit_code_zero (res )
57
+ except AssertionError :
58
+ if not save_failing :
59
+ raise
60
+ failing_tests .append (test_name )
61
+
62
+ if not failing_tests :
63
+ return
64
+ if save_failing :
65
+ with FAILING_TESTS_FILE .open ('a' ) as ff :
66
+ if len (failing_tests ) == len (gst_data ):
67
+ ff .write (f'{ gst_file_relative_path } ,*\n ' )
68
+ else :
69
+ for test_name in sorted (failing_tests ):
70
+ ff .write (f'{ gst_file_relative_path } ,{ test_name } \n ' )
71
+ raise AssertionError (f'Found failing tests in GST file { gst_file_relative_path } : { failing_tests } ' )
51
72
52
73
53
74
def _assert_exit_code_zero (pattern : Pattern ) -> None :
@@ -66,8 +87,8 @@ def _assert_exit_code_zero(pattern: Pattern) -> None:
66
87
67
88
68
89
def _skipped_tests () -> dict [Path , list [str ]]:
69
- slow_tests = read_csv_file (REPO_ROOT / 'tests/slow.llvm' )
70
- failing_tests = read_csv_file (REPO_ROOT / 'tests/failing.llvm' )
90
+ slow_tests = read_csv_file (SLOW_TESTS_FILE )
91
+ failing_tests = read_csv_file (FAILING_TESTS_FILE )
71
92
skipped : dict [Path , list [str ]] = {}
72
93
for test_file , test in slow_tests + failing_tests :
73
94
test_file = TEST_DIR / test_file
@@ -93,8 +114,8 @@ def read_csv_file(csv_file: Path) -> tuple[tuple[Path, str], ...]:
93
114
VM_TESTS ,
94
115
ids = [str (test_file .relative_to (VM_TEST_DIR )) for test_file in VM_TESTS ],
95
116
)
96
- def test_vm (test_file : Path ) -> None :
97
- _test (test_file , 'DEFAULT' , 'VMTESTS' , True )
117
+ def test_vm (test_file : Path , save_failing : bool ) -> None :
118
+ _test (test_file , schedule = 'DEFAULT' , mode = 'VMTESTS' , usegas = True , save_failing = save_failing )
98
119
99
120
100
121
@pytest .mark .skip (reason = 'failing / slow VM tests' )
@@ -103,8 +124,8 @@ def test_vm(test_file: Path) -> None:
103
124
SKIPPED_VM_TESTS ,
104
125
ids = [str (test_file .relative_to (VM_TEST_DIR )) for test_file in SKIPPED_VM_TESTS ],
105
126
)
106
- def test_rest_vm (test_file : Path ) -> None :
107
- _test (test_file , 'DEFAULT' , 'VMTESTS' , True )
127
+ def test_rest_vm (test_file : Path , save_failing : bool ) -> None :
128
+ _test (test_file , schedule = 'DEFAULT' , mode = 'VMTESTS' , usegas = True , save_failing = save_failing )
108
129
109
130
110
131
ALL_TEST_DIR : Final = TEST_DIR / 'BlockchainTests/GeneralStateTests'
@@ -118,8 +139,8 @@ def test_rest_vm(test_file: Path) -> None:
118
139
BCHAIN_TESTS ,
119
140
ids = [str (test_file .relative_to (ALL_TEST_DIR )) for test_file in BCHAIN_TESTS ],
120
141
)
121
- def test_bchain (test_file : Path ) -> None :
122
- _test (test_file , 'CANCUN' , 'NORMAL' , True )
142
+ def test_bchain (test_file : Path , save_failing : bool ) -> None :
143
+ _test (test_file , schedule = 'CANCUN' , mode = 'NORMAL' , usegas = True , save_failing = save_failing )
123
144
124
145
125
146
@pytest .mark .skip (reason = 'failing / slow blockchain tests' )
@@ -128,5 +149,5 @@ def test_bchain(test_file: Path) -> None:
128
149
SKIPPED_BCHAIN_TESTS ,
129
150
ids = [str (test_file .relative_to (ALL_TEST_DIR )) for test_file in SKIPPED_BCHAIN_TESTS ],
130
151
)
131
- def test_rest_bchain (test_file : Path ) -> None :
132
- _test (test_file , 'CANCUN' , 'NORMAL' , True )
152
+ def test_rest_bchain (test_file : Path , save_failing : bool ) -> None :
153
+ _test (test_file , schedule = 'CANCUN' , mode = 'NORMAL' , usegas = True , save_failing = save_failing )
0 commit comments