Comparar commits

...

12 Commits

Autor SHA1 Mensagem Data
Max Brunsfeld 6430bbb460 Wait for chromedriver's startup message on stdout 2015-02-05 22:40:17 -08:00
Max Brunsfeld 362ff963fd ⬆️ grunt-download-atom-shell 2015-02-05 13:07:05 -08:00
Max Brunsfeld 61ca2e14dc Run integration tests on CI 2015-02-05 13:02:25 -08:00
Max Brunsfeld 56677e71e4 Enable integration tests with environment var
I think this makes more sense then running them via a separate command,
since that command would only make sense for atom-core, unlike the
current 'run-package-specs' command, which works for any atom package.

This way, they won't run by default, but you can opt in to running them
on the command line by setting an env var, or in the spec runner by
temporarily editing the code, like we do for focused tests anyway.
2015-02-05 13:02:08 -08:00
Max Brunsfeld c927101bb2 Download chromedriver along with atom-shell 2015-02-05 12:59:48 -08:00
Max Brunsfeld 28f280183e Use which(1), not bash's type function 2015-02-04 15:22:51 -08:00
Max Brunsfeld f1df254a66 Use varargs in integration-test helper fn 2015-02-04 15:20:44 -08:00
Max Brunsfeld af28083a6f Add integration test coverage for reusing windows w/ the same dir 2015-02-04 15:07:08 -08:00
Max Brunsfeld 495caa7316 🎨 Rename DEFAULT_SOCKET_PATH -> DefaultSocketPath 2015-02-04 13:12:41 -08:00
Max Brunsfeld d0757c87c8 Move selenium-webdriver dependency to build/package.json 2015-02-04 13:11:33 -08:00
Max Brunsfeld c19d99e9e2 Add integration test for starting atom w/ different arguments 2015-02-04 12:59:26 -08:00
Max Brunsfeld ab43b08739 Add hidden --socket-path flag
This will allow integration tests to control which atom application
instance they use when creating atom windows
2015-02-04 11:47:29 -08:00
8 arquivos alterados com 174 adições e 13 exclusões
+2 -2
Ver Arquivo
@@ -222,7 +222,7 @@ module.exports = (grunt) ->
grunt.registerTask('test', ['shell:kill-atom', 'run-specs'])
grunt.registerTask('docs', ['markdown:guides', 'build-docs'])
ciTasks = ['output-disk-space', 'download-atom-shell', 'build']
ciTasks = ['output-disk-space', 'download-atom-shell', 'download-atom-shell-chromedriver', 'build']
ciTasks.push('dump-symbols') if process.platform isnt 'win32'
ciTasks.push('set-version', 'check-licenses', 'lint')
ciTasks.push('mkdeb') if process.platform is 'linux'
@@ -232,6 +232,6 @@ module.exports = (grunt) ->
ciTasks.push('publish-build')
grunt.registerTask('ci', ciTasks)
defaultTasks = ['download-atom-shell', 'build', 'set-version']
defaultTasks = ['download-atom-shell', 'download-atom-shell-chromedriver', 'build', 'set-version']
defaultTasks.push 'install' unless process.platform is 'linux'
grunt.registerTask('default', defaultTasks)
+2 -1
Ver Arquivo
@@ -19,7 +19,7 @@
"grunt-contrib-csslint": "~0.1.2",
"grunt-contrib-less": "~0.8.0",
"grunt-cson": "0.14.0",
"grunt-download-atom-shell": "~0.11.0",
"grunt-download-atom-shell": "~0.12.0",
"grunt-lesslint": "0.13.0",
"grunt-peg": "~1.1.0",
"grunt-shell": "~0.3.1",
@@ -31,6 +31,7 @@
"request": "~2.27.0",
"rimraf": "~2.2.2",
"runas": "~1.0.1",
"selenium-webdriver": "^2.44.0",
"tello": "1.0.4",
"temp": "~0.8.1",
"underscore-plus": "1.x",
+12
Ver Arquivo
@@ -85,15 +85,27 @@ module.exports = (grunt) ->
appPath = getAppPath()
resourcePath = process.cwd()
coreSpecsPath = path.resolve('spec')
chromedriverPath = path.join(resourcePath, "atom-shell", "chromedriver")
if process.platform in ['darwin', 'linux']
options =
cmd: appPath
args: ['--test', "--resource-path=#{resourcePath}", "--spec-directory=#{coreSpecsPath}"]
opts:
env: _.extend({}, process.env,
ATOM_INTEGRATION_TESTS_ENABLED: true
PATH: [process.env.path, chromedriverPath].join(":")
)
else if process.platform is 'win32'
options =
cmd: process.env.comspec
args: ['/c', appPath, '--test', "--resource-path=#{resourcePath}", "--spec-directory=#{coreSpecsPath}", "--log-file=ci.log"]
opts:
env: _.extend({}, process.env,
ATOM_INTEGRATION_TESTS_ENABLED: true
PATH: [process.env.path, chromedriverPath].join(";")
)
spawn options, (error, results, code) ->
if process.platform is 'win32'
+36
Ver Arquivo
@@ -0,0 +1,36 @@
#!/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:
#
# * `atom-path` The path to the `Atom` binary
# * `atom-args` A space-separated list of positional arguments to pass to Atom.
#
# Any other switches will be passed through to `Atom`.
atom_path=""
atom_switches=()
atom_args=()
for arg in "$@"; do
case $arg in
--atom-path=*)
atom_path="${arg#*=}"
;;
--atom-args=*)
atom_args_string="${arg#*=}"
for atom_arg in $atom_args_string; do
atom_args+=($atom_arg)
done
;;
*)
atom_switches+=($arg)
;;
esac
done
exec $atom_path "${atom_switches[@]}" "${atom_args[@]}"
+107
Ver Arquivo
@@ -0,0 +1,107 @@
# These tests are excluded by default. To run them from the command line:
#
# ATOM_INTEGRATION_TESTS_ENABLED=true apm test
return unless process.env.ATOM_INTEGRATION_TESTS_ENABLED
os = require "os"
fs = require "fs"
path = require "path"
remote = require "remote"
temp = require("temp").track()
{spawn, spawnSync} = require "child_process"
{Builder, By} = require "../../build/node_modules/selenium-webdriver"
AtomPath = remote.process.argv[0]
AtomLauncherPath = path.join(__dirname, "helpers", "atom-launcher.sh")
SocketPath = path.join(os.tmpdir(), "atom-integration-test.sock")
ChromeDriverPort = 9515
describe "Starting Atom", ->
[chromeDriver, driver, tempDirPath] = []
beforeEach ->
tempDirPath = temp.mkdirSync("empty-dir")
waitsFor "chromedriver to start", (done) ->
chromeDriver = spawn "chromedriver", ["--verbose", "--port=#{ChromeDriverPort}"]
chromeDriver.on "error", (error) ->
throw new Error("chromedriver failed to start: #{error.message}")
chromeDriver.stdout.on "data", -> done()
afterEach ->
waitsForPromise -> driver.quit().thenFinally(-> chromeDriver.kill())
startAtom = (args...) ->
driver = new Builder()
.usingServer("http://localhost:#{ChromeDriverPort}")
.withCapabilities(
chromeOptions:
binary: AtomLauncherPath
args: [
"atom-path=#{AtomPath}"
"atom-args=#{args.join(" ")}"
"dev"
"safe"
"user-data-dir=#{temp.mkdirSync('integration-spec-')}"
"socket-path=#{SocketPath}"
]
)
.forBrowser('atom')
.build()
waitsForPromise ->
driver.wait ->
driver.getTitle().then (title) -> title.indexOf("Atom") >= 0
startAnotherAtom = (args...) ->
spawnSync(AtomPath, args.concat([
"--dev",
"--safe",
"--socket-path=#{SocketPath}"
]))
describe "when given the name of a file that doesn't exist", ->
tempFilePath = null
beforeEach ->
tempFilePath = path.join(tempDirPath, "an-existing-file")
fs.writeFileSync(tempFilePath, "This was already here.")
startAtom(path.join(tempDirPath, "new-file"))
it "opens a new window with an empty text editor", ->
waitsForPromise ->
driver.getAllWindowHandles().then (handles) ->
expect(handles.length).toBe 1
driver.executeScript(-> atom.workspace.getActivePane().getItems().length).then (length) ->
expect(length).toBe 1
driver.executeScript(-> atom.workspace.getActiveTextEditor().getText()).then (text) ->
expect(text).toBe("")
driver.findElement(By.tagName("atom-text-editor")).sendKeys("Hello world!")
driver.executeScript(-> atom.workspace.getActiveTextEditor().getText()).then (text) ->
expect(text).toBe "Hello world!"
# Opening another existing file in the same directory reuses the window,
# and opens a new tab for the file.
waitsForPromise ->
startAnotherAtom(tempFilePath)
driver.wait ->
driver.executeScript(-> atom.workspace.getActivePane().getItems().length).then (length) ->
length is 2
driver.executeScript(-> atom.workspace.getActiveTextEditor().getText()).then (text) ->
expect(text).toBe "This was already here."
# Opening a different directory creates a new window.
waitsForPromise ->
startAnotherAtom(temp.mkdirSync("another-empty-dir"))
driver.wait ->
driver.getAllWindowHandles().then (handles) ->
handles.length is 2
describe "when given the name of a directory that exists", ->
beforeEach ->
startAtom(tempDirPath)
it "opens a new window no text editors open", ->
waitsForPromise ->
driver.executeScript(-> atom.workspace.getActiveTextEditor()).then (editor) ->
expect(editor).toBeNull()
+2 -2
Ver Arquivo
@@ -305,13 +305,13 @@ window.waitsForPromise = (args...) ->
window.waitsFor timeout, (moveOn) ->
promise = fn()
if shouldReject
promise.catch(moveOn)
(promise.catch ? promise.thenCatch).call(promise, moveOn)
promise.then ->
jasmine.getEnv().currentSpec.fail("Expected promise to be rejected, but it was resolved")
moveOn()
else
promise.then(moveOn)
promise.catch (error) ->
(promise.catch ? promise.thenCatch).call promise, (error) ->
jasmine.getEnv().currentSpec.fail("Expected promise to be resolved, but it was rejected with #{jasmine.pp(error)}")
moveOn()
+10 -7
Ver Arquivo
@@ -14,7 +14,7 @@ url = require 'url'
{EventEmitter} = require 'events'
_ = require 'underscore-plus'
socketPath =
DefaultSocketPath =
if process.platform is 'win32'
'\\\\.\\pipe\\atom-sock'
else
@@ -31,17 +31,20 @@ class AtomApplication
# Public: The entry point into the Atom application.
@open: (options) ->
options.socketPath ?= DefaultSocketPath
createAtomApplication = -> new AtomApplication(options)
# FIXME: Sometimes when socketPath doesn't exist, net.connect would strangely
# take a few seconds to trigger 'error' event, it could be a bug of node
# or atom-shell, before it's fixed we check the existence of socketPath to
# speedup startup.
if (process.platform isnt 'win32' and not fs.existsSync socketPath) or options.test
if (process.platform isnt 'win32' and not fs.existsSync options.socketPath) or options.test
createAtomApplication()
return
client = net.connect {path: socketPath}, ->
client = net.connect {path: options.socketPath}, ->
client.write JSON.stringify(options), ->
client.end()
app.terminate()
@@ -57,7 +60,7 @@ class AtomApplication
exit: (status) -> app.exit(status)
constructor: (options) ->
{@resourcePath, @version, @devMode, @safeMode} = options
{@resourcePath, @version, @devMode, @safeMode, @socketPath} = options
# Normalize to make sure drive letter case is consistent on Windows
@resourcePath = path.normalize(@resourcePath) if @resourcePath
@@ -119,15 +122,15 @@ class AtomApplication
connection.on 'data', (data) =>
@openWithOptions(JSON.parse(data))
server.listen socketPath
server.listen @socketPath
server.on 'error', (error) -> console.error 'Application server failed', error
deleteSocketFile: ->
return if process.platform is 'win32'
if fs.existsSync(socketPath)
if fs.existsSync(@socketPath)
try
fs.unlinkSync(socketPath)
fs.unlinkSync(@socketPath)
catch error
# Ignore ENOENT errors in case the file was deleted between the exists
# check and the call to unlink sync. This occurred occasionally on CI
+3 -1
Ver Arquivo
@@ -120,6 +120,7 @@ parseCommandLine = ->
options.alias('t', 'test').boolean('t').describe('t', 'Run the specified specs and exit with error code on failures.')
options.alias('v', 'version').boolean('v').describe('v', 'Print the version.')
options.alias('w', 'wait').boolean('w').describe('w', 'Wait for window to be closed before returning.')
options.string('socket-path')
args = options.argv
if args.help
@@ -140,6 +141,7 @@ parseCommandLine = ->
newWindow = args['new-window']
pidToKillWhenClosed = args['pid'] if args['wait']
logFile = args['log-file']
socketPath = args['socket-path']
if args['resource-path']
devMode = true
@@ -164,6 +166,6 @@ parseCommandLine = ->
# explicitly pass it by command line, see http://git.io/YC8_Ew.
process.env.PATH = args['path-environment'] if args['path-environment']
{resourcePath, pathsToOpen, executedFrom, test, version, pidToKillWhenClosed, devMode, safeMode, newWindow, specDirectory, logFile}
{resourcePath, pathsToOpen, executedFrom, test, version, pidToKillWhenClosed, devMode, safeMode, newWindow, specDirectory, logFile, socketPath}
start()