Skip to content

Commit

Permalink
Merge pull request #18445 from cypress-io/local-server-integration-te…
Browse files Browse the repository at this point in the history
…st-fix

fix: server cypress_spec permissions test now passes
  • Loading branch information
Blue F committed Oct 14, 2021
2 parents 8e3e99d + d517793 commit f4fee90
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/server/lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ const getMsgByType = function (type, arg1 = {}, arg2, arg3) {
return stripIndent`
There is both a \`${arg2}\` and a \`${arg3}\` at the location below:
${arg1}
Cypress does not know which one to read for config. Please remove one of the two and try again.
`
case 'CONFIG_FILE_NOT_FOUND':
Expand Down Expand Up @@ -988,7 +988,7 @@ const getMsgByType = function (type, arg1 = {}, arg2, arg3) {
`
case 'CT_NO_DEV_START_EVENT':
return stripIndent`\
To run component-testing, cypress needs the \`dev-server:start\` event.
To run component-testing, cypress needs the \`dev-server:start\` event.
Implement it by adding a \`on('dev-server:start', () => startDevServer())\` call in your pluginsFile.
${arg1 ?
Expand Down
8 changes: 7 additions & 1 deletion packages/server/lib/scaffold.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const { fs } = require('./util/fs')
const glob = require('./util/glob')
const cwd = require('./cwd')
const debug = require('debug')('cypress:server:scaffold')
const errors = require('./errors')
const { isEmpty } = require('ramda')
const { isDefault } = require('./util/config')

Expand Down Expand Up @@ -232,7 +233,6 @@ module.exports = {

plugins (folder, config) {
debug(`plugins folder ${folder}`)

// skip if user has explicitly set pluginsFile
if (!config.pluginsFile || !isDefault(config, 'pluginsFile')) {
return Promise.resolve()
Expand All @@ -254,6 +254,12 @@ module.exports = {
return this._assertInFileTree(dest, config)
.then(() => {
return fs.copyAsync(src, dest)
}).catch((error) => {
if (error.code === 'EACCES') {
error = errors.get('ERROR_WRITING_FILE', dest, error)
}

throw error
})
},

Expand Down
14 changes: 8 additions & 6 deletions packages/server/test/integration/cypress_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ describe('lib/cypress', () => {
require('mocha-banner').register()

beforeEach(function () {
process.chdir(previousCwd)
this.timeout(8000)

cache.__removeSync()
Expand Down Expand Up @@ -839,27 +840,28 @@ describe('lib/cypress', () => {
// also make sure we test the rest of the integration functionality
// for headed errors! <-- not unit tests, but integration tests!
it('logs error and exits when project folder has read permissions only and cannot write cypress.json', function () {
// test disabled if running as root - root can write all things at all times
// test disabled if running as root (such as inside docker) - root can write all things at all times
if (process.geteuid() === 0) {
return
}

const permissionsPath = path.resolve('./permissions')

const cypressJson = path.join(permissionsPath, 'cypress.json')

return fs.outputFileAsync(cypressJson, '{}')
return fs.mkdirAsync(permissionsPath)
.then(() => {
return fs.outputFileAsync(cypressJson, '{}')
}).then(() => {
// read only
return fs.chmodAsync(permissionsPath, '555')
}).then(() => {
return cypress.start([`--run-project=${permissionsPath}`])
}).then(() => {
return fs.chmodAsync(permissionsPath, '777')
}).then(() => {
return fs.removeAsync(permissionsPath)
}).then(() => {
this.expectExitWithErr('ERROR_READING_FILE', path.join(permissionsPath, 'cypress.json'))
this.expectExitWithErr('ERROR_WRITING_FILE', permissionsPath)
}).finally(() => {
return fs.rmdir(permissionsPath, { recursive: true })
})
})

Expand Down

4 comments on commit f4fee90

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f4fee90 Oct 14, 2021

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.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/8.7.0/circle-develop-f4fee905e72d96d06b4b21cd20298398b3be6673/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f4fee90 Oct 14, 2021

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.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/8.7.0/appveyor-develop-f4fee905e72d96d06b4b21cd20298398b3be6673/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f4fee90 Oct 14, 2021

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.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/8.7.0/appveyor-develop-f4fee905e72d96d06b4b21cd20298398b3be6673/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f4fee90 Oct 14, 2021

Choose a reason for hiding this comment

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

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

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/8.7.0/circle-develop-f4fee905e72d96d06b4b21cd20298398b3be6673/cypress.tgz

Please sign in to comment.