fix: keep local home paths and addresses out of the test fixtures

Three test-only spots had baked in the machine this repository was developed
on, and the repository is publicly readable, so they shipped that machine's
shape to anyone who cloned it:

  * the end-to-end embedding backend was pinned to a private LAN address;
    it is now read from DSH_SLOPO_E2E_API_BASE, defaulting to Ollama's own
    loopback address, so the machine running the suite supplies its own;
  * the real-slopo test resolved discovery from a hardcoded root home, which
    meant it could only ever run for one user — it resolves from the running
    user's home now, which is also the fix for everyone else;
  * the harness-slot contract tests read the global npm tree by absolute
    path; they go through this repository's own node_modules symlink, which
    is already relative to the checkout.

No user-facing behaviour changes: the test files are not in the published
package, and the default configuration was already free of machine-specific
values — every address, path and key defaults to empty and is resolved per
user at runtime.
This commit is contained in:
dsh-slopo agent committed 2026-09-26 07:05:33 +01:00
1 parent 1b2ab3613f
commit 6beb4c0d39
3 files changed
+27 -7

No files matched your search

+9 -2
View File
@@ -31,11 +31,18 @@ import assert from 'node:assert/strict'
import { existsSync, readFileSync } from 'node:fs'
import { join } from 'node:path'
import { test } from 'node:test'
import { fileURLToPath } from 'node:url'
const SOURCE = readFileSync(new URL('../client/client.js', import.meta.url), 'utf8')
/** Where a global dsh installation keeps its packages, if there is one. */
const DSH_PACKAGES = '/usr/local/lib/node_modules/@deepseek-ai/dsh/node_modules/@deepseek-ai'
/**
* The installed harness's packages, reached through this repository's own
* `node_modules/@deepseek-ai` symlink rather than a committed absolute path —
* the link is what makes the `@deepseek-ai/*` imports resolve during tests in
* the first place, so it is the one address that is already relative to the
* checkout.
*/
const DSH_PACKAGES = fileURLToPath(new URL('../node_modules/@deepseek-ai/', import.meta.url))
// ---------------------------------------------------------------------------
// The two doubles
+5 -1
View File
@@ -477,7 +477,11 @@ test(
sourceDir: join(repo, 'src'),
embeddingModel: 'ollama/unclemusclez/jina-embeddings-v2-base-code:latest',
embeddingDimensions: 768,
embeddingApiBase: 'http://10.50.1.2:11434',
// Where the real embedding backend lives is a property of the machine
// running the E2E suite, not of this repository, so it is read from the
// environment rather than committed. The default is Ollama's own
// loopback address.
embeddingApiBase: process.env.DSH_SLOPO_E2E_API_BASE ?? 'http://127.0.0.1:11434',
})
const tool = state.tools.get('slopo')
+13 -4
View File
@@ -17,7 +17,7 @@ import {
slopoCandidates,
uvInstallArgs,
} from '../lib/slopo.js'
import { managedSlopoPath, resolveDshHome, workspaceKey, workspaceStateDir } from '../lib/paths.js'
import { managedSlopoPath, resolveDshHome, userLocalSlopoPath, workspaceKey, workspaceStateDir } from '../lib/paths.js'
test('findSlopo prefers the managed install over PATH', () => {
const home = '/dsh'
@@ -152,8 +152,16 @@ test('workspace state lives under the harness home, not next to the code', () =>
assert.match(workspaceStateDir('/dsh', '/repo'), /^\/dsh\/dsh-slopo\/workspaces\/repo-[0-9a-f]{8}$/)
})
test('the generated config is accepted by the real slopo', { skip: !existsSync(managedSlopoPath('/root/.dsh')) && !existsSync('/root/.local/bin/slopo') }, () => {
const binary = findSlopo('/root/.dsh')
test(
'the generated config is accepted by the real slopo',
{
// Discovery resolves from the RUNNING user's home, not from a committed
// absolute one: a hardcoded home directory only ever matched one machine,
// and it published that machine's layout to everyone else.
skip: !existsSync(managedSlopoPath(resolveDshHome())) && !existsSync(userLocalSlopoPath()),
},
() => {
const binary = findSlopo(resolveDshHome())
assert.ok(binary, 'expected a slopo binary for this test')
const dir = mkdtempSync(join(tmpdir(), 'dsh-slopo-conf-'))
const configPath = join(dir, 'slopo.conf.yaml')
@@ -174,4 +182,5 @@ test('the generated config is accepted by the real slopo', { skip: !existsSync(m
assert.match(out, /embedding_model: ollama\/example:latest/)
assert.match(out, /embedding_dimensions: 768/)
assert.match(out, /api_base: http:\/\/127\.0\.0\.1:11434/)
})
},
)