mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-26 00:55:16 -07:00
fix(launcher): suppress Electron menu diagnostics
This commit is contained in:
@@ -0,0 +1,4 @@
|
|||||||
|
type: fixed
|
||||||
|
area: launcher
|
||||||
|
|
||||||
|
- Suppressed Electron macOS menu diagnostics from `subminer config` launcher output.
|
||||||
@@ -280,6 +280,34 @@ test('launcher config command forwards app configuration window command', () =>
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('launcher config command suppresses known Electron macOS menu diagnostics', () => {
|
||||||
|
withTempDir((root) => {
|
||||||
|
const homeDir = path.join(root, 'home');
|
||||||
|
const xdgConfigHome = path.join(root, 'xdg');
|
||||||
|
const appPath = path.join(root, 'fake-subminer.sh');
|
||||||
|
fs.writeFileSync(
|
||||||
|
appPath,
|
||||||
|
[
|
||||||
|
'#!/bin/sh',
|
||||||
|
'printf "%s\\n" "2026-05-17 02:59:52.141 SubMiner[29060:305323] representedObject is not a WeakPtrToElectronMenuModelAsNSObject" >&2',
|
||||||
|
'printf "%s\\n" "real stderr line" >&2',
|
||||||
|
'exit 0',
|
||||||
|
'',
|
||||||
|
].join('\n'),
|
||||||
|
);
|
||||||
|
fs.chmodSync(appPath, 0o755);
|
||||||
|
|
||||||
|
const env = {
|
||||||
|
...makeTestEnv(homeDir, xdgConfigHome),
|
||||||
|
SUBMINER_APPIMAGE_PATH: appPath,
|
||||||
|
};
|
||||||
|
const result = runLauncher(['config'], env);
|
||||||
|
|
||||||
|
assert.equal(result.status, 0);
|
||||||
|
assert.equal(result.stderr, 'real stderr line\n');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test('launcher forwards --args to mpv as parsed tokens', { timeout: 15000 }, () => {
|
test('launcher forwards --args to mpv as parsed tokens', { timeout: 15000 }, () => {
|
||||||
withTempDir((root) => {
|
withTempDir((root) => {
|
||||||
const homeDir = path.join(root, 'home');
|
const homeDir = path.join(root, 'home');
|
||||||
|
|||||||
+20
-5
@@ -1229,6 +1229,14 @@ function appendCapturedAppOutput(kind: 'STDOUT' | 'STDERR', chunk: string): void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const KNOWN_ELECTRON_MENU_DIAGNOSTIC =
|
||||||
|
'representedObject is not a WeakPtrToElectronMenuModelAsNSObject';
|
||||||
|
|
||||||
|
function filterKnownElectronDiagnostics(chunk: string): string {
|
||||||
|
const lines = chunk.match(/[^\n]*\n|[^\n]+/g) ?? [];
|
||||||
|
return lines.filter((line) => !line.includes(KNOWN_ELECTRON_MENU_DIAGNOSTIC)).join('');
|
||||||
|
}
|
||||||
|
|
||||||
function attachAppProcessLogging(
|
function attachAppProcessLogging(
|
||||||
proc: ReturnType<typeof spawn>,
|
proc: ReturnType<typeof spawn>,
|
||||||
options?: {
|
options?: {
|
||||||
@@ -1243,8 +1251,12 @@ function attachAppProcessLogging(
|
|||||||
if (options?.mirrorStdout) process.stdout.write(chunk);
|
if (options?.mirrorStdout) process.stdout.write(chunk);
|
||||||
});
|
});
|
||||||
proc.stderr?.on('data', (chunk: string) => {
|
proc.stderr?.on('data', (chunk: string) => {
|
||||||
appendCapturedAppOutput('STDERR', chunk);
|
const filteredChunk = filterKnownElectronDiagnostics(chunk);
|
||||||
if (options?.mirrorStderr) process.stderr.write(chunk);
|
if (!filteredChunk) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
appendCapturedAppOutput('STDERR', filteredChunk);
|
||||||
|
if (options?.mirrorStderr) process.stderr.write(filteredChunk);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1268,13 +1280,16 @@ function runSyncAppCommand(
|
|||||||
if (mirrorOutput) process.stdout.write(result.stdout);
|
if (mirrorOutput) process.stdout.write(result.stdout);
|
||||||
}
|
}
|
||||||
if (result.stderr) {
|
if (result.stderr) {
|
||||||
appendCapturedAppOutput('STDERR', result.stderr);
|
const filteredStderr = filterKnownElectronDiagnostics(result.stderr);
|
||||||
if (mirrorOutput) process.stderr.write(result.stderr);
|
if (filteredStderr) {
|
||||||
|
appendCapturedAppOutput('STDERR', filteredStderr);
|
||||||
|
if (mirrorOutput) process.stderr.write(filteredStderr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
status: result.status ?? 1,
|
status: result.status ?? 1,
|
||||||
stdout: result.stdout ?? '',
|
stdout: result.stdout ?? '',
|
||||||
stderr: result.stderr ?? '',
|
stderr: result.stderr ? filterKnownElectronDiagnostics(result.stderr) : '',
|
||||||
error: result.error ?? undefined,
|
error: result.error ?? undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user