clank-together/test/affected.test.js
Saty a9eb651688 Compile only the includers a header change can affect
A verification of a header template compiled every includer (705 for
stpl.h) and a merge every includer of every submitted header (up to 1199
per header), even when the header only differed in line endings; one
such job took up to an hour and held up every other batch. Now:
- merge: headers unchanged from main are skipped; for changed ones, the
  includers whose source mentions a name the change touched (identifiers
  on changed lines, the enclosing class/struct), all of them only when
  that is more than 300;
- verification: the includers that mention the template arguments of
  the annotation (or the class), at most 16.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 03:40:19 +02:00

29 lines
1.1 KiB
JavaScript

import { test } from 'node:test';
import assert from 'node:assert/strict';
import { changedNames } from '../src/server/affected.js';
test('a header change names what it touched, not parameters, paths, strings or hex', () => {
const before = [
'#include "Engine/Source/Base/Types.h"',
'struct Foo {',
' int a;',
'};',
'template <class T> struct Bar { T x; };',
'bool GetRect(CRect& rect);',
'#define K 1',
].join('\n');
const after = [
'#include "Engine/Source/Base/Other.h"',
'struct Foo {',
' int a;',
' int m_new; // 0x16 the new field',
'};',
'template <class T> struct Bar { T x; char pad[0x16]; };',
'bool GetRect(CRect& rect, int count);',
'#define K "d:\\BuildServer\\WoW"',
].join('\n');
const names = new Set(changedNames(before, after));
for (const n of ['Foo', 'm_new', 'Bar', 'GetRect', 'CRect']) assert.ok(names.has(n), `expected ${n}`);
for (const n of ['rect', 'count', 'Engine', 'Other', 'x16', 'BuildServer', 'WoW', 'T', 'the']) assert.ok(!names.has(n), `did not expect ${n}`);
assert.deepEqual(changedNames('a\r\nb\r\n', 'a\nb\n'), [], 'line endings alone change nothing');
});