-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #410 from cosmos/fabo/25-e2e-new
Test build executables
- Loading branch information
Showing
11 changed files
with
820 additions
and
285 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
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,17 @@ | ||
// on windows some processes are not exiting when using child.kill so we use a windows specific comand | ||
module.exports.cleanExitChild = function (child) { | ||
return new Promise((resolve, reject) => { | ||
var isWin = /^win/.test(process.platform) | ||
if (!isWin) { | ||
child.kill('SIGTERM') | ||
} else { | ||
var cp = require('child_process') | ||
cp.exec('taskkill /PID ' + child.pid + ' /T /F', function (error, stdout, stderr) { | ||
if (error !== null) { | ||
console.log('exec error: ' + error) | ||
} | ||
}) | ||
} | ||
child.on('exit', resolve) | ||
}) | ||
} |
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,50 @@ | ||
const spawn = require('child_process').spawn | ||
const {cleanExitChild} = require('./common.js') | ||
|
||
function test (executablePath) { | ||
return new Promise(async (resolve, reject) => { | ||
let child | ||
try { | ||
child = spawn(executablePath, { | ||
env: { | ||
ELECTRON_ENABLE_LOGGING: 'true' | ||
} | ||
}) | ||
|
||
child.stdout.pipe(process.stdout) | ||
|
||
child.stdout.on('data', async data => { | ||
let msg = new Buffer(data, 'utf-8').toString() | ||
if (msg.indexOf('[START SUCCESS]') !== -1) { | ||
clearTimeout(wait) | ||
await cleanExitChild(child) | ||
resolve() | ||
} | ||
}) | ||
|
||
let wait = setTimeout(async () => { | ||
await cleanExitChild(child) | ||
reject() | ||
}, 5000) | ||
} catch (err) { | ||
await cleanExitChild(child) | ||
console.error('Unexpected error', err) | ||
reject(err) | ||
} | ||
}) | ||
} | ||
|
||
async function main () { | ||
let executablePath = process.argv[2] | ||
|
||
if (!executablePath) { | ||
console.error('\nPlease define the executable you want to test like "yarn run test:exe ./Cosmos.exe"\n') | ||
process.exit(-1) | ||
} | ||
await test(executablePath) | ||
.then(() => console.log(executablePath, 'starts as expected')) | ||
.catch(() => console.error(executablePath, 'did not start as expected')) | ||
} | ||
|
||
main() | ||
|
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
Oops, something went wrong.