mirror of
https://github.com/affaan-m/ECC.git
synced 2026-09-29 04:55:12 +02:00
test(locale-agents): fail on a locale doc whose agent no longer exists
Review feedback on #2879: a locale file with no counterpart in `agents/` was skipped, so every other case here silently passed over it. Retiring an agent would leave its seven translations behind with nothing to compare against and nothing to report it. Collect those files while building the list and assert the collection is empty. Zero today across 199 locale docs, so this changes no current result; planting one orphan takes the file to `Passed: 6, Failed: 1` and exit 1.
This commit is contained in:
@@ -82,23 +82,34 @@ function main() {
|
||||
if (fields) canonical.set(file, fields);
|
||||
}
|
||||
|
||||
const rel = filePath => path.relative(REPO_ROOT, filePath).split(path.sep).join('/');
|
||||
|
||||
const localeFiles = [];
|
||||
const orphans = [];
|
||||
for (const dir of localeAgentDirs()) {
|
||||
for (const file of fs.readdirSync(dir).filter(f => f.endsWith('.md'))) {
|
||||
if (canonical.has(file)) {
|
||||
localeFiles.push({ file, filePath: path.join(dir, file) });
|
||||
}
|
||||
const filePath = path.join(dir, file);
|
||||
if (canonical.has(file)) localeFiles.push({ file, filePath });
|
||||
else orphans.push(rel(filePath));
|
||||
}
|
||||
}
|
||||
|
||||
const rel = filePath => path.relative(REPO_ROOT, filePath).split(path.sep).join('/');
|
||||
|
||||
const tests = [
|
||||
['there are locale agent docs to check', () => {
|
||||
assert.ok(canonical.size > 0, 'no canonical agents found');
|
||||
assert.ok(localeFiles.length > 0, 'no locale agent docs found');
|
||||
}],
|
||||
|
||||
['no locale agent doc outlives the agent it documents', () => {
|
||||
// Without this, retiring an agent leaves its translations behind and every
|
||||
// other case here silently skips them — they have nothing to compare to.
|
||||
assert.deepStrictEqual(
|
||||
orphans,
|
||||
[],
|
||||
`locale docs with no agent in agents/:\n ${orphans.join('\n ')}`
|
||||
);
|
||||
}],
|
||||
|
||||
['every locale agent doc has parseable frontmatter', () => {
|
||||
const bad = localeFiles
|
||||
.filter(({ filePath }) => frontmatter(filePath) === null)
|
||||
|
||||
Reference in New Issue
Block a user