Files
orca/config/scripts/test-runtime/execution-policy/vitest-changed-precheck.test.mjs
T
Neil 9bd6272fdf refactor(tooling): organize build, CI, and test owners (#38130)
* refactor(tooling): organize test runtime and maintenance owners

* test(tooling): preserve relocated runtime fixture dependency edges

* refactor(tooling): preserve xterm routing owner checks

* ci(tooling): include routing owner in sparse checkout

* test(tooling): preserve copied workflow dependency closures

* fix(tooling): normalize hashed JSON assets in release parity

* fix(tooling): distinguish asset aliases from literal references

* fix(tooling): frame normalized asset reference payloads

* fix(tooling): normalize decoded JSON asset references

* refactor(tooling): organize build, CI and release owners

* fix(tooling): align moved generator and workflow path contracts

* fix(tooling): update generated plugin bundle owner banners

* test(tooling): create relocated mobile verifier fixture directories

* test(tooling): copy headless detector dependency closure

* test(tooling): align native batch policy fixtures with owner path

* fix(tooling): link moved reliability command to historical evidence

* fix(tooling): preserve nested sandbox owners and canonical guide source

* fix(tooling): target release version owners in checkout fixture
2026-11-04 21:08:19 -08:00

43 lines
1.3 KiB
JavaScript

import { describe, expect, it, vi } from 'vitest'
import { hasNoChangedFiles } from './vitest-changed-precheck.mjs'
const clean = () => vi.fn(async () => ({ code: 0, stdout: '' }))
describe('hasNoChangedFiles', () => {
it('also checks commits since the ref', async () => {
const runProcess = clean()
await expect(
hasNoChangedFiles(['run', '--changed=origin/main'], '/repo', runProcess)
).resolves.toBe(true)
expect(runProcess.mock.calls.map(([spec]) => spec.args)).toContainEqual([
'diff',
'--name-only',
'-z',
'origin/main...HEAD'
])
})
it('starts Vitest when Git reports a file or cannot answer', async () => {
for (const result of [
{ code: 0, stdout: '?? src/a.ts\0' },
{ code: 128, stdout: '' }
]) {
const runProcess = vi.fn(async () => result)
await expect(hasNoChangedFiles(['run', '--changed'], '/repo', runProcess)).resolves.toBe(
false
)
}
})
it.each([
[['run', 'src/a']],
[['run', '--changed', 'src/a']],
[['run', '--changed', '--watch']],
[['related', '--changed']]
])('leaves %j to Vitest', async (args) => {
const runProcess = clean()
await expect(hasNoChangedFiles(args, '/repo', runProcess)).resolves.toBe(false)
expect(runProcess).not.toHaveBeenCalled()
})
})