chore: add project management metadata and remaining repository files

This commit is contained in:
2026-02-22 21:43:43 -08:00
parent 64020a9069
commit 4ebabbe639
37 changed files with 7531 additions and 0 deletions

61
launcher/mpv.test.ts Normal file
View File

@@ -0,0 +1,61 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import net from 'node:net';
import { EventEmitter } from 'node:events';
import { waitForUnixSocketReady } from './mpv';
import * as mpvModule from './mpv';
function createTempSocketPath(): { dir: string; socketPath: string } {
const baseDir = path.join(process.cwd(), '.tmp', 'launcher-mpv-tests');
fs.mkdirSync(baseDir, { recursive: true });
const dir = fs.mkdtempSync(path.join(baseDir, 'case-'));
return { dir, socketPath: path.join(dir, 'mpv.sock') };
}
test('mpv module exposes only canonical socket readiness helper', () => {
assert.equal('waitForSocket' in mpvModule, false);
});
test('waitForUnixSocketReady returns false when socket never appears', async () => {
const { dir, socketPath } = createTempSocketPath();
try {
const ready = await waitForUnixSocketReady(socketPath, 120);
assert.equal(ready, false);
} finally {
fs.rmSync(dir, { recursive: true, force: true });
}
});
test('waitForUnixSocketReady returns false when path exists but is not socket', async () => {
const { dir, socketPath } = createTempSocketPath();
try {
fs.writeFileSync(socketPath, 'not-a-socket');
const ready = await waitForUnixSocketReady(socketPath, 200);
assert.equal(ready, false);
} finally {
fs.rmSync(dir, { recursive: true, force: true });
}
});
test('waitForUnixSocketReady returns true when socket becomes connectable before timeout', async () => {
const { dir, socketPath } = createTempSocketPath();
fs.writeFileSync(socketPath, '');
const originalCreateConnection = net.createConnection;
try {
net.createConnection = (() => {
const socket = new EventEmitter() as net.Socket;
socket.destroy = (() => socket) as net.Socket['destroy'];
socket.setTimeout = (() => socket) as net.Socket['setTimeout'];
setTimeout(() => socket.emit('connect'), 25);
return socket;
}) as typeof net.createConnection;
const ready = await waitForUnixSocketReady(socketPath, 400);
assert.equal(ready, true);
} finally {
net.createConnection = originalCreateConnection;
fs.rmSync(dir, { recursive: true, force: true });
}
});