Skip to content

Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit

feat(panel): pick a custom game executable and Start In folder (upstream #221)

raymondchinsb92d7b1be7b2
diff --git a/dylib/feats/webpatch.c b/dylib/feats/webpatch.c
index 286970b..8e342c5 100644
--- a/dylib/feats/webpatch.c
+++ b/dylib/feats/webpatch.c
@@ -242,7 +242,7 @@ static int out_expand(np_out_t *o, const char *replace, const np_cap_t *caps) {
"E.e.forEach(w=>{if(ps.some(p=>o.startsWith(p[0]+\"=\",w.start))){" \
"r+=o.slice(at,w.start);at=w.end;while(o[at]===\" \"||o[at]===\"\\t\")at++}});r+=o.slice(at)}" \
"SteamClient.Apps.SetAppLaunchOptions(id,r.trim()===\"%command%\"?\"\":r)};" \
- "return{g,s,k:E.e.map(w=>o.slice(w.start,w.end).split(\"=\")[0])}}"
+ "return{g,s,k:E.e.map(w=>o.slice(w.start,w.end).split(\"=\")[0]),c:E.c<0?null:E.G[E.c]}}"
#define NP_CX_PICK \
"(t,n)=>{const o=t.strLaunchOptions||\"\";" \
@@ -297,8 +297,31 @@ static int out_expand(np_out_t *o, const char *replace, const np_cap_t *caps) {
".MSCXPanel .MSCXDrop{display:flex;flex-direction:column;align-items:stretch;gap:6px;" \
"padding:0;margin:10px 0;background:none}" \
".MSCXPanel .MSCXDrop>*{width:100%;max-width:none;margin:0}" \
+ ".MSCXPanel .MSCXPath{align-items:center;gap:8px;margin-bottom:2px}" \
+ ".MSCXPanel .MSCXPathText{flex:1;min-width:0;font-size:13px;overflow-wrap:anywhere}" \
+ ".MSCXPanel .MSCXDefault{color:#8b929a}" \
+ ".MSCXPanel button.MSCXButton{width:auto;flex:none;margin:0;padding:0 14px;font-size:13px;line-height:28px}" \
".MSCXNoBottomGap{margin-bottom:0}\""
+// The Executable rows write a plain sh wrapper around %command%. It swaps the argument after
+// waitforexitandrun for the chosen program and starts it from its folder or the Start In folder.
+// Only that exact wrapper is read back, and nothing is written unless %command% is a bare word.
+#define NP_CX_TARGET \
+ "(o,id)=>{" \
+ "const q=v=>\"'\"+v.replace(/'/g,\"'\\\\''\").replace(/%(?=command%)/gi,\"%'\\\"\\\"'\")+\"'\"," \
+ "h=\"sh -c \"+q('exe=$1 dir=$2 found= prev=; shift 2; for arg in \"$@\"; do shift; '+" \
+ "'if [ -z \"$found\" ] && [ \"$prev\" = waitforexitandrun ]; then arg=$exe found=1; fi; prev=$arg; set -- \"$@\" \"$arg\"; done; '+" \
+ "'[ \"$found\" ] && cd \"${dir:-${exe%/*}/}\" && exec \"$@\"')+\" sh \"," \
+ "at=o.indexOf(h)," \
+ "m=at<0?null:/^('(?:[^']|'\\\\''|'\"\"')*') ('(?:[^']|'\\\\''|'\"\"')*') %command%/.exec(o.slice(at+h.length))," \
+ "rd=v=>v.slice(1,-1).replace(/'\\\\''|'\"\"'/g,x=>x[1]===\"\\\\\"?\"'\":\"\")," \
+ "b=m?o.slice(0,at)+\"%command%\"+o.slice(at+h.length+m[0].length):o;" \
+ "return{ex:m?rd(m[1]):\"\",sd:m?rd(m[2]):\"\",write:(e,d)=>{" \
+ "const B=/%command%/i.test(b)?b:\"%command%\"+(b.trim()?\" \"+b:\"\"),c=MSCXLaunch(B,id).c;" \
+ "if(!c||!/^%command%$/i.test(B.slice(c.start,c.end)))return;" \
+ "const r=B.slice(0,c.start)+(e?h+q(e)+\" \"+q(d)+\" %command%\":\"%command%\")+B.slice(c.end);" \
+ "SteamClient.Apps.SetAppLaunchOptions(id,r.trim()===\"%command%\"?\"\":r)}}}"
+
// FEX runs arm64 Wine, which has no D3DMetal and never runs under Rosetta.
#define NP_CX_OPTIONS_BODY(ARG, RT, BARREL) \
ARG "=>{" \
@@ -368,6 +391,14 @@ static int out_expand(np_out_t *o, const char *replace, const np_cap_t *caps) {
/* A toggle that is on unless set to "0" (upstream 1.2.0: AVX2, FEX x87 precision). */ \
"X=(k,l)=>(0," RT ".jsx)(" BARREL ".Yh,{className:\"MSCXRow\",label:l," \
"checked:\"0\"!==ev(k),onChange:v=>s([[k,v?\"\":\"0\"]])},k)," \
+ "XT=(" NP_CX_TARGET ")(o,t.unAppID),ex=XT.ex,sd=XT.sd,exd=ex.replace(/\\/[^\\/]*$/,\"\")||\"/\"," \
+ "pk=(q,f)=>SteamClient.System.OpenFileDialog(q).then(p=>p&&f(p))," \
+ "P=(v,x,q,f,rs,k)=>(0," RT ".jsxs)(\"div\",{className:\"MSCXRow MSCXPath\",children:[" \
+ "(0," RT ".jsx)(\"div\",{className:v?\"MSCXPathText\":\"MSCXPathText MSCXDefault\",children:x})," \
+ "(0," RT ".jsx)(" BARREL ".$n,{className:\"MSCXButton\",onClick:()=>pk(q,f)," \
+ "children:npL(\"Browse...\",\"浏览…\",\"Sfoglia...\")})," \
+ "v&&(0," RT ".jsx)(" BARREL ".$n,{className:\"MSCXButton\",onClick:rs," \
+ "children:npL(\"Reset\",\"重置\",\"Ripristina\")})]},k)," \
"bv=g(\"CX_GRAPHICS_BACKEND\"),b=fex&&\"d3dmetal\"===bv?\"\":bv," \
"dm=!fex&&(\"\"===b||\"d3dmetal\"===b)," \
"dx=\"\"===b||\"dxmt\"===b," \
@@ -426,7 +457,18 @@ static int out_expand(np_out_t *o, const char *replace, const np_cap_t *caps) {
"]},\"ctl\")," \
"fex&&(0," RT ".jsx)(" BARREL ".XY,{label:\"FEX\"," \
"children:X(\"FEX_X87REDUCEDPRECISION\"," \
- "\"Reduced x87 Precision (Reducing precision improves game performance, is enabled by default in CrossOver Preview)\")},\"fex\")" \
+ "\"Reduced x87 Precision (Reducing precision improves game performance, is enabled by default in CrossOver Preview)\")},\"fex\")," \
+ "(0," RT ".jsxs)(" BARREL ".XY,{label:npL(\"Executable\",\"可执行文件\",\"Eseguibile\"),children:[" \
+ "P(ex,ex||npL(\"Game default\",\"游戏默认\",\"Predefinito del gioco\")," \
+ "{strTitle:npL(\"Choose a program to launch\",\"选择要启动的程序\",\"Scegli il programma da avviare\")," \
+ "rgFilters:[{strFileTypeName:npL(\"Windows programs (*.exe, *.bat)\",\"Windows 程序 (*.exe, *.bat)\"," \
+ "\"Programmi Windows (*.exe, *.bat)\"),rFilePatterns:[\"*.exe\",\"*.bat\"],bUseAsDefault:!0}]," \
+ "strInitialFile:ex||t.strInstallFolder||\"\"}," \
+ "p=>XT.write(p,\"\"),()=>XT.write(\"\",\"\"),\"exe\")," \
+ "ex&&P(sd,npL(\"Start In\",\"起始位置\",\"Avvia in\")+\": \"+(sd||exd)," \
+ "{strTitle:npL(\"Start In\",\"起始位置\",\"Avvia in\"),strInitialFile:sd||exd,bChooseDirectory:!0}," \
+ "p=>XT.write(ex,p),()=>XT.write(ex,\"\"),\"dir\")" \
+ "]},\"exe\")" \
"]})})}"
#define NP_CX_OPTIONS_CAPTURE(RT, BARREL) \
diff --git a/dylib/tests/panel-behavior/behavior.js b/dylib/tests/panel-behavior/behavior.js
index 54396f2..8482ee4 100644
--- a/dylib/tests/panel-behavior/behavior.js
+++ b/dylib/tests/panel-behavior/behavior.js
@@ -19,7 +19,7 @@ for (const form of Object.keys(FORMS)) {
'a shortcut renders the panel before a tool name reaches the page');
let r = nodes('');
- t.ok(toggles(r).length === 7 && sections(r).length === 4, 'automatic shows seven toggles in four sections');
+ t.ok(toggles(r).length === 7 && sections(r).length === 5, 'automatic shows seven toggles in five sections');
t.ok(r.filter(x => x.type === 'Dropdown').length === 3, 'three dropdowns');
t.ok(!('label' in r.find(x => x.type === 'Dropdown').props), 'the backend dropdown carries no label column');
diff --git a/dylib/tests/panel-behavior/harness.js b/dylib/tests/panel-behavior/harness.js
index 036132b..f984ff6 100644
--- a/dylib/tests/panel-behavior/harness.js
+++ b/dylib/tests/panel-behavior/harness.js
@@ -15,7 +15,7 @@ const expand = (s, caps) => s.replace(/[\u0001-\u0008\u0013-\u0016]/g, c => {
const mk = (type, props) => ({ type, props });
const react = { jsx: mk, jsxs: mk, Fragment: 'Fragment' };
-const barrel = { XY: 'Section', m: 'Dropdown', Yh: 'Toggle' };
+const barrel = { XY: 'Section', m: 'Dropdown', Yh: 'Toggle', $n: 'Button' };
// The two shapes take the payload in different forms and bind different names, which
// is the whole of the difference between them.
@@ -34,14 +34,18 @@ function panel(emit, form, globals = Object.assign(Object.create(globalThis),
const body = expand(raw, { [f.react]: names[0], [f.barrel]: names[1] });
const src = form === 'component' ? 'var ' + body.replace(/,$/, '') : body.replace(/;$/, '');
const written = [];
+ // Each file dialog records its request and answers with the next entry in `files`,
+ // straight away so a check can read what was written without awaiting.
+ const dialogs = [], files = [];
const SteamClient = {
Apps: { SetAppLaunchOptions: (appid, opts) => written.push({ appid, opts }) },
+ System: { OpenFileDialog: q => { dialogs.push(q); const p = files.shift(); return { then: f => f(p) }; } },
};
const build = new Function(names[0], names[1], 'SteamClient', 'globalThis',
src + '\nreturn { MSCXOpts, MSCXPick: typeof MSCXPick === "function" ? MSCXPick : null,' +
' MSCXToolQuery: typeof MSCXToolQuery === "function" ? MSCXToolQuery : null };');
const { MSCXOpts, MSCXPick, MSCXToolQuery } = build(react, barrel, SteamClient, globals);
- return { render: MSCXOpts, pick: MSCXPick, toolQuery: MSCXToolQuery, written };
+ return { render: MSCXOpts, pick: MSCXPick, toolQuery: MSCXToolQuery, written, dialogs, files };
}
// Function components are resolved rather than recorded, so a check sees the nodes the
diff --git a/dylib/tests/panel-behavior/localization.js b/dylib/tests/panel-behavior/localization.js
index fb043ae..3c02fcf 100644
--- a/dylib/tests/panel-behavior/localization.js
+++ b/dylib/tests/panel-behavior/localization.js
@@ -19,7 +19,7 @@ for (const form of Object.keys(FORMS)) {
for (const [language, cases] of [['zh', zhCases], ['it', itCases], ['en', enCases]]) {
const t = (...labels) => labels[lang[language]];
for (const globals of cases) {
- const { render, written } = panel(emit, form, globals);
+ const { render, files, written } = panel(emit, form, globals);
const nodes = walk(render({ details: details('CX_GRAPHICS_BACKEND=dxmt %command%') }));
const dropdowns = nodes.filter(n => n.type === 'Dropdown');
assert.equal(dropdowns[0].props.rgOptions[0].label, t('Automatic', '自动', 'Automatico'));
@@ -33,6 +33,15 @@ for (const form of Object.keys(FORMS)) {
'允许游戏直接读取控制器(Mac 上推荐,仅在需要 Steam Input 按键映射时关闭)',
'Lascia che i giochi leggano direttamente i controller (consigliato su Mac, disattiva solo per la rimappatura di Steam Input)'));
assert(nodes.some(n => n.props.label === t('Disable hidraw', '停用 hidraw', 'Disattiva hidraw')));
+ assert(nodes.some(n => n.props.label === t('Executable', '可执行文件', 'Eseguibile')));
+ assert(nodes.some(n => n.props.children === t('Game default', '游戏默认', 'Predefinito del gioco')));
+ const browse = nodes.find(n => n.type === 'Button');
+ files.push('/g/a.exe');
+ browse.props.onClick();
+ const target = walk(render({ details: details(written.at(-1).opts) }));
+ assert.deepEqual(target.filter(n => n.type === 'Button').map(n => n.props.children),
+ [t('Browse...', '浏览…', 'Sfoglia...'), t('Reset', '重置', 'Ripristina'), t('Browse...', '浏览…', 'Sfoglia...')]);
+ assert(target.some(n => n.props.children === t('Start In', '起始位置', 'Avvia in') + ': /g'));
raw.props.onChange(true);
assert.equal(written.at(-1).opts, 'BRIDGEPLAY_RAW_CONTROLLERS=1 CX_GRAPHICS_BACKEND=dxmt %command%');
const hud = nodes.find(n => n.props.label === t('Metal HUD', 'Metal 性能监视器', 'Metal HUD'));
diff --git a/dylib/tests/panel-behavior/shell.js b/dylib/tests/panel-behavior/shell.js
index 8fc7d23..6d3f01a 100644
--- a/dylib/tests/panel-behavior/shell.js
+++ b/dylib/tests/panel-behavior/shell.js
@@ -20,15 +20,15 @@ const ON_UNLESS_0 = { ROSETTA_ADVERTISE_AVX: true };
const PANEL_KEYS = ['CX_GRAPHICS_BACKEND', 'MTL_HUD_ENABLED', 'D3DM_ENABLE_METALFX', 'DXMT_ENABLE_NVEXT',
'DXMT_METALFX_SPATIAL_SWAPCHAIN', 'DXMT_CONFIG', 'ROSETTA_ADVERTISE_AVX', 'WINEMSYNC', 'BRIDGEPLAY_RETINA',
'BRIDGEPLAY_RAW_CONTROLLERS', 'BRIDGEPLAY_DISABLE_HIDRAW'];
-const OTHER_KEYS = ['WINEDEBUG', 'DXVK_HUD', 'FOO'];
+const OTHER_KEYS = ['WINEDEBUG', 'DXVK_HUD', 'FOO', 'SteamAppId', 'STEAM_COMPAT_DATA_PATH'];
-const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'np-shell-'));
+const dir = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'np-shell-')));
const probe = path.join(dir, 'probe');
-// The game: appends one record per run, argc, the arguments, then a set flag and value
-// per key, each field NUL-terminated. A shell script starts in milliseconds, node in ~80.
+// The game: appends one record per run, argc, the arguments, the working directory, then a
+// set flag and value per key, each field NUL-terminated. A shell script starts in milliseconds, node in ~80.
const KEYS = PANEL_KEYS.concat(OTHER_KEYS);
fs.writeFileSync(probe, '#!/bin/sh\n{\n' +
- ` printf '%s\\0' "$#"\n for a in "$@"; do printf '%s\\0' "$a"; done\n` +
+ ` printf '%s\\0' "$#"\n for a in "$@"; do printf '%s\\0' "$a"; done\n pwd -P | tr -d '\\n'; printf '\\0'\n` +
KEYS.map(k => ` if [ "\${${k}+set}" ]; then printf '1\\0%s\\0' "$${k}"; else printf '0\\0'; fi\n`).join('') +
'} >>"$NP_PROBE_OUT"\n', { mode: 0o755 });
@@ -39,6 +39,7 @@ function records(text) {
const argc = Number(f[n++]);
const run = { argv: f.slice(n, n + argc), env: {} };
n += argc;
+ run.cwd = f[n++];
for (const k of KEYS) if (f[n++] === '1') run.env[k] = f[n++];
runs.push(run);
}
@@ -47,20 +48,21 @@ function records(text) {
fs.writeFileSync(path.join(dir, 'gamemoderun'), '#!/bin/sh\nexec "$@"\n', { mode: 0o755 });
const quote = s => "'" + s.replace(/'/g, "'\\''") + "'";
-const COMMAND = quote(probe) + " 'game.exe'";
+// What Steam logs for %command%: the tool, its verb, then the game.
+const COMMAND = quote(probe) + " waitforexitandrun 'game.exe'";
-function steamLine(options) {
+function steamLine(options, command = COMMAND) {
const o = options.trim();
- return /%command%/i.test(o) ? o.replace(/%command%/gi, () => COMMAND) : COMMAND + (o ? ' ' + o : '');
+ return /%command%/i.test(o) ? o.replace(/%command%/gi, () => command) : command + (o ? ' ' + o : '');
}
const shells = ['/bin/sh', '/bin/dash'].filter(s => fs.existsSync(s));
-function launch(shell, options) {
+function launch(shell, options, command) {
const out = path.join(dir, 'runs');
fs.rmSync(out, { force: true });
- spawnSync(shell, ['-c', steamLine(options)], {
- env: { PATH: dir + ':/usr/bin:/bin', HOME: process.env.HOME, NP_PROBE_OUT: out },
+ spawnSync(shell, ['-c', steamLine(options, command)], {
+ env: { PATH: dir + ':/usr/bin:/bin', HOME: process.env.HOME, NP_PROBE_OUT: out, SteamAppId: '287700', STEAM_COMPAT_DATA_PATH: '/steam/prefix/287700' },
cwd: dir, timeout: 10000, stdio: 'ignore',
});
return fs.existsSync(out) ? records(fs.readFileSync(out, 'utf8')) : [];
@@ -74,7 +76,8 @@ function view(form, options) {
.forEach(n => { toggles[TOGGLES[n.props.label]] = n; });
const backend = nodes.find(n => n.type === 'Dropdown' && n.props.rgOptions.some(o => o.data === 'dxvk'));
const upscale = nodes.find(n => n.type === 'Dropdown' && n.props.rgOptions.some(o => o.data === '1.5'));
- return { toggles, backend, upscale, written: P.written };
+ return { toggles, backend, upscale, written: P.written, files: P.files, dialogs: P.dialogs,
+ buttons: nodes.filter(n => n.type === 'Button') };
}
function dxmt(conf) {
@@ -223,6 +226,117 @@ for (const shell of shells) {
failed += t.failed;
}
}
+
+// The Executable rows, driven through Steam's file dialog and read back from what the game gets.
+const TARGETS = ['Mod Engine 2/launchmod_eldenring.bat',
+ `Jeux/Café "d" l'été/ゲーム.EXE`, 'AssassinsCreed_Dx10.exe', '$HOME `id` \\x.bat',
+ 'braces{a,b}[*]?/%command%\n.exe'].map(p => path.join(dir, p));
+for (const exe of TARGETS) fs.mkdirSync(path.dirname(exe), { recursive: true });
+const startDir = path.join(dir, 'start in/ü');
+fs.mkdirSync(startDir, { recursive: true });
+const otherExe = path.join(dir, 'other.exe');
+const STARTS = ['', '-windowed', 'MTL_HUD_ENABLED=1 %command% --offline',
+ 'WINEDEBUG="a b" gamemoderun %command% -t er',
+ '"/Users/test/Games/Mod Engine 2/launchmod_eldenring.bat"',
+ `bash -c 'exec "\${@/game.exe/launchmod_eldenring.bat}"' -- %command%`];
+for (const shell of shells) {
+ for (const form of Object.keys(FORMS)) {
+ const t = runner(`${path.basename(shell)} ${form} executable`);
+ const click = (v, n, file) => {
+ if (file !== undefined) v.files.push(file);
+ v.buttons[n].props.onClick();
+ return v.written.length ? v.written[v.written.length - 1].opts : null;
+ };
+ for (const start of STARTS) {
+ const before = launch(shell, start);
+ let v = view(form, start);
+ t.ok(v.buttons.length === 1, `${JSON.stringify(start)}: only Browse shows without a target`);
+ t.ok(click(v, 0, '') === null, `${JSON.stringify(start)}: a cancelled dialog writes nothing`);
+ for (const exe of TARGETS) {
+ const what = `${JSON.stringify(start)} + ${JSON.stringify(exe)}`;
+ v = view(form, start);
+ const picked = click(v, 0, exe);
+ t.ok(JSON.stringify(v.dialogs[0].rgFilters[0].rFilePatterns) === '["*.exe","*.bat"]',
+ `${what}: the dialog offers .exe and .bat`);
+ const run = launch(shell, picked);
+ t.ok(run.length === before.length && run.length > 0, `${what}: the game runs once -> ${JSON.stringify(picked)}`);
+ if (!run.length || run.length !== before.length) continue;
+ t.ok(run[0].argv[1] === exe && run[0].cwd === path.dirname(exe),
+ `${what}: tool receives the chosen target and its working directory`);
+ t.ok(JSON.stringify(run[0].argv) === JSON.stringify(before[0].argv.map((a, i) => i === 1 ? exe : a)),
+ `${what}: game arguments kept ${JSON.stringify(run[0].argv)}`);
+ t.ok(['WINEDEBUG', 'MTL_HUD_ENABLED', 'SteamAppId', 'STEAM_COMPAT_DATA_PATH'].every(k => run[0].env[k] === before[0].env[k]),
+ `${what}: other settings kept`);
+
+ if (start === STARTS[0] && exe === TARGETS[0]) {
+ t.ok(launch(shell, picked, quote(probe) + " run 'game.exe'").length === 0,
+ `${what}: without waitforexitandrun nothing launches`);
+ v = view(form, picked);
+ v.toggles.MTL_HUD_ENABLED.props.onChange(true);
+ const toggled = v.written.at(-1).opts;
+ const toggleRun = launch(shell, toggled);
+ t.ok(toggleRun.length === 1 && toggleRun[0].env.MTL_HUD_ENABLED === '1' &&
+ toggleRun[0].argv[1] === exe, `${what}: settings edits retain the generated wrapper`);
+ const F = panel(emit, form, undefined, { fexTools: ['fex'] });
+ F.pick(details('CX_GRAPHICS_BACKEND=d3dmetal ' + toggled), 'fex');
+ const fexRun = launch(shell, F.written.at(-1).opts);
+ t.ok(fexRun.length === 1 && !fexRun[0].env.CX_GRAPHICS_BACKEND &&
+ fexRun[0].argv[1] === exe, `${what}: FEX cleanup retains the generated wrapper`);
+ v = view(form, picked);
+ const badDir = click(v, 2, path.join(dir, 'missing'));
+ t.ok(launch(shell, badDir).length === 0, `${what}: failed cd does not launch a game`);
+ }
+ v = view(form, picked);
+ t.ok(v.buttons.length === 3, `${what}: Reset and Start In show once a target is set`);
+ const folder = exe.replace(/\/[^/]*$/, '');
+ const withDir = click(v, 2, startDir);
+ t.ok(v.dialogs[0].bChooseDirectory === true && v.dialogs[0].strInitialFile === folder,
+ `${what}: Start In opens on the target's folder`);
+ const dirRun = launch(shell, withDir);
+ t.ok(dirRun.length && dirRun[0].cwd === startDir && dirRun[0].argv[1] === exe, `${what}: Start In is set and the target kept`);
+
+ v = view(form, withDir);
+ const cancelled = click(v, 0, undefined) === null;
+ t.ok(cancelled && v.buttons.length === 4, `${what}: both rows offer Reset once both are set`);
+ const dirReset = launch(shell, click(v, 3));
+ t.ok(dirReset.length && dirReset[0].cwd === path.dirname(exe) && dirReset[0].argv[1] === exe,
+ `${what}: resetting Start In keeps the target`);
+
+ v = view(form, withDir);
+ const again = launch(shell, click(v, 0, otherExe));
+ t.ok(again.length && again[0].argv[1] === otherExe && again[0].cwd === dir,
+ `${what}: choosing another target drops the old Start In`);
+
+ v = view(form, withDir);
+ const reset = click(v, 1);
+ const resetRun = launch(shell, reset);
+ t.ok(resetRun.length === before.length && resetRun.every((r, n) =>
+ r.cwd === before[n].cwd && JSON.stringify(r.argv) === JSON.stringify(before[n].argv)),
+ `${what}: Reset launches the game as before -> ${JSON.stringify(reset)}`);
+ t.ok(reset === (/%command%/.test(start) || !start ? start : '%command% ' + start),
+ `${what}: Reset restores the original text`);
+ }
+ }
+ failed += t.failed;
+ }
+}
+
+// A %command% the wrapper cannot stand in for is left alone rather than rewritten.
+for (const form of Object.keys(FORMS)) {
+ const t = runner(`${form} executable, unsupported options`);
+ for (const start of ['MTL_HUD_ENABLED=1 "%command%"', 'MTL_HUD_ENABLED=1 \\%command%',
+ "bash -c 'run %command%'", '# %command%']) {
+ const v = view(form, start);
+ v.files.push(otherExe);
+ v.buttons[0].props.onClick();
+ t.ok(v.written.length === 0, `${JSON.stringify(start)}: Browse writes nothing`);
+ }
+ const lookalike = "sh -c 'exec \"$@\"' sh '/g/a.exe' '' %command%";
+ const v = view(form, lookalike);
+ t.ok(v.buttons.length === 1, 'a hand-written wrapper is not read as a chosen executable');
+ failed += t.failed;
+}
+
fs.rmSync(dir, { recursive: true, force: true });
console.log(failed ? `\n${failed} failure(s)` : `\npanel agrees with ${shells.join(' and ')}`);
process.exit(failed ? 1 : 0);