()
| 1199 | } |
| 1200 | |
| 1201 | async function assertFileSystemIsValid() { |
| 1202 | /** |
| 1203 | * Check that files exist only where files belong, and directories exist only |
| 1204 | * where directories belong. |
| 1205 | */ |
| 1206 | { |
| 1207 | for (const dirent of await fs.readdir(SchemaDir, { |
| 1208 | withFileTypes: true, |
| 1209 | })) { |
| 1210 | if (isIgnoredFile(dirent.name)) continue |
| 1211 | |
| 1212 | const schemaName = dirent.name |
| 1213 | const schemaPath = path.join(SchemaDir, schemaName) |
| 1214 | |
| 1215 | if (!dirent.isFile()) { |
| 1216 | printErrorAndExit(new Error(), [ |
| 1217 | `Expected only files under directory "${SchemaDir}"`, |
| 1218 | `Found non-file at "./${schemaPath}"`, |
| 1219 | ]) |
| 1220 | } |
| 1221 | } |
| 1222 | |
| 1223 | await Promise.all([onTestDir(TestPositiveDir), onTestDir(TestNegativeDir)]) |
| 1224 | async function onTestDir(/** @type {string} */ rootTestDir) { |
| 1225 | for (const dirent of await fs.readdir(rootTestDir, { |
| 1226 | withFileTypes: true, |
| 1227 | })) { |
| 1228 | if (isIgnoredFile(dirent.name)) continue |
| 1229 | |
| 1230 | const testDir = path.join(rootTestDir, dirent.name) |
| 1231 | if (!dirent.isDirectory()) { |
| 1232 | printErrorAndExit(new Error(), [ |
| 1233 | `Expected only directories under directory "${rootTestDir}"`, |
| 1234 | `Found non-directory at "./${testDir}"`, |
| 1235 | ]) |
| 1236 | } |
| 1237 | |
| 1238 | for (const dirent of await fs.readdir(testDir, { |
| 1239 | withFileTypes: true, |
| 1240 | })) { |
| 1241 | if (isIgnoredFile(dirent.name)) continue |
| 1242 | |
| 1243 | const schemaName = dirent.name |
| 1244 | const schemaPath = path.join(testDir, schemaName) |
| 1245 | |
| 1246 | if (!dirent.isFile()) { |
| 1247 | printErrorAndExit(new Error(), [ |
| 1248 | `Expected only files under directory "./${testDir}"`, |
| 1249 | `Found non-file at "./${schemaPath}"`, |
| 1250 | ]) |
| 1251 | } |
| 1252 | } |
| 1253 | } |
| 1254 | } |
| 1255 | } |
| 1256 | |
| 1257 | /** |
| 1258 | * Check that each test file has a corresponding schema. We only need to |
no test coverage detected