test: Add detailed METAR decode statistics to test function

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2026-02-14 16:07:59 -07:00
parent 2101b6b74e
commit f49f3f1aed
+26 -1
View File
@@ -536,18 +536,43 @@
function testAllMetars() { function testAllMetars() {
console.log(`--- Starting test of ${metars.length} METARs ---`); console.log(`--- Starting test of ${metars.length} METARs ---`);
let failed = 0; let failed = 0;
let withUnknowns = 0;
const originalConsoleLog = console.log;
metars.forEach(metarString => { metars.forEach(metarString => {
const tempLogs = [];
console.log = (...args) => {
tempLogs.push(args.join(' '));
};
try { try {
const sections = generateMetarSections(metarString); const sections = generateMetarSections(metarString);
if (sections.length === 0 && metarString.length > 0) { if (sections.length === 0 && metarString.length > 0) {
throw new Error("Parser produced no sections"); throw new Error("Parser produced no sections");
} }
const hasUnknowns = tempLogs.some(msg => msg.includes('Unknown') || msg.includes('Other remark'));
if (hasUnknowns) {
withUnknowns++;
originalConsoleLog(`METAR with decoding issues: ${metarString}`);
tempLogs.forEach(msg => originalConsoleLog(` -> ${msg}`));
}
} catch (e) { } catch (e) {
console.error("Failed to parse:", metarString, e); console.error("Failed to parse:", metarString, e);
failed++; failed++;
} }
}); });
console.log(`--- Test finished, ${failed} failures ---`);
console.log = originalConsoleLog;
const total = metars.length;
const clean = total - failed - withUnknowns;
console.log(`--- Test finished ---`);
console.log(`Total METARs: ${total}`);
console.log(`Clean decodes: ${clean} (${(clean/total*100).toFixed(1)}%)`);
console.log(`Decodes with issues: ${withUnknowns} (${(withUnknowns/total*100).toFixed(1)}%)`);
console.log(`Failed to parse: ${failed} (${(failed/total*100).toFixed(1)}%)`);
} }
testAllBtn.addEventListener('click', testAllMetars); testAllBtn.addEventListener('click', testAllMetars);