Specify ATOM_HOME when starting Atom in integration test

Otherwise, tests may fail because the Welcome pane may appear,
depending on the content of `~/.atom/config.cson`
This commit is contained in:
Max Brunsfeld
2015-02-07 21:49:15 -08:00
parent 56a4e6b7bf
commit 6bfe3bf3b4
4 changed files with 36 additions and 21 deletions

View File

@@ -0,0 +1,5 @@
"*":
welcome:
showOnStartup: false
"exception-reporting":
userId: "7c0a3c52-795c-5e20-5323-64efcf91f212"

View File

@@ -1,12 +1,15 @@
#!/bin/bash
# This script wraps the `Atom` binary, allowing the `chromedriver` server to
# execute it with positional arguments. `chromedriver` only allows 'switches'
# to be specified when starting a browser, not positional arguments, so this
# script accepts two special switches:
# execute it with positional arguments and environment variables. `chromedriver`
# only allows 'switches' to be specified when starting a browser, not positional
# arguments, so this script accepts the following special switches:
#
# * `atom-path` The path to the `Atom` binary
# * `atom-args` A space-separated list of positional arguments to pass to Atom.
# * `atom-path`: The path to the `Atom` binary.
# * `atom-arg`: A positional argument to pass to Atom. This flag can be specified
# multiple times.
# * `atom-env`: A key=value environment variable to set for Atom. This flag can
# be specified multiple times.
#
# Any other switches will be passed through to `Atom`.
@@ -20,11 +23,12 @@ for arg in "$@"; do
atom_path="${arg#*=}"
;;
--atom-args=*)
atom_args_string="${arg#*=}"
for atom_arg in $atom_args_string; do
atom_args+=($atom_arg)
done
--atom-arg=*)
atom_args+=(${arg#*=})
;;
--atom-env=*)
export ${arg#*=}
;;
*)
@@ -33,4 +37,7 @@ for arg in "$@"; do
esac
done
exec $atom_path "${atom_switches[@]}" "${atom_args[@]}"
echo "Launching Atom" >&2
echo ${atom_path} ${atom_args[@]} ${atom_switches[@]} >&2
exec ${atom_path} ${atom_args[@]} ${atom_switches[@]}

View File

@@ -2,6 +2,7 @@ os = require "os"
path = require "path"
temp = require("temp").track()
remote = require "remote"
{map, extend} = require "underscore-plus"
{spawn, spawnSync} = require "child_process"
webdriverio = require "../../../build/node_modules/webdriverio"
async = require "async"
@@ -39,7 +40,7 @@ module.exports =
runs -> chromedriver.kill()
# Start Atom using chromedriver.
startAtom: (args...) ->
startAtom: (args, env={}) ->
webdriverio.remote(
host: 'localhost'
port: ChromedriverPort
@@ -49,12 +50,13 @@ module.exports =
binary: AtomLauncherPath
args: [
"atom-path=#{AtomPath}"
"atom-args=#{args.join(" ")}"
"dev"
"safe"
"user-data-dir=#{temp.mkdirSync('integration-spec-')}"
"socket-path=#{SocketPath}"
])
]
.concat(map args, (arg) -> "atom-arg=#{arg}")
.concat(map env, (value, key) -> "atom-env=#{key}=#{value}"))
.init()
.addCommand "waitForCondition", (conditionFn, timeout, cb) ->
timedOut = succeeded = false
@@ -78,9 +80,9 @@ module.exports =
# Once one `Atom` window is open, subsequent invocations of `Atom` will exit
# immediately.
startAnotherAtom: (args...) ->
startAnotherAtom: (args, env={}) ->
spawnSync(AtomPath, args.concat([
"--dev",
"--safe",
"--dev"
"--safe"
"--socket-path=#{SocketPath}"
]))
]), env: extend({}, process.env, env))

View File

@@ -6,6 +6,7 @@ return unless process.env.ATOM_INTEGRATION_TESTS_ENABLED
fs = require "fs"
path = require "path"
temp = require("temp").track()
AtomHome = path.join(__dirname, "fixtures", "atom-home")
{startAtom, startAnotherAtom, driverTest} = require("./helpers/start-atom")
describe "Starting Atom", ->
@@ -24,7 +25,7 @@ describe "Starting Atom", ->
driverTest ->
# Opening a new file creates one window with one empty text editor.
startAtom(path.join(tempDirPath, "new-file"))
startAtom([path.join(tempDirPath, "new-file")], ATOM_HOME: AtomHome)
.waitForExist("atom-text-editor", 5000)
.then((exists) -> expect(exists).toBe true)
.windowHandles()
@@ -42,7 +43,7 @@ describe "Starting Atom", ->
# Opening an existing file in the same directory reuses the window and
# adds a new tab for the file.
.call(-> startAnotherAtom(tempFilePath))
.call(-> startAnotherAtom([tempFilePath], ATOM_HOME: AtomHome))
.waitForCondition(
(-> @execute((-> atom.workspace.getActivePane().getItems().length)).then ({value}) -> value is 2),
5000)
@@ -52,7 +53,7 @@ describe "Starting Atom", ->
# Opening a different directory creates a second window with no
# tabs open.
.call(-> startAnotherAtom(temp.mkdirSync("another-empty-dir")))
.call(-> startAnotherAtom([temp.mkdirSync("another-empty-dir")], ATOM_HOME: AtomHome))
.waitForCondition(
(-> @windowHandles().then(({value}) -> value.length is 2)),
5000)