add sandbox argument to [build binary] (#5197)

* add sandbox argument to [build binary]

* relative path

* ughh [build binary]
This commit is contained in:
Gleb Bahmutov
2019-09-25 08:03:03 -04:00
committed by Brian Mann
parent eaff40b499
commit 73e3c7c346
2 changed files with 19 additions and 7 deletions

View File

@@ -72,10 +72,6 @@ const runSmokeTest = (binaryDir, options) => {
debug('needs Xvfb?', needsXvfb)
const isLinuxLike = () => process.platform !== 'win32'
const isRootUser = () => process.geteuid() === 0
/**
* Spawn Cypress running smoke test to check if all operating system
* dependencies are good.
@@ -84,7 +80,7 @@ const runSmokeTest = (binaryDir, options) => {
const random = _.random(0, 1000)
const args = ['--smoke-test', `--ping=${random}`]
if (isLinuxLike() && isRootUser()) {
if (needsSandbox()) {
// electron requires --no-sandbox to run as root
args.unshift('--no-sandbox')
}
@@ -360,7 +356,18 @@ const start = (options = {}) => {
})
}
const isLinuxLike = () => process.platform !== 'win32'
const isRootUser = () => process.geteuid() === 0
/**
* Returns true if running on a system where Electron needs "--no-sandbox" flag.
* @see https://crbug.com/638180
*/
const needsSandbox = () => isLinuxLike() && isRootUser()
module.exports = {
start,
VERIFY_TEST_RUNNER_TIMEOUT_MS,
needsSandbox,
}

View File

@@ -5,6 +5,7 @@ execa = require('execa')
path = require("path")
Promise = require("bluebird")
os = require("os")
verify = require("../../cli/lib/tasks/verify")
Fixtures = require("../../packages/server/test/support/helpers/fixtures")
fs = Promise.promisifyAll(fse)
@@ -16,7 +17,7 @@ shouldSkipProjectTest = () ->
os.platform() == "win32"
runSmokeTest = (buildAppExecutable) ->
rand = "" + Math.random()
rand = String(_.random(0, 1000))
console.log("executable path #{buildAppExecutable}")
hasRightResponse = (stdout) ->
@@ -25,7 +26,11 @@ runSmokeTest = (buildAppExecutable) ->
lines = stdout.split('\n').map((s) -> s.trim())
return lines.includes(rand)
execa "#{buildAppExecutable}", ["--smoke-test", "--ping=#{rand}"], {timeout: 10000}
args = ["--smoke-test", "--ping=#{rand}"]
if verify.needsSandbox()
args.push("--no-sandbox")
execa "#{buildAppExecutable}", args, {timeout: 10000}
.catch (err) ->
console.error("smoke test failed with error %s", err.message)
throw err