mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-08-29 04:26:38 +00:00
test(webworker): keep dependency coverage generic
This commit is contained in:
@@ -37,9 +37,7 @@ const repoRoot = fileURLToPath(new URL('../../../../', import.meta.url))
|
|||||||
const SUBJECT = '@deepseek-ai/dsh-timeout'
|
const SUBJECT = '@deepseek-ai/dsh-timeout'
|
||||||
const LANDLOCK = '@deepseek-ai/node-addon-landlock-run'
|
const LANDLOCK = '@deepseek-ai/node-addon-landlock-run'
|
||||||
const PLUGIN_INVENTORY = '@deepseek-ai/dsh-plugin-package-inventory-deepseek'
|
const PLUGIN_INVENTORY = '@deepseek-ai/dsh-plugin-package-inventory-deepseek'
|
||||||
const TERMINAL_BASH = '@deepseek-ai/dsh-terminal-bash'
|
|
||||||
const WEB_SERVER = '@deepseek-ai/dsh-host-webserver'
|
const WEB_SERVER = '@deepseek-ai/dsh-host-webserver'
|
||||||
const XTERM_HEADLESS = '@xterm/headless'
|
|
||||||
|
|
||||||
const workspaces = indexWorkspacePackages(repoRoot)
|
const workspaces = indexWorkspacePackages(repoRoot)
|
||||||
|
|
||||||
@@ -116,15 +114,6 @@ const packedWebServer = (): ReturnType<typeof packVfsImage> => webServerMemo ??=
|
|||||||
entries: [],
|
entries: [],
|
||||||
})
|
})
|
||||||
|
|
||||||
let terminalBashMemo: ReturnType<typeof packVfsImage> | undefined
|
|
||||||
const packedTerminalBash = (): ReturnType<typeof packVfsImage> => terminalBashMemo ??= packVfsImage({
|
|
||||||
config: `- id: subject\n name: '${TERMINAL_BASH}'\n`,
|
|
||||||
profile: 'terminal-bash-dependency-check',
|
|
||||||
workspaces,
|
|
||||||
resolveFrom: repoRoot,
|
|
||||||
entries: [],
|
|
||||||
})
|
|
||||||
|
|
||||||
/** The image's archive, inflated once: mounting reads the tar, not the gzip member. */
|
/** The image's archive, inflated once: mounting reads the tar, not the gzip member. */
|
||||||
let archiveMemo: Uint8Array | undefined
|
let archiveMemo: Uint8Array | undefined
|
||||||
const archive = async (): Promise<Uint8Array> =>
|
const archive = async (): Promise<Uint8Array> =>
|
||||||
@@ -229,27 +218,6 @@ const archive = async (): Promise<Uint8Array> =>
|
|||||||
expect(typeof webserver.WebServer).toBe('function')
|
expect(typeof webserver.WebServer).toBe('function')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('loads a third-party dependency requested through createRequire', async () => {
|
|
||||||
const result = packedTerminalBash()
|
|
||||||
expect(result.missing).toEqual([])
|
|
||||||
expect(result.packages.get(XTERM_HEADLESS)).toBeGreaterThan(0)
|
|
||||||
expect(Object.hasOwn(result.files, `node_modules/${XTERM_HEADLESS}/lib-headless/xterm-headless.js`)).toBe(true)
|
|
||||||
|
|
||||||
const vfs = loadVfsImage(await inflateImage(result.image, 'the packed terminal backend'), DEFAULT_ROOT)
|
|
||||||
const loader = new WorkerModuleLoader({
|
|
||||||
vfs,
|
|
||||||
root: DEFAULT_ROOT,
|
|
||||||
staticModules: createNodeBuiltins(),
|
|
||||||
staticModulePrefixes: REPLACED_PREFIXES,
|
|
||||||
})
|
|
||||||
setActiveVfs(vfs)
|
|
||||||
setActiveModuleLoader(loader)
|
|
||||||
const terminal = loader.requireFrom(`${DEFAULT_ROOT}/workspace`)(TERMINAL_BASH) as {
|
|
||||||
BashTerminalBackend?: unknown
|
|
||||||
}
|
|
||||||
expect(typeof terminal.BashTerminalBackend).toBe('function')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('runs the unchanged Landlock entry package over the Worker platform executable', async () => {
|
it('runs the unchanged Landlock entry package over the Worker platform executable', async () => {
|
||||||
const result = packedLandlock()
|
const result = packedLandlock()
|
||||||
expect(workspaces.has(LANDLOCK)).toBe(true)
|
expect(workspaces.has(LANDLOCK)).toBe(true)
|
||||||
|
|||||||
@@ -147,9 +147,9 @@ check(
|
|||||||
{
|
{
|
||||||
const direct = lowerModuleSource({
|
const direct = lowerModuleSource({
|
||||||
filename: 'node_modules/p/direct.js',
|
filename: 'node_modules/p/direct.js',
|
||||||
source: "import { createRequire } from 'node:module'\ncreateRequire(import.meta.url)('@xterm/headless')\n",
|
source: "import { createRequire } from 'node:module'\ncreateRequire(import.meta.url)('external-package')\n",
|
||||||
})
|
})
|
||||||
check('literal createRequire call is a module request', direct.moduleRequests, ['node:module', '@xterm/headless'])
|
check('literal createRequire call is a module request', direct.moduleRequests, ['node:module', 'external-package'])
|
||||||
|
|
||||||
const assigned = lowerModuleSource({
|
const assigned = lowerModuleSource({
|
||||||
filename: 'node_modules/p/assigned.js',
|
filename: 'node_modules/p/assigned.js',
|
||||||
|
|||||||
Reference in New Issue
Block a user