(top_dir, source_id_to_file_names, new_ids_only=False)
| 170 | |
| 171 | |
| 172 | def examine_id_coverage(top_dir, source_id_to_file_names, new_ids_only=False): |
| 173 | test_sub_dirs = [ |
| 174 | path.join("test", "libsolidity", "natspecJSON"), |
| 175 | path.join("test", "libsolidity", "smtCheckerTests"), |
| 176 | path.join("test", "libsolidity", "syntaxTests"), |
| 177 | path.join("test", "libyul", "yulSyntaxTests") |
| 178 | ] |
| 179 | test_file_names = find_files( |
| 180 | top_dir, |
| 181 | test_sub_dirs, |
| 182 | [".sol", ".yul"] |
| 183 | ) |
| 184 | source_ids = source_id_to_file_names.keys() |
| 185 | test_ids = find_ids_in_test_files(test_file_names) |
| 186 | |
| 187 | # special case, we are interested in warnings which are ignored by regular tests: |
| 188 | # Warning (1878): SPDX license identifier not provided in source file. .... |
| 189 | # Warning (3420): Source file does not specify required compiler version! |
| 190 | test_ids |= find_ids_in_cmdline_test_err(path.join(top_dir, "test", "cmdlineTests", "error_codes", "err")) |
| 191 | |
| 192 | # white list of ids which are not covered by tests |
| 193 | white_ids = { |
| 194 | "9804", # Tested in test/libyul/ObjectParser.cpp. |
| 195 | "1544", |
| 196 | "1749", |
| 197 | "2674", |
| 198 | "6367", |
| 199 | "8387", |
| 200 | "3805", # "This is a pre-release compiler version, please do not use it in production." |
| 201 | # The warning may or may not exist in a compiler build. |
| 202 | "4591", # "There are more than 256 warnings. Ignoring the rest." |
| 203 | # Due to 3805, the warning lists look different for different compiler builds. |
| 204 | "1920", # Unimplemented feature error from YulStack (currently there are no UnimplementedFeatureErrors thrown by libyul) |
| 205 | "7053", # Unimplemented feature error (parsing stage), currently has no tests |
| 206 | "2339", # SMTChecker, covered by CL tests |
| 207 | "6240", # SMTChecker, covered by CL tests |
| 208 | "2788", # SMTChecker: BMC: verification condition(s) could not be proved |
| 209 | "1733", # AsmAnalysis: expecting bool expression (everything is implicitly bool without types in Yul) |
| 210 | "9547", # AsmAnalysis: assigning incompatible types in Yul (whitelisted as there are currently no types) |
| 211 | "5026", # ContractLevelChecker: too difficult to exceed transient storage max size due to only value types supported. |
| 212 | } |
| 213 | assert len(test_ids & white_ids) == 0, "The sets are not supposed to intersect" |
| 214 | test_ids |= white_ids |
| 215 | |
| 216 | test_only_ids = test_ids - source_ids |
| 217 | source_only_ids = source_ids - test_ids |
| 218 | |
| 219 | if not new_ids_only: |
| 220 | print(f"IDs in source files: {len(source_ids)}") |
| 221 | print(f"IDs in test files : {len(test_ids)} ({len(test_ids) - len(source_ids)})") |
| 222 | print() |
| 223 | |
| 224 | if len(test_only_ids) != 0: |
| 225 | print("Error. The following error codes found in tests, but not in sources:") |
| 226 | print_ids(test_only_ids) |
| 227 | return False |
| 228 | |
| 229 | if len(source_only_ids) != 0: |
no test coverage detected