Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Make the compatibility_layers test work on systems with Wine installed #3847

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Make the compatibility_layers test work on systems with Wine installed
This test assumed that Wine is not installed, which works fine in CI, but not on
 most "real" systems
  • Loading branch information
CommandMC committed Jul 2, 2024
commit 5f1c48438ff54de5f2feb976592d4be8362c3781
20 changes: 8 additions & 12 deletions src/backend/utils/__tests__/compatibility_layers.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { describe } from 'node:test'
import {
getDefaultWine,
getWineExecs,
Expand All @@ -7,6 +6,7 @@ import {
import { mkdirSync } from 'graceful-fs'
import { dirname, join } from 'path'
import { tmpdir } from 'os'
import child_process from 'child_process'

jest.mock('@xhmikosr/decompress')
jest.mock('../../logger/logfile')
Expand All @@ -18,22 +18,16 @@ describe('getDefaultWine', () => {
name: 'Default Wine - Not Found',
type: 'wine'
}
jest.spyOn(child_process, 'execSync').mockImplementation(() => {
throw new Error()
})
const result = getDefaultWine()
expect(result).toEqual(expected)
})

test('return list with one default wine', () => {
const expected = {
bin: '/usr/bin/wine',
name: 'Wine Default - wine-6.0 (Staging)',
type: 'wine',
wineserver: ''
}

// spy on the execSync calling which wine and returning /usr/bin/wine
// eslint-disable-next-line @typescript-eslint/no-var-requires
const execSync = jest.spyOn(require('child_process'), 'execSync')
execSync.mockImplementation((command: any) => {
jest.spyOn(child_process, 'execSync').mockImplementation((command) => {
if (command === 'which wine') {
return '/usr/bin/wine\n'
} else if (command === 'wine --version') {
Expand All @@ -43,7 +37,9 @@ describe('getDefaultWine', () => {
})

const result = getDefaultWine()
expect(result).toEqual(expected)
expect(result.bin).toBe('/usr/bin/wine')
expect(result.name).toBe('Wine Default - wine-6.0 (Staging)')
expect(result.type).toBe('wine')
})
})

Expand Down
Loading