mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-09-07 04:10:42 +00:00
A developer's Clash and a CI runner's squid both export HTTP_PROXY and its siblings. Now that the harness honors them, an ambient value decides test outcomes: this PR has already recorded a proxy's 502 page as a snapshot's expected output, and let a runner's own export stand in for "what the user exported" in an assertion about inherited names. A Vitest setup file clears the proxy names before any suite runs, wired into every configuration that declares a setup. Real-API e2e is cleared too: before proxy support existed every request connected directly and that suite passed, so direct is the environment it is known to work in. `NODE_USE_ENV_PROXY` cannot be cleared this way — Node samples the proxy environment at process start — and the module says so. A proxy application never exports it, and the eight names one does export are fully handled: with all of them set, the affected suites pass. The wiring is what regresses, so that is what the test pins. Configurations are discovered rather than listed, because the web suites carry no setup today and a hand-written list would let one of them gain a setup without gaining this one. `plugin.spec.ts` kept its own copy of the eight names to guard against the machine; it never sets a proxy variable itself, so the setup replaces that entirely. `install.spec.ts` had one assertion waiting on a DNS miss with no deadline, which timed out once under load.
44 lines
2.1 KiB
TypeScript
44 lines
2.1 KiB
TypeScript
import { readFileSync } from 'node:fs'
|
|
import { describe, expect, it } from 'vitest'
|
|
import { PROXY_ENV_NAMES } from '../packages/net/http-proxy/src/policy.ts'
|
|
import { clearAmbientProxyEnv, TEST_PROXY_SETUP_FILE, vitestConfigFiles } from './test-proxy-environment.ts'
|
|
|
|
describe('ambient proxy environment', () => {
|
|
it('clears every name the policy resolver reads, in both casings', () => {
|
|
const env: NodeJS.ProcessEnv = {
|
|
HTTP_PROXY: 'http://p:1', http_proxy: 'http://p:1',
|
|
HTTPS_PROXY: 'http://p:1', https_proxy: 'http://p:1',
|
|
ALL_PROXY: 'http://p:1', all_proxy: 'http://p:1',
|
|
NO_PROXY: 'example.com', no_proxy: 'example.com',
|
|
NODE_USE_ENV_PROXY: '1',
|
|
PATH: '/usr/bin',
|
|
}
|
|
expect(clearAmbientProxyEnv(env)).toHaveLength(PROXY_ENV_NAMES.length + 1)
|
|
expect(env).toEqual({ PATH: '/usr/bin' })
|
|
})
|
|
|
|
it('reports only the names that were set, and touches nothing else', () => {
|
|
const env: NodeJS.ProcessEnv = { all_proxy: 'http://p:1', HOME: '/home/me' }
|
|
expect(clearAmbientProxyEnv(env)).toEqual(['all_proxy'])
|
|
expect(env).toEqual({ HOME: '/home/me' })
|
|
})
|
|
|
|
// A runtime assertion that this process is clear would pass either way: importing the module
|
|
// above already ran it. What can actually regress is the wiring — a new Vitest project, or a
|
|
// config that lists only the invariant host — so that is what this pins.
|
|
const declared = vitestConfigFiles()
|
|
.map(config => ({ config, slots: readFileSync(config, 'utf8').match(/setupFiles: \[[^\]]*\]/g) ?? [] }))
|
|
.filter(entry => entry.slots.length > 0)
|
|
|
|
it('finds the configurations that declare a setup at all', () => {
|
|
// Guards the discovery itself: a glob that stopped matching would make every case below vacuous.
|
|
expect(declared.map(entry => entry.config)).toEqual([
|
|
'vitest.config.ts', 'vitest.e2e.config.ts', 'vitest.expected.config.ts', 'vitest.snapshot.config.ts',
|
|
])
|
|
})
|
|
|
|
it.each(declared)('$config runs the setup in every setupFiles it declares', ({ slots }) => {
|
|
for (const slot of slots) expect(slot).toContain(TEST_PROXY_SETUP_FILE)
|
|
})
|
|
})
|