Skip to content

Commit

Permalink
Fix browser detection with multiline --versions (#6712)
Browse files Browse the repository at this point in the history
  • Loading branch information
flotwig committed Mar 12, 2020
1 parent 1d84887 commit 9caf21a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 12 deletions.
20 changes: 10 additions & 10 deletions packages/launcher/lib/browsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const browsers: Browser[] = [
family: 'chromium',
channel: 'stable',
displayName: 'Chrome',
versionRegex: /Google Chrome (\S+)/,
versionRegex: /Google Chrome (\S+)/m,
profile: true,
binary: ['google-chrome', 'chrome', 'google-chrome-stable'],
},
Expand All @@ -21,7 +21,7 @@ export const browsers: Browser[] = [
// technically Chromium is always in development
channel: 'stable',
displayName: 'Chromium',
versionRegex: /Chromium (\S+)/,
versionRegex: /Chromium (\S+)/m,
profile: true,
binary: ['chromium-browser', 'chromium'],
},
Expand All @@ -30,7 +30,7 @@ export const browsers: Browser[] = [
family: 'chromium',
channel: 'canary',
displayName: 'Canary',
versionRegex: /Google Chrome Canary (\S+)/,
versionRegex: /Google Chrome Canary (\S+)/m,
profile: true,
binary: 'google-chrome-canary',
},
Expand All @@ -41,7 +41,7 @@ export const browsers: Browser[] = [
displayName: 'Firefox',
info: firefoxInfo,
// Mozilla Firefox 70.0.1
versionRegex: /^Mozilla Firefox ([^\sab]+)$/,
versionRegex: /^Mozilla Firefox ([^\sab]+)$/m,
profile: true,
binary: 'firefox',
},
Expand All @@ -52,7 +52,7 @@ export const browsers: Browser[] = [
displayName: 'Firefox Developer Edition',
info: firefoxInfo,
// Mozilla Firefox 73.0b12
versionRegex: /^Mozilla Firefox (\S+b\S*)$/,
versionRegex: /^Mozilla Firefox (\S+b\S*)$/m,
profile: true,
// ubuntu PPAs install it as firefox
binary: ['firefox-developer-edition', 'firefox'],
Expand All @@ -64,7 +64,7 @@ export const browsers: Browser[] = [
displayName: 'Firefox Nightly',
info: firefoxInfo,
// Mozilla Firefox 74.0a1
versionRegex: /^Mozilla Firefox (\S+a\S*)$/,
versionRegex: /^Mozilla Firefox (\S+a\S*)$/m,
profile: true,
// ubuntu PPAs install it as firefox-trunk
binary: ['firefox-nightly', 'firefox-trunk'],
Expand All @@ -74,7 +74,7 @@ export const browsers: Browser[] = [
family: 'chromium',
channel: 'stable',
displayName: 'Edge',
versionRegex: /Microsoft Edge (\S+)/,
versionRegex: /Microsoft Edge (\S+)/m,
profile: true,
binary: 'edge',
},
Expand All @@ -83,7 +83,7 @@ export const browsers: Browser[] = [
family: 'chromium',
channel: 'canary',
displayName: 'Edge Canary',
versionRegex: /Microsoft Edge Canary (\S+)/,
versionRegex: /Microsoft Edge Canary (\S+)/m,
profile: true,
binary: 'edge-canary',
},
Expand All @@ -92,7 +92,7 @@ export const browsers: Browser[] = [
family: 'chromium',
channel: 'beta',
displayName: 'Edge Beta',
versionRegex: /Microsoft Edge Beta (\S+)/,
versionRegex: /Microsoft Edge Beta (\S+)/m,
profile: true,
binary: 'edge-beta',
},
Expand All @@ -101,7 +101,7 @@ export const browsers: Browser[] = [
family: 'chromium',
channel: 'dev',
displayName: 'Edge Dev',
versionRegex: /Microsoft Edge Dev (\S+)/,
versionRegex: /Microsoft Edge Dev (\S+)/m,
profile: true,
binary: 'edge-dev',
},
Expand Down
4 changes: 2 additions & 2 deletions packages/launcher/test/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ export const goalBrowsers = [
{
displayName: 'Test Browser',
name: 'test-browser-name',
versionRegex: /test-browser v(\S+)$/,
versionRegex: /test-browser v(\S+)$/m,
profile: true,
binary: 'test-browser',
},
{
displayName: 'Foo Browser',
name: 'foo-browser',
versionRegex: /foo-browser v(\S+)$/,
versionRegex: /foo-browser v(\S+)$/m,
profile: true,
binary: ['foo-browser', 'foo-bar-browser'],
},
Expand Down
9 changes: 9 additions & 0 deletions packages/launcher/test/unit/browsers_spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import _ from 'lodash'
import { browsers } from '../../lib/browsers'
import { expect } from 'chai'
const snapshot = require('snap-shot-it')

describe('browsers', () => {
it('returns the expected list of browsers', () => {
snapshot(browsers)
})

// https://github.com/cypress-io/cypress/issues/6669
it('exports multiline versionRegexes', () => {
expect(_.every(browsers.map(({ versionRegex }) => {
return versionRegex.multiline
}))).to.be.true
})
})
19 changes: 19 additions & 0 deletions packages/launcher/test/unit/linux_spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require('../spec_helper')

import _ from 'lodash'
import * as linuxHelper from '../../lib/linux'
import 'chai-as-promised'
import { log } from '../log'
Expand Down Expand Up @@ -42,6 +43,24 @@ describe('linux browser detection', () => {
return linuxHelper.detect(goal).then(checkBrowser)
})

// https://github.com/cypress-io/cypress/issues/6669
it('detects browser if the --version stdout is multiline', () => {
stdout.withArgs('multiline-foo', ['--version'])
.resolves('Running without a11y support!\nfoo-browser v9001.1.2.3')

const goal = _.defaults({ binary: 'multiline-foo' }, _.find(goalBrowsers, { name: 'foo-browser' }))
const checkBrowser = (browser) => {
expect(browser).to.deep.equal({
name: 'foo-browser',
path: 'multiline-foo',
version: '9001.1.2.3',
})
}

// @ts-ignore
return linuxHelper.detect(goal).then(checkBrowser)
})

// despite using detect(), this test is in linux/spec instead of detect_spec because it is
// testing side effects that occur within the Linux-specific detect function
// https://github.com/cypress-io/cypress/issues/1400
Expand Down

4 comments on commit 9caf21a

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 9caf21a Mar 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.2.0/linux-x64/circle-develop-9caf21a6aa70d5b90321b122a65395e8f0354dd9-279667/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.2.0/circle-develop-9caf21a6aa70d5b90321b122a65395e8f0354dd9-279660/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 9caf21a Mar 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.2.0/darwin-x64/circle-develop-9caf21a6aa70d5b90321b122a65395e8f0354dd9-279728/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.2.0/circle-develop-9caf21a6aa70d5b90321b122a65395e8f0354dd9-279722/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 9caf21a Mar 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

Instructions are included below, depending on the shell you are using.

In Command Prompt (cmd.exe):

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.2.0/win32-x64/appveyor-develop-9caf21a6aa70d5b90321b122a65395e8f0354dd9-31433471/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.2.0/appveyor-develop-9caf21a6aa70d5b90321b122a65395e8f0354dd9-31433471/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/4.2.0/win32-x64/appveyor-develop-9caf21a6aa70d5b90321b122a65395e8f0354dd9-31433471/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.2.0/appveyor-develop-9caf21a6aa70d5b90321b122a65395e8f0354dd9-31433471/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.2.0/win32-x64/appveyor-develop-9caf21a6aa70d5b90321b122a65395e8f0354dd9-31433471/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.2.0/appveyor-develop-9caf21a6aa70d5b90321b122a65395e8f0354dd9-31433471/cypress.tgz

Using cross-env:

If the above commands do not work for you, you can also try using cross-env:

npm i -g cross-env
cross-env CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.2.0/win32-x64/appveyor-develop-9caf21a6aa70d5b90321b122a65395e8f0354dd9-31433471/cypress.zip npm install https://cdn.cypress.io/beta/npm/4.2.0/appveyor-develop-9caf21a6aa70d5b90321b122a65395e8f0354dd9-31433471/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 9caf21a Mar 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 ia32 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

Instructions are included below, depending on the shell you are using.

In Command Prompt (cmd.exe):

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.2.0/win32-ia32/appveyor-develop-9caf21a6aa70d5b90321b122a65395e8f0354dd9-31433471/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.2.0/appveyor-develop-9caf21a6aa70d5b90321b122a65395e8f0354dd9-31433471/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/4.2.0/win32-ia32/appveyor-develop-9caf21a6aa70d5b90321b122a65395e8f0354dd9-31433471/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.2.0/appveyor-develop-9caf21a6aa70d5b90321b122a65395e8f0354dd9-31433471/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.2.0/win32-ia32/appveyor-develop-9caf21a6aa70d5b90321b122a65395e8f0354dd9-31433471/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.2.0/appveyor-develop-9caf21a6aa70d5b90321b122a65395e8f0354dd9-31433471/cypress.tgz

Using cross-env:

If the above commands do not work for you, you can also try using cross-env:

npm i -g cross-env
cross-env CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.2.0/win32-ia32/appveyor-develop-9caf21a6aa70d5b90321b122a65395e8f0354dd9-31433471/cypress.zip npm install https://cdn.cypress.io/beta/npm/4.2.0/appveyor-develop-9caf21a6aa70d5b90321b122a65395e8f0354dd9-31433471/cypress.tgz

Please sign in to comment.