-
Notifications
You must be signed in to change notification settings - Fork 265
fix: Include swiftshader directory when creating installer for Electron 10+ #375
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
Changes from 10 commits
cc715be
255d8d1
2db4aab
dd035a2
772635f
f517443
0501a27
3368341
ffe8e31
a0b2b70
b5c6cc3
b36f263
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,33 +3,38 @@ import path from 'path'; | |
| import { createTempDir } from '../src/temp-utils'; | ||
| import fs from 'fs-extra'; | ||
| import { createWindowsInstaller } from '../src'; | ||
| import spawn from '../src/spawn-promise'; | ||
|
|
||
| const log = require('debug')('electron-windows-installer:spec'); | ||
|
|
||
| const appDirectory = path.join(__dirname, 'fixtures/app'); | ||
| const fixtureAppDirectory = path.join(__dirname, 'fixtures/app'); | ||
|
|
||
| test.beforeEach(async (): Promise<void> => { | ||
| const updateExePath = path.join(appDirectory, 'Squirrel.exe'); | ||
| function spawn7z(args: string[]): Promise<string> { | ||
| const sevenZipPath = path.join(__dirname, '..', 'vendor', '7z.exe'); | ||
| return process.platform !== 'win32' | ||
| ? spawn(process.arch === 'x64' ? 'wine64' : 'wine', [sevenZipPath, ...args]) | ||
| : spawn(sevenZipPath, args); | ||
| } | ||
|
|
||
| if (await fs.pathExists(updateExePath)) { | ||
| await fs.unlink(updateExePath); | ||
| } | ||
| }); | ||
| async function createTempAppDirectory(): Promise<string> { | ||
| const appDirectory = await createTempDir('ad-'); | ||
|
niik marked this conversation as resolved.
Outdated
|
||
| await fs.copy(fixtureAppDirectory, appDirectory); | ||
| return appDirectory; | ||
| } | ||
|
|
||
| test('creates a nuget package and installer', async (t): Promise<void> => { | ||
| const outputDirectory = await createTempDir('ei-'); | ||
|
|
||
| const options = { | ||
| appDirectory: appDirectory, | ||
| outputDirectory: outputDirectory | ||
| }; | ||
| const appDirectory = await createTempAppDirectory(); | ||
| const options = { appDirectory, outputDirectory }; | ||
|
|
||
| await createWindowsInstaller(options); | ||
|
|
||
| log(`Verifying assertions on ${outputDirectory}`); | ||
| log(JSON.stringify(await fs.readdir(outputDirectory))); | ||
|
|
||
| t.true(await fs.pathExists(path.join(outputDirectory, 'myapp-1.0.0-full.nupkg'))); | ||
| const nupkgPath = path.join(outputDirectory, 'myapp-1.0.0-full.nupkg'); | ||
|
|
||
| t.true(await fs.pathExists(nupkgPath)); | ||
| t.true(await fs.pathExists(path.join(outputDirectory, 'MyAppSetup.exe'))); | ||
|
|
||
| if (process.platform === 'win32') { | ||
|
|
@@ -38,4 +43,33 @@ test('creates a nuget package and installer', async (t): Promise<void> => { | |
|
|
||
| log('Verifying Update.exe'); | ||
| t.true(await fs.pathExists(path.join(appDirectory, 'Squirrel.exe'))); | ||
|
|
||
| log('Verifying contents of .nupkg'); | ||
|
|
||
| const packageContents = await spawn7z(['l', nupkgPath]); | ||
|
|
||
| t.true(packageContents.includes('lib\\net45\\vk_swiftshader_icd.json')); | ||
| t.true(packageContents.includes('lib\\net45\\swiftshader\\libEGL.dll')); | ||
|
Comment on lines
+44
to
+53
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice if there was a test that didn't add the swiftshader files as well, to prevent regressions.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, I'll take a stab at it!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I encountered an issue where the two tests caused a race condition trying to delete the |
||
| }); | ||
|
|
||
| test('creates an installer when swiftshader files are missing', async (t): Promise<void> => { | ||
| const appDirectory = await createTempAppDirectory(); | ||
| const outputDirectory = await createTempDir('ei-'); | ||
|
niik marked this conversation as resolved.
Outdated
|
||
| const options = { appDirectory, outputDirectory }; | ||
|
|
||
| // Remove swiftshader folder and swiftshader json file, simulating Electron < 10.0 | ||
| await fs.remove(path.join(appDirectory, 'swiftshader', 'libEGL.dll')); | ||
| await fs.remove(path.join(appDirectory, 'swiftshader', 'libGLESv2.dll')); | ||
| await fs.rmdir(path.join(appDirectory, 'swiftshader')); | ||
| await fs.remove(path.join(appDirectory, 'vk_swiftshader_icd.json')); | ||
|
|
||
| await createWindowsInstaller(options); | ||
|
|
||
| const nupkgPath = path.join(outputDirectory, 'myapp-1.0.0-full.nupkg'); | ||
|
|
||
| log('Verifying contents of .nupkg'); | ||
|
|
||
| const packageContents = await spawn7z(['l', nupkgPath]); | ||
| t.false(packageContents.includes('vk_swiftshader_icd.json')); | ||
| t.false(packageContents.includes('swiftshader\\')); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally I'd ask to refactor this to look a bit more like how it's done elsewhere in the module (I do not agree with multi-line ternary statements), but I have a PR to drastically refactor how
spawnworks in #373 so it's kind of a moot point.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I tried to stay true to the current coding style but old habits die hard, I'll extract the wine binary name into a variable.