fix: keep local home paths and addresses out of the test fixtures [skip release]
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 and the published package never contained
the test files, so this push publishes nothing. 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.
[skip release]
This commit is contained in:
1 parent
1b2ab3613f
commit
cf3e797849
3 files changed
+47
-27
No files matched your search
+9
-2
@@ -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
@@ -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')
|
||||
|
||||
|
||||
+33
-24
@@ -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,26 +152,35 @@ 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')
|
||||
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')
|
||||
writeFileSync(
|
||||
configPath,
|
||||
renderSlopoConfig({
|
||||
source_dir: dir,
|
||||
db_file: join(dir, 'slopo.db'),
|
||||
ignore_file: join(dir, 'slopo.ignore.txt'),
|
||||
agent_log_file: join(dir, 'slopo.agent.log'),
|
||||
embedding_model: 'ollama/example:latest',
|
||||
embedding_dimensions: 768,
|
||||
embedding_params: { api_base: 'http://127.0.0.1:11434' },
|
||||
source_dir_exclude: ['**/test/**'],
|
||||
}),
|
||||
)
|
||||
const out = execFileSync(binary, ['--config', configPath, 'show-config'], { encoding: 'utf8' })
|
||||
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/)
|
||||
})
|
||||
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')
|
||||
writeFileSync(
|
||||
configPath,
|
||||
renderSlopoConfig({
|
||||
source_dir: dir,
|
||||
db_file: join(dir, 'slopo.db'),
|
||||
ignore_file: join(dir, 'slopo.ignore.txt'),
|
||||
agent_log_file: join(dir, 'slopo.agent.log'),
|
||||
embedding_model: 'ollama/example:latest',
|
||||
embedding_dimensions: 768,
|
||||
embedding_params: { api_base: 'http://127.0.0.1:11434' },
|
||||
source_dir_exclude: ['**/test/**'],
|
||||
}),
|
||||
)
|
||||
const out = execFileSync(binary, ['--config', configPath, 'show-config'], { encoding: 'utf8' })
|
||||
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/)
|
||||
},
|
||||
)
|
||||
Reference in new issue
Block a user