Skip to content

Commit

Permalink
fix: warn when the projectRoot is not writeable (#18495)
Browse files Browse the repository at this point in the history
closes #18485
  • Loading branch information
elevatebart committed Oct 14, 2021
1 parent af472b6 commit 83a1f09
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/server/lib/modes/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,9 +608,22 @@ const openProjectCreate = (projectRoot, socketId, args) => {
return openProject.create(projectRoot, args, options)
}

const createAndOpenProject = async function (socketId, options) {
async function checkAccess (folderPath) {
return fs.access(folderPath, fs.W_OK).catch((err) => {
if (['EACCES', 'EPERM'].includes(err.code)) {
// we cannot write due to folder permissions
return errors.warning('FOLDER_NOT_WRITABLE', folderPath)
}

throw err
})
}

const createAndOpenProject = async (socketId, options) => {
const { projectRoot, projectId } = options

await checkAccess(projectRoot)

return openProjectCreate(projectRoot, socketId, options)
.then((open_project) => open_project.getProject())
.then((project) => {
Expand Down
3 changes: 3 additions & 0 deletions packages/server/test/e2e/non_root_read_only_fs_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ describe('e2e readonly fs', function () {

const projectPath = Fixtures.projectPath('read-only-project-root')

/**
* Change permissions recursively
*/
const chmodr = (p: string, mode: number) => {
const stats = fs.statSync(p)

Expand Down
2 changes: 2 additions & 0 deletions packages/server/test/unit/modes/run_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,7 @@ describe('lib/modes/run', () => {
sinon.stub(random, 'id').returns(1234)
sinon.stub(openProject, 'create').resolves(openProject)
sinon.stub(runMode, 'waitForSocketConnection').resolves()
sinon.stub(fs, 'access').resolves()
sinon.stub(runMode, 'waitForTestsToFinishRunning').resolves({
stats: { failures: 10 },
spec: {},
Expand Down Expand Up @@ -736,6 +737,7 @@ describe('lib/modes/run', () => {

sinon.stub(electron.app, 'on').withArgs('ready').yieldsAsync()
sinon.stub(user, 'ensureAuthToken')
sinon.stub(fs, 'access').resolves()
sinon.stub(random, 'id').returns(1234)
sinon.stub(openProject, 'create').resolves(openProject)
sinon.stub(system, 'info').resolves({ osName: 'osFoo', osVersion: 'fooVersion' })
Expand Down

4 comments on commit 83a1f09

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 83a1f09 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-83a1f09b1174b4d70a826d9894e47a0ce7a777e9/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 83a1f09 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-83a1f09b1174b4d70a826d9894e47a0ce7a777e9/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 83a1f09 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-83a1f09b1174b4d70a826d9894e47a0ce7a777e9/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 83a1f09 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-83a1f09b1174b4d70a826d9894e47a0ce7a777e9/cypress.tgz

Please sign in to comment.