run-oxlint.spec.ts 1.0 KB

12345678910111213141516171819202122232425262728
  1. import { describe, expect, it } from 'vitest'
  2. import { resolveOxlintInvocation } from './run-oxlint.ts'
  3. describe('Oxlint invocation', () => {
  4. it('preserves the ordinary default invocation', () => {
  5. expect(resolveOxlintInvocation(['.'], { PATH: '/bin' })).toEqual({
  6. args: ['.'],
  7. env: { PATH: '/bin' },
  8. })
  9. })
  10. it('bounds both worker pools from one setting', () => {
  11. expect(resolveOxlintInvocation(['.', '--fix'], { DSH_OXLINT_THREADS: '4', GOMAXPROCS: '12' })).toEqual({
  12. args: ['.', '--fix', '--threads=4'],
  13. env: { DSH_OXLINT_THREADS: '4', GOMAXPROCS: '4' },
  14. })
  15. })
  16. it.each(['0', '-1', '1.5', 'auto'])('rejects invalid worker bound %s', (value) => {
  17. expect(() => resolveOxlintInvocation(['.'], { DSH_OXLINT_THREADS: value }))
  18. .toThrow('DSH_OXLINT_THREADS must be a positive integer')
  19. })
  20. it('rejects a competing direct worker bound', () => {
  21. expect(() => resolveOxlintInvocation(['.', '--threads=2'], { DSH_OXLINT_THREADS: '4' }))
  22. .toThrow('use DSH_OXLINT_THREADS instead')
  23. })
  24. })