Fix Windows mpv logging and add log export (#88)

This commit is contained in:
2026-05-26 00:31:38 -07:00
committed by GitHub
parent 43ebc7d371
commit 11c196821d
150 changed files with 2748 additions and 582 deletions
+32 -2
View File
@@ -124,6 +124,29 @@ test('short version flag prints installed app version without requiring app bina
});
});
test('logs export writes sanitized archive without requiring app binary', () => {
withTempDir((root) => {
const homeDir = path.join(root, 'home');
const xdgConfigHome = path.join(root, 'xdg');
const logsDir =
process.platform === 'win32'
? path.join(xdgConfigHome, 'SubMiner', 'logs')
: path.join(homeDir, '.config', 'SubMiner', 'logs');
fs.mkdirSync(logsDir, { recursive: true });
fs.writeFileSync(path.join(logsDir, 'app-2026-W21.log'), `/home/kyle/video.mkv\n`, 'utf8');
const result = runLauncher(['logs', '-e'], makeTestEnv(homeDir, xdgConfigHome));
assert.equal(result.status, 0, `stdout:\n${result.stdout}\nstderr:\n${result.stderr}`);
const zipPath = result.stdout.trim();
assert.match(zipPath, /subminer-logs-.+\.zip$/);
assert.equal(fs.existsSync(zipPath), true);
const archive = fs.readFileSync(zipPath);
assert.equal(archive.includes(Buffer.from('/home/kyle')), false);
assert.equal(archive.includes(Buffer.from('/home/<user>')), true);
});
});
test('config path prefers jsonc over json for same directory', () => {
withTempDir((root) => {
const homeDir = path.join(root, 'home');
@@ -395,7 +418,7 @@ ${bunBinary} -e "const net=require('node:net'); const fs=require('node:fs'); con
});
});
test('launcher forwards non-info log level into mpv plugin script opts', { timeout: 15000 }, () => {
test('launcher forwards non-info log level into mpv logging args', { timeout: 15000 }, () => {
withTempDir((root) => {
const homeDir = path.join(root, 'home');
const xdgConfigHome = path.join(root, 'xdg');
@@ -430,6 +453,11 @@ test('launcher forwards non-info log level into mpv plugin script opts', { timeo
autoStartSubMiner: true,
pauseUntilOverlayReady: true,
},
logging: {
files: {
mpv: true,
},
},
}),
);
fs.writeFileSync(appPath, '#!/bin/sh\nexit 0\n');
@@ -468,7 +496,9 @@ ${bunBinary} -e "const net=require('node:net'); const fs=require('node:fs'); con
const result = runLauncher(['--log-level', 'debug', videoPath], env);
assert.equal(result.status, 0, `stdout:\n${result.stdout}\nstderr:\n${result.stderr}`);
assert.match(fs.readFileSync(mpvArgsPath, 'utf8'), /--script-opts=.*subminer-log_level=debug/);
const mpvArgs = fs.readFileSync(mpvArgsPath, 'utf8');
assert.match(mpvArgs, /--msg-level=all=warn,subminer=debug/);
assert.doesNotMatch(mpvArgs, /--script-opts=.*subminer-log_level=debug/);
});
});