mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-21 22:50:49 -06:00
Windows support (#484)
* try installing on Windows * Handle windows setup - no browser detection on windows yet, just placeholder code - symlink types * add appveyor file * add appveyor windows build * use execa to run server unit tests * run server unit tests on appveyor * ignore root install errors * upgrade rebuild-node-sass and work on Json unit test that fails on Windows * print npm version before installing, commented out caching node modules in the root * a few small tweaks for windows support * fix bin-up in launcher project use bin-up@1.1.0 for windows support, close #491 * cli: build script on Windows, close #492 * cli: build errors are fatal * use cross-env in extension Fixes environment variables on Windows in #490 * extension: fix 3 tests on Windows 1 more broken test remaining * extension: use EOL before comparing text * example: update test for Windows * example: replace build.sh with build.js Close #488 * remove trailing whitespace * cli: build script again * server: work on unit tests for windows * binary: add windows as build platform * windows: try building binary started work on building on CI for windows
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -37,3 +37,4 @@ cli/build
|
||||
|
||||
# Building app binary
|
||||
scripts/binary/support
|
||||
package-lock.json
|
||||
|
||||
@@ -9,6 +9,7 @@ Build status | Description
|
||||
[](https://circleci.com/gh/cypress-io/cypress-test-node-versions) | [cypress-test-example-repos](https://github.com/cypress-io/cypress-test-example-repos)
|
||||
[](https://circleci.com/gh/cypress-io/docsearch-scraper) | [docsearch-scraper](https://github.com/cypress-io/docsearch-scraper)
|
||||
[](https://hub.docker.com/r/cypress/base/) | [cypress-docker-images](https://github.com/cypress-io/cypress-docker-images)
|
||||
[](https://ci.appveyor.com/project/cypress-io/cypress-monorepo) | Windows CI
|
||||
|
||||
# Cypress
|
||||
|
||||
|
||||
29
appveyor.yml
Normal file
29
appveyor.yml
Normal file
@@ -0,0 +1,29 @@
|
||||
# https://www.appveyor.com/docs/lang/nodejs-iojs/
|
||||
# Test against the latest version of this Node.js version
|
||||
environment:
|
||||
nodejs_version: "6"
|
||||
|
||||
# https://www.appveyor.com/docs/build-cache/
|
||||
# cache:
|
||||
# - node_modules
|
||||
|
||||
# Install scripts. (runs after repo cloning)
|
||||
install:
|
||||
- ps: Install-Product node $env:nodejs_version
|
||||
# Output useful info for debugging.
|
||||
- node --version
|
||||
- npm --version
|
||||
# install root modules
|
||||
- npm install
|
||||
|
||||
# Post-install test scripts.
|
||||
test_script:
|
||||
# Output useful info for debugging.
|
||||
- node --version
|
||||
- npm --version
|
||||
- npm run binary-build -- --platform windows --version 0.20.2-win
|
||||
# - cd packages/server && npm run test-unit
|
||||
# - npm test
|
||||
|
||||
# Don't actually build.
|
||||
build: off
|
||||
@@ -11,12 +11,12 @@
|
||||
},
|
||||
"scripts": {
|
||||
"test": "npm run test-unit",
|
||||
"test-unit": "$(bin-up mocha) --reporter mocha-multi-reporters --reporter-options configFile=../mocha-reporter-config.json",
|
||||
"test-watch": "$(bin-up mocha) --watch",
|
||||
"test-dependencies": "$(bin-up deps-ok) && dependency-check . --no-dev",
|
||||
"test-unit": "bin-up mocha --reporter mocha-multi-reporters --reporter-options configFile=../mocha-reporter-config.json",
|
||||
"test-watch": "bin-up mocha --watch",
|
||||
"test-dependencies": "bin-up deps-ok && dependency-check . --no-dev",
|
||||
"test-debug": "node --inspect --debug-brk $(bin-up _mocha)",
|
||||
"lint": "$(bin-up eslint) --fix *.js bin/* lib/*.js lib/**/*.js test/*.js test/**/*.js",
|
||||
"prebuild": "npm run test-dependencies && ./scripts/build.sh",
|
||||
"lint": "bin-up eslint --fix *.js bin/* lib/*.js lib/**/*.js test/*.js test/**/*.js",
|
||||
"prebuild": "npm run test-dependencies && node ./scripts/start-build.js",
|
||||
"build": "node ./scripts/build.js",
|
||||
"prerelease": "npm run build",
|
||||
"release": "cd build && releaser --no-node --no-changelog",
|
||||
@@ -52,12 +52,13 @@
|
||||
"@cypress/sinon-chai": "1.0.0",
|
||||
"babel-cli": "^6.24.1",
|
||||
"babel-preset-es2015": "^6.24.1",
|
||||
"bin-up": "^1.0.1",
|
||||
"bin-up": "^1.1.0",
|
||||
"chai": "^3.5.0",
|
||||
"clear-module": "^2.1.0",
|
||||
"dependency-check": "^2.8.0",
|
||||
"execa-wrap": "1.1.0",
|
||||
"nock": "^9.0.9",
|
||||
"shelljs": "0.7.8",
|
||||
"sinon": "3.2.1",
|
||||
"snap-shot-it": "4.0.0",
|
||||
"strip-ansi": "4.0.0"
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
## clean out build
|
||||
rm -rf build
|
||||
|
||||
## copy over binary
|
||||
mkdir -p build/bin
|
||||
cp bin/cypress build/bin/cypress
|
||||
|
||||
## copy readme
|
||||
cp NPM_README.md build/README.md
|
||||
|
||||
## copy .release.json
|
||||
cp .release.json build/.release.json
|
||||
|
||||
## generate babel'd js index + lib
|
||||
babel lib -d build/lib && babel index.js -o build/index.js
|
||||
15
cli/scripts/start-build.js
Executable file
15
cli/scripts/start-build.js
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const shell = require('shelljs')
|
||||
|
||||
shell.set('-v') // verbose
|
||||
shell.set('-e') // any error is fatal
|
||||
|
||||
shell.rm('-rf', 'build')
|
||||
shell.mkdir('-p', 'build/bin')
|
||||
shell.cp('bin/cypress', 'build/bin/cypress')
|
||||
shell.cp('NPM_README.md', 'build/README.md')
|
||||
shell.cp('.release.json', 'build/.release.json')
|
||||
|
||||
shell.exec('babel lib -d build/lib')
|
||||
shell.exec('babel index.js -o build/index.js')
|
||||
@@ -11,6 +11,5 @@
|
||||
"scripts": {
|
||||
"test": "echo 'Nothing to test for the coffee package'"
|
||||
},
|
||||
"devDependencies": {
|
||||
}
|
||||
"devDependencies": {}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ Promise = require("bluebird")
|
||||
minimist = require("minimist")
|
||||
paths = require("./paths")
|
||||
install = require("./install")
|
||||
log = require("debug")("cypress:electron")
|
||||
|
||||
fs = Promise.promisifyAll(fs)
|
||||
|
||||
@@ -13,10 +14,12 @@ module.exports = {
|
||||
install.check()
|
||||
|
||||
install: ->
|
||||
log("installing %j", arguments)
|
||||
install.package.apply(install, arguments)
|
||||
|
||||
cli: (argv = []) ->
|
||||
opts = minimist(argv)
|
||||
log("cli options %j", opts)
|
||||
|
||||
pathToApp = argv[0]
|
||||
|
||||
@@ -29,18 +32,26 @@ module.exports = {
|
||||
throw new Error("No path to your app was provided.")
|
||||
|
||||
open: (appPath, argv, cb) ->
|
||||
log("opening %s", appPath)
|
||||
appPath = path.resolve(appPath)
|
||||
dest = paths.getPathToResources("app")
|
||||
log("appPath %s", appPath)
|
||||
log("dest path %s", dest)
|
||||
|
||||
## make sure this path exists!
|
||||
fs.statAsync(appPath)
|
||||
.then ->
|
||||
log("appPath exists %s", appPath)
|
||||
## clear out the existing symlink
|
||||
fs.removeAsync(dest)
|
||||
.then ->
|
||||
fs.ensureSymlinkAsync(appPath, dest, "dir")
|
||||
symlinkType = paths.getSymlinkType()
|
||||
log("making symlink from %s to %s of type %s", appPath, dest, symlinkType)
|
||||
fs.ensureSymlinkAsync(appPath, dest, symlinkType)
|
||||
.then ->
|
||||
cp.spawn(paths.getPathToExec(), argv, {stdio: "inherit"})
|
||||
execPath = paths.getPathToExec()
|
||||
log("spawning %s", execPath)
|
||||
cp.spawn(execPath, argv, {stdio: "inherit"})
|
||||
.on "close", (code) ->
|
||||
if cb
|
||||
cb(code)
|
||||
|
||||
@@ -5,6 +5,7 @@ path = require("path")
|
||||
Promise = require("bluebird")
|
||||
pkg = require("../package.json")
|
||||
paths = require("./paths")
|
||||
log = require("debug")("cypress:electron")
|
||||
|
||||
fs = Promise.promisifyAll(fs)
|
||||
|
||||
@@ -54,6 +55,9 @@ module.exports = {
|
||||
pkgr = require("electron-packager")
|
||||
icons = require("@cypress/icons")
|
||||
|
||||
iconPath = icons.getPathToIcon("cypress")
|
||||
log("package icon", iconPath)
|
||||
|
||||
_.defaults(options, {
|
||||
dist: paths.getPathToDist()
|
||||
dir: "app"
|
||||
@@ -65,9 +69,10 @@ module.exports = {
|
||||
prune: true
|
||||
overwrite: true
|
||||
electronVersion
|
||||
icon: icons.getPathToIcon("cypress.icns")
|
||||
icon: iconPath
|
||||
})
|
||||
|
||||
log("packager options %j", options)
|
||||
pkgr(options)
|
||||
.then (appPaths) ->
|
||||
appPaths[0]
|
||||
|
||||
@@ -7,14 +7,14 @@ execPath = {
|
||||
darwin: "Cypress.app/Contents/MacOS/Cypress"
|
||||
freebsd: "Cypress"
|
||||
linux: "Cypress"
|
||||
# win32: "dist/Cypress.exe"
|
||||
win32: "Cypress.exe"
|
||||
}
|
||||
|
||||
resourcesPath = {
|
||||
darwin: "Cypress.app/Contents/Resources"
|
||||
freebsd: "resources"
|
||||
linux: "resources"
|
||||
# win32: "resources"
|
||||
win32: "resources"
|
||||
}
|
||||
|
||||
unknownPlatformErr = ->
|
||||
@@ -44,4 +44,9 @@ module.exports = {
|
||||
getPathToVersion: ->
|
||||
@getPathToDist("version")
|
||||
|
||||
}
|
||||
getSymlinkType: ->
|
||||
if os.platform() == "win32"
|
||||
"junction"
|
||||
else
|
||||
"dir"
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"postinstall": "echo '@packages/electron needs: npm run build'",
|
||||
"start": "./bin/cypress-electron",
|
||||
"test": "mocha --compilers coffee:@packages/coffee/register",
|
||||
"build": "./bin/cypress-electron --install",
|
||||
"build": "node ./bin/cypress-electron --install",
|
||||
"clean-deps": "rm -rf node_modules"
|
||||
},
|
||||
"bin": {
|
||||
@@ -24,8 +24,9 @@
|
||||
"mocha": "^3.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@cypress/icons": "^0.5.4",
|
||||
"@cypress/icons": "^0.6.0",
|
||||
"bluebird": "^3.4.1",
|
||||
"debug": "^3.0.1",
|
||||
"electron-packager": "9.0.1",
|
||||
"fs-extra": "^0.30.0",
|
||||
"lodash": "^4.15.0",
|
||||
|
||||
16
packages/example/bin/build.js
Normal file
16
packages/example/bin/build.js
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const shell = require('shelljs')
|
||||
|
||||
shell.set('-v') // verbose
|
||||
shell.set('-e') // any error is fatal
|
||||
|
||||
shell.rm('-rf', 'app')
|
||||
shell.mkdir('app')
|
||||
|
||||
shell.cp('-r', 'node_modules/cypress-example-kitchensink/app', '.')
|
||||
shell.rm('-rf', 'cypress')
|
||||
|
||||
shell.cp('-r', 'node_modules/cypress-example-kitchensink/cypress', '.')
|
||||
|
||||
shell.exec('node ./bin/convert.js')
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/bin/bash
|
||||
rm -rf app
|
||||
mkdir app
|
||||
cp -r node_modules/cypress-example-kitchensink/app .
|
||||
rm -rf cypress
|
||||
cp -r node_modules/cypress-example-kitchensink/cypress .
|
||||
./bin/convert.js
|
||||
gulp build
|
||||
@@ -6,12 +6,12 @@
|
||||
"scripts": {
|
||||
"postinstall": "echo '@packages/example needs: npm run build'",
|
||||
"clean-deps": "rm -rf node_modules",
|
||||
"test": "NODE_ENV=test mocha",
|
||||
"test": "cross-env NODE_ENV=test mocha",
|
||||
"test-e2e": "cypress run",
|
||||
"build": "./bin/build.sh && gulp build",
|
||||
"build": "node ./bin/build.js && gulp build",
|
||||
"predeploy": "npm run build",
|
||||
"deploy": "gulp deploy",
|
||||
"lint": "$(bin-up eslint) --fix *.js bin/*.js lib/*.js test/*.js",
|
||||
"lint": "bin-up eslint --fix *.js bin/*.js lib/*.js test/*.js",
|
||||
"pretest": "npm run lint"
|
||||
},
|
||||
"files": [
|
||||
@@ -19,8 +19,9 @@
|
||||
"lib"
|
||||
],
|
||||
"devDependencies": {
|
||||
"bin-up": "^1.0.1",
|
||||
"bin-up": "^1.1.0",
|
||||
"chai": "^3.5.0",
|
||||
"cross-env": "^5.0.5",
|
||||
"cypress-example-kitchensink": "0.8.0",
|
||||
"glob": "^7.0.3",
|
||||
"gulp": "^3.9.1",
|
||||
@@ -28,6 +29,7 @@
|
||||
"gulp-gh-pages": "^0.5.4",
|
||||
"gulp-rev-all": "^0.8.22",
|
||||
"mocha": "^2.4.5",
|
||||
"run-sequence": "^1.1.5"
|
||||
"run-sequence": "^1.1.5",
|
||||
"shelljs": "^0.7.8"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
let example = require('../index')
|
||||
let expect = require('chai').expect
|
||||
let normalize = require('path').normalize
|
||||
|
||||
let cwd = process.cwd()
|
||||
|
||||
/* global describe, it */
|
||||
describe('Cypress Example', function () {
|
||||
it('returns path to example_spec', function () {
|
||||
expect(example.getPathToExample()).to.eq(`${cwd}/cypress/integration/example_spec.js`)
|
||||
let result = example.getPathToExample()
|
||||
let expected = `${cwd}/cypress/integration/example_spec.js`
|
||||
expect(normalize(result)).to.eq(normalize(expected))
|
||||
})
|
||||
})
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"watch": "gulp watch",
|
||||
"build": "gulp build",
|
||||
"build-prod": "gulp build",
|
||||
"test": "NODE_ENV=test $(bin-up mocha) --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json",
|
||||
"test": "cross-env NODE_ENV=test bin-up mocha --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json",
|
||||
"test-watch": "npm run test -- --watch",
|
||||
"clean": "gulp clean",
|
||||
"clean-deps": "rm -rf node_modules"
|
||||
@@ -23,10 +23,12 @@
|
||||
"@cypress/core-socket": "0.1.0",
|
||||
"@cypress/icons": "0.5.4",
|
||||
"@cypress/releaser": "0.1.12",
|
||||
"bin-up": "^1.0.1",
|
||||
"bin-up": "^1.1.0",
|
||||
"browserify": "^13.0.0",
|
||||
"chai": "^3.5.0",
|
||||
"coffeeify": "^2.0.1",
|
||||
"cross-env": "^5.0.5",
|
||||
"eol": "^0.9.1",
|
||||
"fs-extra": "^0.26.7",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-clean": "^0.3.2",
|
||||
|
||||
@@ -3,6 +3,7 @@ require("../spec_helper")
|
||||
fs = require("fs-extra")
|
||||
path = require("path")
|
||||
Promise = require("bluebird")
|
||||
eol = require("eol")
|
||||
extension = require("../../index")
|
||||
cwd = process.cwd()
|
||||
|
||||
@@ -21,14 +22,20 @@ describe "Extension", ->
|
||||
|
||||
context ".getPathToExtension", ->
|
||||
it "returns path to dist", ->
|
||||
expect(extension.getPathToExtension()).to.eq(cwd + "/dist")
|
||||
result = extension.getPathToExtension()
|
||||
expected = path.join(cwd, "dist")
|
||||
expect(path.normalize(result)).to.eq(path.normalize(expected))
|
||||
|
||||
it "returns path to files in dist", ->
|
||||
expect(extension.getPathToExtension("background.js")).to.eq(cwd + "/dist/background.js")
|
||||
result = extension.getPathToExtension("background.js")
|
||||
expected = path.join(cwd, "/dist/background.js")
|
||||
expect(path.normalize(result)).to.eq(path.normalize(expected))
|
||||
|
||||
context ".getPathToTheme", ->
|
||||
it "returns path to theme", ->
|
||||
expect(extension.getPathToTheme()).to.eq(cwd + "/theme")
|
||||
result = extension.getPathToTheme()
|
||||
expected = path.join(cwd, "theme")
|
||||
expect(path.normalize(result)).to.eq(path.normalize(expected))
|
||||
|
||||
context ".getPathToRoot", ->
|
||||
it "returns path to root", ->
|
||||
@@ -44,7 +51,8 @@ describe "Extension", ->
|
||||
it "rewrites the background.js source", ->
|
||||
extension.setHostAndPath("http://dev.local:8080", "/__foo")
|
||||
.then (str) ->
|
||||
expect(str).to.eq """
|
||||
result = eol.auto(str)
|
||||
expected = eol.auto """
|
||||
(function() {
|
||||
var HOST, PATH, automation, client, fail, invoke,
|
||||
slice = [].slice;
|
||||
@@ -69,6 +77,7 @@ describe "Extension", ->
|
||||
}).call(this);
|
||||
|
||||
"""
|
||||
expect(result).to.eq(expected)
|
||||
|
||||
it "does not mutate background.js", ->
|
||||
fs.readFileAsync(@src, "utf8")
|
||||
|
||||
@@ -39,9 +39,11 @@ export function detectBrowserDarwin(browser: Browser) {
|
||||
return detectBrowserLinux(browser)
|
||||
}
|
||||
|
||||
return fn().then(merge({ name: browser.name })).catch(() => {
|
||||
log('could not detect %s using traditional Mac methods', browser.name)
|
||||
log('trying linux search')
|
||||
return detectBrowserLinux(browser)
|
||||
})
|
||||
return fn()
|
||||
.then(merge({ name: browser.name }))
|
||||
.catch(() => {
|
||||
log('could not detect %s using traditional Mac methods', browser.name)
|
||||
log('trying linux search')
|
||||
return detectBrowserLinux(browser)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { detectBrowserLinux } from './linux'
|
||||
import { detectBrowserDarwin } from './darwin'
|
||||
import { detectBrowserWindows } from './windows'
|
||||
import { log } from './log'
|
||||
import { Browser, NotInstalledError } from './types'
|
||||
import { browsers } from './browsers'
|
||||
@@ -27,7 +28,8 @@ type Detectors = {
|
||||
}
|
||||
const detectors: Detectors = {
|
||||
darwin: detectBrowserDarwin,
|
||||
linux: detectBrowserLinux
|
||||
linux: detectBrowserLinux,
|
||||
win32: detectBrowserWindows
|
||||
}
|
||||
|
||||
function lookup(platform: NodeJS.Platform, obj: Browser): Promise<Object> {
|
||||
@@ -61,6 +63,7 @@ function checkOneBrowser(browser: Browser) {
|
||||
throw err
|
||||
}
|
||||
|
||||
log('checking one browser %s', browser.name)
|
||||
return lookup(platform, browser)
|
||||
.then(merge(browser))
|
||||
.then(pickBrowserProps)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/** TODO this are typical browser names, not just Mac */
|
||||
export type MacBrowserName = 'chrome' | 'chromium' | 'canary' | string
|
||||
|
||||
export type PlatformName = 'darwin' | 'linux'
|
||||
export type PlatformName = 'darwin' | 'linux' | 'win32'
|
||||
|
||||
export type Browser = {
|
||||
/** short browser name */
|
||||
|
||||
29
packages/launcher/lib/windows/index.ts
Normal file
29
packages/launcher/lib/windows/index.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { log } from '../log'
|
||||
import { FoundBrowser, Browser, NotInstalledError } from '../types'
|
||||
import * as Promise from 'bluebird'
|
||||
|
||||
const notInstalledErr = (name: string) => {
|
||||
const err: NotInstalledError = new Error(
|
||||
`Browser not installed: ${name}`
|
||||
) as NotInstalledError
|
||||
err.notInstalled = true
|
||||
return err
|
||||
}
|
||||
|
||||
function getWindowsBrowser(
|
||||
name: string,
|
||||
binary: string,
|
||||
versionRegex: RegExp
|
||||
): Promise<FoundBrowser> {
|
||||
log(
|
||||
'Cannot detect windows browser yet "%s" binary "%s" version "%s"',
|
||||
name,
|
||||
binary,
|
||||
versionRegex
|
||||
)
|
||||
return Promise.reject(notInstalledErr(name))
|
||||
}
|
||||
|
||||
export function detectBrowserWindows(browser: Browser) {
|
||||
return getWindowsBrowser(browser.name, browser.binary, browser.versionRegex)
|
||||
}
|
||||
@@ -6,14 +6,15 @@
|
||||
"types": "../ts/index.d.ts",
|
||||
"scripts": {
|
||||
"pretest": "npm run lint",
|
||||
"test": "$(bin-up mocha) --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json",
|
||||
"test": "npm run unit",
|
||||
"unit": "bin-up mocha --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json",
|
||||
"clean-deps": "rm -rf node_modules",
|
||||
"clean": "rm lib/*.js lib/**/*.js || true",
|
||||
"clean-js": "npm run clean",
|
||||
"lint": "npm run format-ts && npm run lint-ts && npm run lint-coffee && npm run lint-js",
|
||||
"lint-js": "$(bin-up eslint) --fix *.js",
|
||||
"lint-js": "bin-up eslint --fix *.js",
|
||||
"lint-ts": "tslint --type-check --project . --fix --format stylish lib/*.ts lib/**/*.ts",
|
||||
"lint-coffee": "$(bin-up coffeelint) test/*.coffee test/**/*.coffee",
|
||||
"lint-coffee": "bin-up coffeelint test/*.coffee test/**/*.coffee",
|
||||
"format-ts": "prettier --no-semi --single-quote --write lib/*.ts lib/**/*.ts",
|
||||
"build-js": "tsc",
|
||||
"size": "t=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";"
|
||||
@@ -30,7 +31,7 @@
|
||||
"@types/lodash": "^4.14.64",
|
||||
"@types/mocha": "^2.2.41",
|
||||
"@types/node": "^7.0.18",
|
||||
"bin-up": "^1.0.1",
|
||||
"bin-up": "^1.1.0",
|
||||
"chai": "^3.5.0",
|
||||
"prettier": "^1.4.2",
|
||||
"sinon": "^1.17.3",
|
||||
@@ -41,7 +42,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/ramda": "0.0.10",
|
||||
"bluebird": "^3.3.5",
|
||||
"bluebird": "^3.5.0",
|
||||
"debug": "^2.6.6",
|
||||
"execa": "^0.6.3",
|
||||
"fs-extra": "^3.0.0",
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
const detect = require('../../lib/detect').default
|
||||
const log = require('debug')('cypress:launcher:test')
|
||||
const os = require('os')
|
||||
import {project} from 'ramda'
|
||||
|
||||
const isWindows = () =>
|
||||
os.platform() === 'win32'
|
||||
|
||||
describe('browser detection', () => {
|
||||
// making simple to debug tests
|
||||
// using DEBUG=... flag
|
||||
@@ -11,7 +15,13 @@ describe('browser detection', () => {
|
||||
|
||||
const mainProps = project(['name', 'version'], browsers)
|
||||
log('%d browsers\n%j', browsers.length, mainProps)
|
||||
expect(browsers.length).to.be.gt(0)
|
||||
|
||||
if (isWindows()) {
|
||||
// we might not find any browsers on Windows CI
|
||||
expect(browsers.length).to.be.gte(0)
|
||||
} else {
|
||||
expect(browsers.length).to.be.gt(0)
|
||||
}
|
||||
}
|
||||
|
||||
// we are only going to run tests on platforms with at least
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
"react-addons-test-utils": "^15.6.0",
|
||||
"react-dom": "^15.6.1",
|
||||
"react-test-renderer": "^15.6.1",
|
||||
"rebuild-node-sass": "^1.0.1",
|
||||
"rebuild-node-sass": "^1.1.0",
|
||||
"sinon": "^1.17.4",
|
||||
"sinon-chai": "^2.8.0",
|
||||
"zunder": "^4.1.1"
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
"react-addons-test-utils": "^15.6.0",
|
||||
"react-dom": "^15.6.1",
|
||||
"react-test-renderer": "^15.6.1",
|
||||
"rebuild-node-sass": "^1.0.1",
|
||||
"rebuild-node-sass": "^1.1.0",
|
||||
"sinon": "^1.17.5",
|
||||
"sinon-chai": "^2.8.0",
|
||||
"zunder": "^5.1.0"
|
||||
|
||||
@@ -7,6 +7,7 @@ check = require("check-more-types")
|
||||
log = require("debug")("cypress:server:appdata")
|
||||
pkg = require("@packages/root")
|
||||
cwd = require("../cwd")
|
||||
os = require("os")
|
||||
|
||||
fs = Promise.promisifyAll(fs)
|
||||
name = pkg.productName or pkg.name
|
||||
@@ -15,6 +16,12 @@ data = ospath.data()
|
||||
if not name
|
||||
throw new Error("Root package is missing name")
|
||||
|
||||
getSymlinkType = ->
|
||||
if os.platform() == "win32"
|
||||
"junction"
|
||||
else
|
||||
"dir"
|
||||
|
||||
isProduction = ->
|
||||
process.env.CYPRESS_ENV is "production"
|
||||
|
||||
@@ -36,7 +43,9 @@ module.exports = {
|
||||
src = path.dirname(@path())
|
||||
dest = cwd(".cy")
|
||||
|
||||
fs.ensureSymlinkAsync(src, dest, "dir")
|
||||
log("symlink folder from %s to %s", src, dest)
|
||||
symlinkType = getSymlinkType()
|
||||
fs.ensureSymlinkAsync(src, dest, symlinkType)
|
||||
|
||||
removeSymlink: ->
|
||||
fs.removeAsync(cwd(".cy")).catch(->)
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
"cors": "^2.8.3",
|
||||
"coveralls": "^2.11.8",
|
||||
"electron-osx-sign": "^0.3.0",
|
||||
"eol": "^0.9.1",
|
||||
"execa": "^0.8.0",
|
||||
"express-session": "^1.14.1",
|
||||
"express-useragent": "^1.0.4",
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
/* eslint-disable no-console */
|
||||
|
||||
const _ = require('lodash')
|
||||
const cp = require('child_process')
|
||||
const chalk = require('chalk')
|
||||
const minimist = require('minimist')
|
||||
const execa = require('execa')
|
||||
const os = require('os')
|
||||
|
||||
const options = minimist(process.argv.slice(2))
|
||||
|
||||
@@ -15,6 +16,9 @@ function exitErr (msg) {
|
||||
return process.exit(1)
|
||||
}
|
||||
|
||||
const isWindows = () =>
|
||||
os.platform() === 'win32'
|
||||
|
||||
if (!run) {
|
||||
return exitErr(`
|
||||
Error: A path to a spec file must be specified!
|
||||
@@ -31,21 +35,32 @@ if (!run) {
|
||||
`)
|
||||
}
|
||||
|
||||
const args = [
|
||||
'--xvfb-run-args',
|
||||
'-as \"-screen 0 1280x1024x8\"',
|
||||
'mocha',
|
||||
run,
|
||||
]
|
||||
const commandAndArguments = {
|
||||
command: '',
|
||||
args: [],
|
||||
}
|
||||
|
||||
if (isWindows()) {
|
||||
commandAndArguments.command = 'mocha'
|
||||
commandAndArguments.args = [run]
|
||||
} else {
|
||||
commandAndArguments.command = 'xvfb-maybe'
|
||||
commandAndArguments.args = [
|
||||
'--xvfb-run-args ' +
|
||||
'"-as \\"-screen 0 1280x1024x8\\""',
|
||||
'mocha',
|
||||
run,
|
||||
]
|
||||
}
|
||||
|
||||
if (options.fgrep) {
|
||||
args.push(
|
||||
commandAndArguments.args.push(
|
||||
'--fgrep',
|
||||
options.fgrep
|
||||
)
|
||||
}
|
||||
|
||||
args.push(
|
||||
commandAndArguments.args.push(
|
||||
'--timeout',
|
||||
'10000',
|
||||
'--recursive',
|
||||
@@ -84,8 +99,10 @@ if (options.browser) {
|
||||
env.BROWSER = options.browser
|
||||
}
|
||||
|
||||
cp.spawn('xvfb-maybe', args, {
|
||||
env,
|
||||
stdio: 'inherit',
|
||||
})
|
||||
.on('exit', process.exit)
|
||||
const cmd = `${commandAndArguments.command} ${
|
||||
commandAndArguments.args.join(' ')}`
|
||||
console.log('test command:')
|
||||
console.log(cmd)
|
||||
|
||||
const child = execa.shell(cmd, { env, stdio: 'inherit' })
|
||||
child.on('exit', process.exit)
|
||||
|
||||
@@ -6,6 +6,11 @@ Promise = require("bluebird")
|
||||
config = require("#{root}lib/config")
|
||||
fixture = require("#{root}lib/fixture")
|
||||
FixturesHelper = require("#{root}/test/support/helpers/fixtures")
|
||||
os = require("os")
|
||||
eol = require("eol")
|
||||
|
||||
isWindows = () ->
|
||||
os.platform() == "win32"
|
||||
|
||||
fs = Promise.promisifyAll(fs)
|
||||
|
||||
@@ -43,6 +48,7 @@ describe "lib/fixture", ->
|
||||
it "throws when json is invalid", ->
|
||||
e =
|
||||
"""
|
||||
'bad_json.json' is not valid JSON.
|
||||
Parse error on line 2:
|
||||
{ "bad": "json""should": "not parse
|
||||
----------------^
|
||||
@@ -53,7 +59,15 @@ describe "lib/fixture", ->
|
||||
.then ->
|
||||
throw new Error("should have failed but did not")
|
||||
.catch (err) ->
|
||||
expect(err.message).to.eq "'bad_json.json' is not valid JSON.\n#{e}"
|
||||
if isWindows()
|
||||
# there is weird trailing whitespace in the lines
|
||||
# of the error message on Windows
|
||||
expect(err.message).to.include "'bad_json.json' is not valid JSON."
|
||||
expect(err.message).to.include "Parse error on line 2:"
|
||||
expect(err.message).to.include "Expecting 'EOF', '}', ':', ',', ']', got 'STRING'"
|
||||
else
|
||||
# on other platforms can match the error directly
|
||||
expect(eol.auto(err.message)).to.eq eol.auto(e)
|
||||
|
||||
it "reformats json and writes back even on parse error", ->
|
||||
fixture.get(@fixturesFolder, "bad_json.json")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
require("../spec_helper")
|
||||
|
||||
path = require("path")
|
||||
Fixtures = require("../support/helpers/fixtures")
|
||||
config = require("#{root}lib/config")
|
||||
settings = require("#{root}lib/util/settings")
|
||||
@@ -23,14 +24,15 @@ describe "lib/screenshots", ->
|
||||
it "outputs file and returns size and path", ->
|
||||
screenshots.save({name: "foo/tweet"}, image, @cfg.screenshotsFolder)
|
||||
.then (obj) =>
|
||||
path = @cfg.screenshotsFolder + "/footweet.png"
|
||||
expectedPath = path.normalize(@cfg.screenshotsFolder + "/footweet.png")
|
||||
actualPath = path.normalize(obj.path)
|
||||
|
||||
expect(obj.size).to.eq("279 B")
|
||||
expect(obj.path).to.eq(path)
|
||||
expect(actualPath).to.eq(expectedPath)
|
||||
expect(obj.width).to.eq(10)
|
||||
expect(obj.height).to.eq(10)
|
||||
|
||||
fs.statAsync(path)
|
||||
fs.statAsync(expectedPath)
|
||||
|
||||
context ".copy", ->
|
||||
it "doesnt yell over ENOENT errors", ->
|
||||
|
||||
@@ -435,8 +435,8 @@ describe "lib/socket", ->
|
||||
expect(result).to.be.undefined
|
||||
|
||||
it "returns undefined if #testFilePath matches arguments", ->
|
||||
@socket.testFilePath = "tests/test1.js"
|
||||
result = @socket.watchTestFileByPath(@cfg, "integration/test1.js", @watchers)
|
||||
@socket.testFilePath = path.join("tests", "test1.js")
|
||||
result = @socket.watchTestFileByPath(@cfg, path.join("integration", "test1.js"), @watchers)
|
||||
expect(result).to.be.undefined
|
||||
|
||||
it "closes existing watched test file", ->
|
||||
|
||||
@@ -30,6 +30,9 @@ getPlatformQuestion = ->
|
||||
},{
|
||||
name: "Linux"
|
||||
value: "linux"
|
||||
}, {
|
||||
name: "Windows",
|
||||
value: "win32"
|
||||
}]
|
||||
}]
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ coffee = require("@packages/coffee")
|
||||
electron = require("@packages/electron")
|
||||
signOsxApp = require("electron-osx-sign")
|
||||
debug = require("debug")("cypress:binary")
|
||||
R = require("ramda")
|
||||
|
||||
meta = require("./meta")
|
||||
smoke = require("./smoke")
|
||||
@@ -31,6 +32,12 @@ fs = Promise.promisifyAll(fse)
|
||||
logger = (msg, platform) ->
|
||||
console.log(chalk.yellow(msg), chalk.bgWhite(chalk.black(platform)))
|
||||
|
||||
logBuiltAllPackages = () ->
|
||||
console.log("built all packages")
|
||||
|
||||
logBuiltAllJs = () ->
|
||||
console.log("built all JS")
|
||||
|
||||
# can pass options to better control the build
|
||||
# for example
|
||||
# skipClean - do not delete "dist" folder before build
|
||||
@@ -77,7 +84,10 @@ buildCypressApp = (platform, version, options = {}) ->
|
||||
log("#buildPackages")
|
||||
|
||||
packages.runAllBuild()
|
||||
# Promise.resolve()
|
||||
.then(R.tap(logBuiltAllPackages))
|
||||
.then(packages.runAllBuildJs)
|
||||
.then(R.tap(logBuiltAllJs))
|
||||
|
||||
copyPackages = ->
|
||||
log("#copyPackages")
|
||||
|
||||
@@ -61,7 +61,15 @@ deploy = {
|
||||
opts.runTests = false if opts["skip-tests"]
|
||||
if not opts.platform and os.platform() == meta.platforms.linux
|
||||
# only can build Linux on Linux
|
||||
opts.platform = "linux"
|
||||
opts.platform = meta.platforms.linux
|
||||
|
||||
# windows aliases
|
||||
if opts.platform == "win32" or opts.platform == "win" or opts.platform == "windows"
|
||||
opts.platform = meta.platforms.windows
|
||||
|
||||
if not opts.platform and os.platform() == meta.platforms.windows
|
||||
# only can build Windows binary on Windows platform
|
||||
opts.platform = meta.platforms.windows
|
||||
|
||||
# be a little bit user-friendly and allow aliased values
|
||||
if opts.platform == "mac"
|
||||
|
||||
@@ -6,7 +6,8 @@ R = require("ramda")
|
||||
# canonical platform names
|
||||
platforms = {
|
||||
darwin: "darwin"
|
||||
linux: "linux"
|
||||
linux: "linux",
|
||||
windows: "win32"
|
||||
}
|
||||
|
||||
isValidPlatform = check.oneOf(R.values(platforms))
|
||||
@@ -17,12 +18,15 @@ isValidPlatform = check.oneOf(R.values(platforms))
|
||||
## <platform>/ = linux or darwin
|
||||
## ... platform-specific files
|
||||
buildDir = (platform, args...) ->
|
||||
la(isValidPlatform(platform), "invalid platform", platform)
|
||||
la(isValidPlatform(platform),
|
||||
"invalid build platform", platform, "valid choices", R.values(platforms))
|
||||
switch platform
|
||||
when "darwin"
|
||||
path.resolve("build", platform, args...)
|
||||
when "linux"
|
||||
path.resolve("build", platform, "Cypress", args...)
|
||||
when "win32"
|
||||
path.resolve("build", platform, "Cypress", args...)
|
||||
|
||||
## returns a path into the /dist directory
|
||||
distDir = (platform, args...) ->
|
||||
|
||||
@@ -6,6 +6,9 @@ glob = require("glob")
|
||||
Promise = require("bluebird")
|
||||
la = require("lazy-ass")
|
||||
check = require("check-more-types")
|
||||
execa = require("execa")
|
||||
R = require("ramda")
|
||||
os = require("os")
|
||||
|
||||
fs = Promise.promisifyAll(fs)
|
||||
glob = Promise.promisify(glob)
|
||||
@@ -16,27 +19,27 @@ pathToPackageJson = (pkg) ->
|
||||
path.join(pkg, "package.json")
|
||||
|
||||
npmRun = (args, cwd) ->
|
||||
new Promise (resolve, reject) ->
|
||||
reject = _.once(reject)
|
||||
command = "npm " + args.join(" ")
|
||||
console.log(command)
|
||||
if cwd
|
||||
console.log("in folder:", cwd)
|
||||
|
||||
cp.spawn("npm", args, { stdio: "inherit", cwd })
|
||||
.on "error", reject
|
||||
.on "exit", (code) ->
|
||||
if code is 0
|
||||
resolve()
|
||||
else
|
||||
msg = "npm " + args.join(" ") + " failed with exit code: #{code}"
|
||||
reject(new Error(msg))
|
||||
la(check.maybe.string(cwd), "invalid CWD string", cwd)
|
||||
execa("npm", args, { stdio: "inherit", cwd })
|
||||
# if everything is ok, resolve with nothing
|
||||
.then R.always(undefined)
|
||||
.catch (result) ->
|
||||
msg = "#{command} failed with exit code: #{result.code}"
|
||||
throw new Error(msg)
|
||||
|
||||
|
||||
runAllBuildJs = _.partial(npmRun, ["run", "all", "build-js", "--skip-packages", "cli,docs"])
|
||||
runAllBuildJs = _.partial(npmRun, ["run", "all", "build-js", "--skip-packages", "cli"])
|
||||
|
||||
# removes transpiled JS files in the original package folders
|
||||
runAllCleanJs = _.partial(npmRun, ["run", "all", "clean-js", "--skip-packages", "cli,docs"])
|
||||
runAllCleanJs = _.partial(npmRun, ["run", "all", "clean-js", "--skip-packages", "cli"])
|
||||
|
||||
# builds all the packages except for cli and docs
|
||||
# builds all the packages except for cli
|
||||
runAllBuild = _.partial(npmRun,
|
||||
["run", "all", "build", "--", "--serial", "--skip-packages", "cli,docs"])
|
||||
["run", "all", "build", "--", "--serial", "--skip-packages", "cli"])
|
||||
|
||||
copyAllToDist = (distDir) ->
|
||||
copyRelativePathToDist = (relative) ->
|
||||
@@ -100,6 +103,7 @@ npmInstallAll = (pathToPackages) ->
|
||||
|
||||
|
||||
retryNpmInstall = (pkg) ->
|
||||
console.log("installing", pkg)
|
||||
npmInstall = _.partial(npmRun, ["install", "--production", "--quiet"])
|
||||
npmInstall(pkg)
|
||||
.catch {code: "EMFILE"}, ->
|
||||
@@ -126,6 +130,12 @@ ensureFoundSomething = (files) ->
|
||||
throw new Error("Could not find any files")
|
||||
files
|
||||
|
||||
symlinkType = () ->
|
||||
if os.platform() == "win32"
|
||||
"junction"
|
||||
else
|
||||
"dir"
|
||||
|
||||
symlinkAll = (pathToDistPackages, pathTo) ->
|
||||
console.log("symlink these packages", pathToDistPackages)
|
||||
la(check.unemptyString(pathToDistPackages),
|
||||
@@ -142,8 +152,10 @@ symlinkAll = (pathToDistPackages, pathTo) ->
|
||||
dest = pathTo("node_modules", "@packages", path.basename(pkg))
|
||||
relativeDest = path.relative(dest + '/..', pkg)
|
||||
|
||||
console.log(relativeDest, "link ->", dest)
|
||||
fs.ensureSymlinkAsync(relativeDest, dest)
|
||||
type = symlinkType()
|
||||
console.log(relativeDest, "link ->", dest, "type", type)
|
||||
|
||||
fs.ensureSymlinkAsync(relativeDest, dest, symlinkType)
|
||||
.catch((err) ->
|
||||
if not err.message.includes "EEXIST"
|
||||
throw err
|
||||
|
||||
Reference in New Issue
Block a user