Files
orca/config/scripts/static-analysis/ratchets/react-compiler/check-react-compiler-compat-ratchet.test.mjs
T
Brennan Benson 7777f352d8 build: fail the React Compiler ratchet on stale uncompiled-list paths (#40198)
* build: fail the React Compiler ratchet on stale uncompiled-list paths

- A listed path that no longer names a renderer source (a rename or split) fails the ratchet, so the file can't silently start compiling.
- The build and the ratchet read the lists through one parser that drops trailing notes, resolved from the repo root rather than the current directory.

* build: resolve uncompiled lists from import.meta.url and check listed paths on disk

- electron-vite's config bundle rewrites import.meta.url per file but not import.meta.dirname, so the repo root came out wrong and desktop builds failed with ENOENT.
- A listed path is stale only if no renderer file exists there; the scan's test-name filter no longer flags shipped files like notification-test-delivery.ts.

* build: require uncompiled-list entries to name the exact file the build matches

A ../ segment, a directory or a different letter case passed the existence check, but the build's exclusion matches only the exact path, so the file still compiled.

* build: reject backslashes in uncompiled-list entries

On Windows path.join turns a backslash into a separator, so the entry passed the check while the build's forward-slash match missed it.
2026-11-09 17:53:19 -08:00

40 lines
1.3 KiB
JavaScript

import { describe, expect, it } from 'vitest'
import { parseListedFiles } from '../../../../build-plugins/react-compiler-uncompiled-files.mjs'
import { findStaleUncompiledFiles } from './check-react-compiler-compat-ratchet.mjs'
describe('uncompiled file list', () => {
it('reads paths from list, count and hazard lines, dropping notes', () => {
const text = [
'# header',
'src/renderer/src/a.tsx',
'src/renderer/src/b.tsx # why it stays uncompiled',
'2 src/renderer/src/c.ts',
'1 src/renderer/src/d.ts#useD:store-read-in-memo-block',
''
].join('\n')
expect(parseListedFiles(text)).toEqual([
'src/renderer/src/a.tsx',
'src/renderer/src/b.tsx',
'src/renderer/src/c.ts',
'src/renderer/src/d.ts'
])
})
it('reports listed paths that no longer name a renderer file', () => {
const files = new Set([
'src/renderer/src/kept.tsx',
'src/renderer/src/notification-test-delivery.ts'
])
expect(
findStaleUncompiledFiles(
new Set([
'src/renderer/src/kept.tsx',
'src/renderer/src/notification-test-delivery.ts',
'src/renderer/src/renamed.tsx'
]),
(rel) => files.has(rel)
)
).toEqual(['src/renderer/src/renamed.tsx'])
})
})