67 lines
2 KiB
JavaScript
67 lines
2 KiB
JavaScript
'use strict'
|
|
|
|
const path = require('path')
|
|
const fs = require('fs')
|
|
|
|
const runner = require('../src/runner')
|
|
const wines = require('../src/wines')
|
|
|
|
async function main() {
|
|
await wines.refreshWines()
|
|
const proton = wines.getWines().find(w => w.type === 'proton')
|
|
if (!proton) {
|
|
console.log('NO PROTON IMPORTED')
|
|
return
|
|
}
|
|
console.log('using:', proton.id, proton.path)
|
|
|
|
const game = {
|
|
id: 'proton-e2e',
|
|
name: 'Proton E2E',
|
|
mode: 'leave',
|
|
path: '.',
|
|
exePath: 'C:\\windows\\system32\\cmd.exe',
|
|
workdir: path.resolve('.'),
|
|
wine: proton.id,
|
|
prefix: '',
|
|
args: '/c echo PROTON-RUNNER-OK > C:\\proton-runner.txt',
|
|
dllOverrides: [],
|
|
env: {}
|
|
}
|
|
|
|
const env = runner.buildEnv({ game, wine: proton }).env
|
|
console.log('STEAM_COMPAT_DATA_PATH:', env.STEAM_COMPAT_DATA_PATH)
|
|
console.log('symlinked to:', fs.readlinkSync(env.STEAM_COMPAT_DATA_PATH))
|
|
console.log('WINEPREFIX:', env.WINEPREFIX)
|
|
|
|
const exitPromise = new Promise(resolve => {
|
|
runner.runGame({
|
|
game,
|
|
wine: proton,
|
|
onExit: (code, signal) => resolve({ code, signal })
|
|
})
|
|
})
|
|
|
|
for (let i = 0; i < 60; i++) {
|
|
await new Promise(r => setTimeout(r, 2000))
|
|
const outFile = path.join(env.WINEPREFIX, 'drive_c', 'proton-runner.txt')
|
|
if (fs.existsSync(outFile)) {
|
|
console.log('OUTPUT:', fs.readFileSync(outFile, 'utf8').trim())
|
|
console.log('PROTON E2E PASS')
|
|
return
|
|
}
|
|
}
|
|
console.log('TIMEOUT waiting for output file')
|
|
const logs = fs.readdirSync(path.join(require('../src/paths').DIRS.DATA, 'logs')).filter(f => f.startsWith('proton-e2e'))
|
|
if (logs.length) {
|
|
const log = fs.readFileSync(path.join(require('../src/paths').DIRS.DATA, 'logs', logs[logs.length - 1]), 'utf8')
|
|
console.log('LOG TAIL:', log.slice(-2000))
|
|
}
|
|
const { code } = await Promise.race([exitPromise, new Promise(r => setTimeout(() => r({ code: 'still-running' }), 30000))])
|
|
console.log('exit:', code)
|
|
}
|
|
|
|
main().catch(e => {
|
|
console.error(e)
|
|
process.exit(1)
|
|
})
|