diff --git a/crates/celox-sv-analyzer/src/system_functions.rs b/crates/celox-sv-analyzer/src/system_functions.rs index 4f675690537..11bdd0b0a9e 100644 --- a/crates/celox-sv-analyzer/src/system_functions.rs +++ b/crates/celox-sv-analyzer/src/system_functions.rs @@ -1,5 +1,6 @@ -//! The system tasks and functions Celox knows (IEEE 1800-2023 clauses 20 and -//! 21), and where the SystemVerilog frontend supports each one. +//! The system tasks and functions Celox knows (those IEEE 1800-2023 defines, +//! mostly in clauses 20 and 21, and the optional ones of its Annex D), and +//! where the SystemVerilog frontend supports each one. //! //! The analyzer checks each call against this catalog where it converts the //! call, with the context it converts it in ([`CallSite`]), so a name the @@ -49,7 +50,7 @@ pub enum SystemFunction { Onehot0, /// `$isunknown` (20.9). Isunknown, - /// `$urandom` (18.13.1, 20.15.2). + /// `$urandom` (18.13.1). Urandom, } @@ -416,7 +417,8 @@ const fn function(function: SystemFunction, min_args: usize, max_args: Option { + const repository = mkdtempSync(join(tmpdir(), "celox-ci-changes-")); + t.after(() => rmSync(repository, { recursive: true, force: true })); + const git = (...args) => + execFileSync("git", args, { cwd: repository, encoding: "utf8" }).trim(); + const commit = (path) => { + writeFileSync(join(repository, path), `${path}\n`); + git("add", path); + git("commit", "--quiet", "-m", path); + return git("rev-parse", "HEAD"); + }; + git("init", "--quiet"); + git("config", "user.name", "test"); + git("config", "user.email", "test@example.com"); + git("config", "commit.gpgsign", "false"); + const fork = commit("README.md"); + git("checkout", "--quiet", "-b", "pr"); + const head = commit("CONTRIBUTING.md"); + git("checkout", "--quiet", fork); + const base = commit("unknown-base-change.xyz"); + assert.deepEqual(changedFilesBetween(base, head, repository), ["CONTRIBUTING.md"]); + assert.deepEqual( + runClassifier(base, head, { GITHUB_EVENT_NAME: "pull_request" }, repository), + { ...none, docs: true, heliodor_arm64: false, release: false }, + ); +}); diff --git a/scripts/ci-rust-scope.mjs b/scripts/ci-rust-scope.mjs index f81bab85071..75a18ea9ed0 100644 --- a/scripts/ci-rust-scope.mjs +++ b/scripts/ci-rust-scope.mjs @@ -206,12 +206,17 @@ export function rustTestScope(files, packages) { }; } -/** Changed files between two commits, or null when they cannot be compared. */ -export function changedFilesBetween(base, head) { +/** + * Files changed on head since it forked from base, or null when they cannot be + * compared. A PR's base.sha is the current base tip, so a two-point diff would + * also report base changes that the PR branch has not merged yet. + */ +export function changedFilesBetween(base, head, cwd = undefined) { const sha = /^[0-9a-f]{40,64}$/i; if (!sha.test(base) || !sha.test(head) || /^0+$/.test(base)) return null; try { - return execFileSync("git", ["diff", "--name-only", "-z", base, head], { + return execFileSync("git", ["diff", "--name-only", "-z", `${base}...${head}`], { + cwd, encoding: "utf8", }) .split("\0")