forked from mongodb-js/compass
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(e2e): smoketest macOS .dmg files COMPASS-8709 (mongodb-js#6582)
* run smoketests on mac * promisified async spawn helper rather * the app might already exist * try and preserve permissions * print args * we seem to need that * basic test * all the webdriver logs * really enable chromedriver's verbose logging * MOAR log output * remove settings dir before starting * comment for clarification * run this on the GUI machines * ignore hadron-build-info.json * comments
- Loading branch information
Showing
10 changed files
with
218 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
fixtures | ||
.nyc_output | ||
coverage | ||
hadron-build-info.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { spawn } from 'child_process'; | ||
import type { SpawnOptions } from 'child_process'; | ||
|
||
export function execute( | ||
command: string, | ||
args: string[], | ||
options?: SpawnOptions | ||
): Promise<void> { | ||
return new Promise((resolve, reject) => { | ||
console.log(command, ...args); | ||
const p = spawn(command, args, { | ||
stdio: 'inherit', | ||
...options, | ||
}); | ||
p.on('error', (err: any) => { | ||
reject(err); | ||
}); | ||
p.on('close', (code: number | null, signal: NodeJS.Signals | null) => { | ||
if (code !== null) { | ||
if (code === 0) { | ||
resolve(); | ||
} else { | ||
reject( | ||
new Error(`${command} ${args.join(' ')} exited with code ${code}`) | ||
); | ||
} | ||
} else { | ||
if (signal !== null) { | ||
reject( | ||
new Error( | ||
`${command} ${args.join(' ')} exited with signal ${signal}` | ||
) | ||
); | ||
} else { | ||
// shouldn't happen | ||
reject( | ||
new Error( | ||
`${command} ${args.join(' ')} exited with no code or signal` | ||
) | ||
); | ||
} | ||
} | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import path from 'path'; | ||
import { existsSync } from 'fs'; | ||
import type { InstalledAppInfo, Package } from './types'; | ||
import { execute } from './helpers'; | ||
|
||
export async function installMacDMG( | ||
appName: string, | ||
{ filepath }: Package | ||
): Promise<InstalledAppInfo> { | ||
const fullDestinationPath = `/Applications/${appName}.app`; | ||
|
||
if (existsSync(fullDestinationPath)) { | ||
// Would ideally just throw here, but unfortunately in CI the mac | ||
// environments aren't all clean so somewhere we have to remove it anyway. | ||
console.log(`${fullDestinationPath} already exists. Removing.`); | ||
await execute('rm', ['-rf', fullDestinationPath]); | ||
} | ||
|
||
await execute('hdiutil', ['attach', filepath]); | ||
try { | ||
await execute('cp', [ | ||
'-Rp', | ||
`/Volumes/${appName}/${appName}.app`, | ||
'/Applications', | ||
]); | ||
} finally { | ||
await execute('hdiutil', ['detach', `/Volumes/${appName}`]); | ||
} | ||
|
||
// see if the executable will run without being quarantined or similar | ||
await execute(`/Applications/${appName}.app/Contents/MacOS/${appName}`, [ | ||
'--version', | ||
]); | ||
|
||
if (process.env.HOME) { | ||
const settingsDir = path.resolve( | ||
process.env.HOME, | ||
'Library', | ||
'Application Support', | ||
appName | ||
); | ||
|
||
if (existsSync(settingsDir)) { | ||
console.log(`${settingsDir} already exists. Removing.`); | ||
await execute('rm', ['-rf', settingsDir]); | ||
} | ||
} | ||
|
||
return Promise.resolve({ | ||
appName, | ||
appPath: `/Applications/${appName}.app`, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export type Package = { | ||
filename: string; | ||
filepath: string; | ||
}; | ||
|
||
export type InstalledAppInfo = { | ||
appName: string; | ||
appPath: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters