diff --git a/cli/lib/tasks/verify.js b/cli/lib/tasks/verify.js index 6b24f53aed..48830022aa 100644 --- a/cli/lib/tasks/verify.js +++ b/cli/lib/tasks/verify.js @@ -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, } diff --git a/scripts/binary/smoke.coffee b/scripts/binary/smoke.coffee index fdd77f358b..8bffae9bfa 100644 --- a/scripts/binary/smoke.coffee +++ b/scripts/binary/smoke.coffee @@ -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