Files
bare-operating-system/packages/bare-os-coreutils/test/expand-tab-stops.test.mjs
T
Raven Scott c64910d72e Implement the 20-track POSIX + P2P roadmap: booter, protocol, coreutils, docs,
and seeder/kernel parity.

Booter / ctx (1.44.0)
- bareOsReadPearRuntimeSnapshotJson; hrpc stock routes documented (kernel.*,
  vfs.readText, bare_os.echo, bare_os.disk_os_hints).
- Peer admission: BARE_OS_DHT_ADDRESS_CLASS_ALLOWLIST + meta.dhtAddressClass;
  shouldAttemptPeer(peerKey, meta).
- Optional BARE_OS_VFS_WARM_CACHE_INVALIDATE_ON_APPEND on system drive cores.
- maybeMergeBareFromDrive: path dedupe + early exit when manifest keys satisfied.
- identity-account: zero UTF-8 passphrase buffer after PBKDF2 (string path).

Shell / utilities
- BARE_OS_SHELL_ERREXIT and set -e / set +e; tests in bare-os-booter/test.js.
- expand: comma-separated POSIX-style tab stops; man page + coreutils tests.

Tooling / docs
- kernel-microbench vfs: warmReplicationPathClassify sketch.
- holepunch-drift-repos suggestedCriticalRepos; sync-holepunch-clones report.
- scripts/README: pretest maintainer runbook; handbook/12 P2P vs POSIX.
- KERNEL_CONTRACT, environment appendix, PLACEHOLDER_BASELINE (multisig gate),
  compatibility matrix, posix artifacts, syscalls.example.json, seeder sync.

Requires: npm run pretest && npm test (already green in session).
2026-04-05 01:06:59 -04:00

60 lines
1.5 KiB
JavaScript

/**
* expand -t comma-separated tab stops
*/
import { readFile } from 'node:fs/promises'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import test from 'brittle'
import b4a from 'b4a'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor
async function loadBin(name) {
const runtime = await readFile(
path.join(__dirname, '../lib/runtime.js'),
'utf8'
)
const body = await readFile(
path.join(__dirname, `../src/${name}.js`),
'utf8'
)
return new AsyncFunction(
'ctx',
'argv',
`${runtime}\n${body}\nif (typeof run === 'function') return await run(ctx, argv)\n`
)
}
function createCtx() {
const logs = []
return {
b4a,
exitCode: 0,
vfs: { async stat() { return null } },
console: {
log: (m) => logs.push(String(m)),
error: (m) => logs.push(String(m))
},
_logs: logs
}
}
test('expand -t 1,5 maps two leading tabs to five spaces before text', async (t) => {
const run = await loadBin('expand')
const ctx = createCtx()
ctx.shellStdin = '\t\tfoo'
await run(ctx, ['expand', '-t', '1,5'])
t.is(ctx.exitCode, 0)
t.is(ctx._logs.join('\n'), ' foo')
})
test('expand -t 8 uniform matches single-stop width', async (t) => {
const run = await loadBin('expand')
const ctx = createCtx()
ctx.shellStdin = '\tx'
await run(ctx, ['expand', '-t', '8'])
t.is(ctx._logs.join('\n'), ' x')
})