forked from cypress-io/cypress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnon_root_read_only_fs_spec.ts
49 lines (42 loc) · 1.13 KB
/
non_root_read_only_fs_spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import * as fs from 'fs'
import * as path from 'path'
import systemTests from '../lib/system-tests'
import Fixtures from '../lib/fixtures'
import { scaffoldCommonNodeModules } from '@tooling/system-tests/lib/dep-installer'
describe('e2e readonly fs', function () {
systemTests.setup()
const projectPath = Fixtures.projectPath('read-only-project-root')
/**
* Change permissions recursively
*/
const chmodr = (p: string, mode: number) => {
const stats = fs.statSync(p)
fs.chmodSync(p, mode)
if (stats.isDirectory()) {
fs.readdirSync(p).forEach((child) => {
chmodr(path.join(p, child), mode)
})
}
}
const onRun = async (exec) => {
try {
await Fixtures.scaffoldProject('read-only-project-root')
await scaffoldCommonNodeModules()
chmodr(projectPath, 0o500)
await exec()
} finally {
chmodr(projectPath, 0o777)
}
}
systemTests.it('warns when unable to write to disk', {
project: 'read-only-project-root',
expectedExitCode: 1,
spec: 'spec.cy.js',
snapshot: true,
config: {
video: false,
},
skipScaffold: true,
onRun,
})
})