diff --git a/packages/server/__snapshots__/8_read_only_fs.ts.js b/packages/server/__snapshots__/8_read_only_fs.ts.js index 5752c1c2d6ee..ef6e98de675a 100644 --- a/packages/server/__snapshots__/8_read_only_fs.ts.js +++ b/packages/server/__snapshots__/8_read_only_fs.ts.js @@ -1,5 +1,5 @@ exports['e2e project dir access / warns when unable to write to dir'] = ` -Folder /var/folders/k1/3m_8g1215_3ds89dv0g55fn40000gn/T/71d038ec is not writable. +Folder /tmp/8_read_only_fs is not writable. Writing to this directory is required by Cypress in order to store screenshots and videos. @@ -47,17 +47,17 @@ Warning: We failed to record the video. This error will not alter the exit code. -Error: ffmpeg exited with code 1: /var/folders/k1/3m_8g1215_3ds89dv0g55fn40000gn/T/71d038ec/cypress/videos/spec.js.mp4: Permission denied +Error: ffmpeg exited with code 1: /tmp/8_read_only_fs/cypress/videos/spec.js.mp4: Permission denied - [stack trace lines] + [stack trace lines] Warning: We failed processing this video. This error will not alter the exit code. -Error: ffmpeg exited with code 1: /var/folders/k1/3m_8g1215_3ds89dv0g55fn40000gn/T/71d038ec/cypress/videos/spec.js.mp4: Permission denied +Error: ffmpeg exited with code 1: /tmp/8_read_only_fs/cypress/videos/spec.js.mp4: Permission denied - [stack trace lines] + [stack trace lines] ==================================================================================================== diff --git a/packages/server/package.json b/packages/server/package.json index f3982c2546d9..8b11350baf30 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -153,6 +153,7 @@ "chai-as-promised": "7.1.1", "chai-subset": "1.6.0", "chai-uuid": "1.0.6", + "chmodr": "1.2.0", "chokidar-cli": "1.2.2", "chrome-har-capturer": "0.13.4", "coffee-coverage": "3.0.1", @@ -200,4 +201,4 @@ "optionalDependencies": { "registry-js": "1.8.0" } -} +} \ No newline at end of file diff --git a/packages/server/test/e2e/8_read_only_fs.ts b/packages/server/test/e2e/8_read_only_fs.ts index 352e29319c36..ad01724932e8 100644 --- a/packages/server/test/e2e/8_read_only_fs.ts +++ b/packages/server/test/e2e/8_read_only_fs.ts @@ -1,13 +1,12 @@ -import * as fs from 'fs-extra' -import * as os from 'os' +import * as fs from 'fs' import * as path from 'path' -import * as crypto from 'crypto' const e2e = require('../support/helpers/e2e') +const chmodr = require('chmodr') describe('e2e project dir access', function () { e2e.setup() - const projectDir: string = path.join(os.tmpdir(), crypto.randomBytes(4).toString('hex')) + const projectDir: string = path.join('/', 'tmp', '8_read_only_fs') beforeEach(() => { if (fs.existsSync(projectDir)) { @@ -18,18 +17,14 @@ describe('e2e project dir access', function () { // we cant sue one define by source code since we need to modify the file permissions on the dir and files fs.mkdirSync(path.join(projectDir)) - fs.writeFile(path.join(projectDir, 'cypress.json'), `{"projectId": "2pz86o"}`) - + fs.writeFileSync(path.join(projectDir, 'cypress.json'), `{"projectId": "2pz86o"}`) fs.mkdirSync(path.join(projectDir, 'cypress')) fs.mkdirSync(path.join(projectDir, 'cypress', 'integration')) fs.writeFileSync(path.join(projectDir, 'cypress', 'integration', 'spec.js'), `it('test',() => expect(true).to.be.true )`) - fs.mkdirSync(path.join(projectDir, 'cypress', 'plugins')) fs.writeFileSync(path.join(projectDir, 'cypress', 'plugins', 'index.js'), `module.exports = () => {}`) - fs.mkdirSync(path.join(projectDir, 'cypress', 'support')) fs.writeFileSync(path.join(projectDir, 'cypress', 'support', 'index.js'), `module.exports = () => {}`) - fs.mkdirSync(path.join(projectDir, 'cypress', 'videos')) // setup the file/folder permissions @@ -37,17 +32,7 @@ describe('e2e project dir access', function () { // the dir needs executable for debugging // the main test here is that it isn't writable, which would be either 6 or 7 // See here for more info on these numbers http://permissions-calculator.org/ - const readExe = 0o500 - - fs.chmodSync(path.join(projectDir), readExe) - fs.chmodSync(path.join(projectDir, 'cypress'), readExe) - fs.chmodSync(path.join(projectDir, 'cypress', 'integration'), readExe) - fs.chmodSync(path.join(projectDir, 'cypress', 'integration', 'spec.js'), readExe) - fs.chmodSync(path.join(projectDir, 'cypress', 'plugins'), readExe) - fs.chmodSync(path.join(projectDir, 'cypress', 'plugins', 'index.js'), readExe) - fs.chmodSync(path.join(projectDir, 'cypress', 'support'), readExe) - fs.chmodSync(path.join(projectDir, 'cypress', 'support', 'index.js'), readExe) - fs.chmodSync(path.join(projectDir, 'cypress', 'videos'), readExe) + chmodr.sync(projectDir, 0o500) // test that we setup the folder structure correctly let err: any diff --git a/yarn.lock b/yarn.lock index 8e80f6e94e0a..ba6e430e2d4a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7751,6 +7751,11 @@ cheerio@^1.0.0-rc.3: lodash "^4.15.0" parse5 "^3.0.1" +chmodr@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/chmodr/-/chmodr-1.2.0.tgz#720e96caa09b7f1cdbb01529b7d0ab6bc5e118b9" + integrity sha512-Y5uI7Iq/Az6HgJEL6pdw7THVd7jbVOTPwsmcPOBjQL8e3N+pz872kzK5QxYGEy21iRys+iHWV0UZQXDFJo1hyA== + chokidar-cli@1.2.2: version "1.2.2" resolved "https://registry.yarnpkg.com/chokidar-cli/-/chokidar-cli-1.2.2.tgz#fbfddcf1f9062c07744f0bbeb6f60a49de12c656"