The design language that makes your AI harness better at design.
JavaScript
test:rust-changed: select core and html for tests/oracle/vectors changes
Paul Bakaus3a40839eb07a
diff --git a/scripts/lib/rust-test-selection.mjs b/scripts/lib/rust-test-selection.mjsindex 580e7a1be..4de164b64 100644--- a/scripts/lib/rust-test-selection.mjs+++ b/scripts/lib/rust-test-selection.mjs@@ -5,6 +5,15 @@export const WORKSPACE_FILES = [/^Cargo\.(toml|lock)$/, /^rust-toolchain(\.toml)?$/, /^\.cargo\//];+// Readers the source search cannot see. crates/core/tests/vectors.rs and+// crates/html/tests/vectors.rs build the vectors path with chained calls,+// `repo.join("tests").join("oracle").join("vectors")`, so no single string+// in them names the directory. Add a row here for any other path a crate+// assembles piece by piece.+export const KNOWN_READERS = [+ { prefix: 'tests/oracle/vectors/', crates: ['impeccable-core', 'impeccable-html'] },+];+// Crates name what they read either relative to their manifest// (`include_str!("../../../skill/scripts/live-browser.js")`,// `CARGO_MANIFEST_DIR/../../tests/fixtures/concept-catalog`) or from the repo@@ -52,6 +61,9 @@ export function selectCrates({ changed, packages, searchCrates }) {if (name) pick(name, file);continue;}+ for (const { prefix, crates } of KNOWN_READERS) {+ if (file.startsWith(prefix)) for (const name of crates) pick(name, file);+ }for (const hit of searchCrates(searchTerms(file))) {const name = crateOf(hit);if (name) pick(name, file);diff --git a/tests/rust-test-selection.test.mjs b/tests/rust-test-selection.test.mjsindex ec60f41e3..0991d58a7 100644--- a/tests/rust-test-selection.test.mjs+++ b/tests/rust-test-selection.test.mjs@@ -1,6 +1,8 @@import { describe, it } from 'node:test';import assert from 'node:assert/strict';-import { searchTerms, selectCrates } from '../scripts/lib/rust-test-selection.mjs';+import { readdirSync, readFileSync } from 'node:fs';+import { join } from 'node:path';+import { KNOWN_READERS, searchTerms, selectCrates } from '../scripts/lib/rust-test-selection.mjs';// A small workspace shaped like the real one: core at the bottom, html on// core, cli on html, and a dev-dependency edge from tool to core.@@ -68,6 +70,29 @@ describe('rust-test-selection', () => {assert.deepEqual(select(['scripts/bundle-signing-keys.json'], sources).names, ['cli', 'html']);});+ it('selects the known readers of paths built with chained joins', () => {+ const packages = [+ { name: 'impeccable-core', dir: 'crates/core', deps: [] },+ { name: 'impeccable-html', dir: 'crates/html', deps: ['impeccable-core'] },+ { name: 'impeccable-comp', dir: 'crates/comp', deps: [] },+ ];+ const { selected } = selectCrates({+ changed: ['tests/oracle/vectors/calls/engines.static-html.css-cascade/cssPropToCamel.jsonl'],+ packages,+ searchCrates: () => [],+ });+ assert.deepEqual([...selected.keys()].sort(), ['impeccable-core', 'impeccable-html']);+ // Every row must name a workspace crate, or a rename silently drops it.+ const real = readdirSync('crates').flatMap((dir) => {+ try {+ return [/^name\s*=\s*"([^"]+)"/m.exec(readFileSync(join('crates', dir, 'Cargo.toml'), 'utf8'))[1]];+ } catch {+ return [];+ }+ });+ for (const row of KNOWN_READERS) for (const name of row.crates) assert.ok(real.includes(name), name);+ });+it('builds terms for the file and its directories', () => {assert.deepEqual(searchTerms('package.json'), ['../package.json']);assert.deepEqual(searchTerms('a/b/c.txt'), ['../a/b/c.txt', '"a/b/c.txt', '../a/b"', '../a/b/"', '"a/b"', '"a/b/"', '../a"', '../a/"']);