@@ -95,6 +95,9 @@ describe('chmod', () => {
95
95
await testChmod ( '0000' , 'ugo+x' , '0111' )
96
96
await testChmod ( '0000' , 'ugo+w' , '0222' )
97
97
await testChmod ( '0000' , 'ugo+r' , '0444' )
98
+ await testChmod ( '0000' , 'a+x' , '0111' )
99
+ await testChmod ( '0000' , 'a+w' , '0222' )
100
+ await testChmod ( '0000' , 'a+r' , '0444' )
98
101
} )
99
102
100
103
it ( 'should update modes with basic symbolic notation that removes bits' , async ( ) => {
@@ -116,6 +119,9 @@ describe('chmod', () => {
116
119
await testChmod ( '0111' , 'ugo-x' , '0000' )
117
120
await testChmod ( '0222' , 'ugo-w' , '0000' )
118
121
await testChmod ( '0444' , 'ugo-r' , '0000' )
122
+ await testChmod ( '0111' , 'a-x' , '0000' )
123
+ await testChmod ( '0222' , 'a-w' , '0000' )
124
+ await testChmod ( '0444' , 'a-r' , '0000' )
119
125
} )
120
126
121
127
it ( 'should update modes with basic symbolic notation that overrides bits' , async ( ) => {
@@ -137,6 +143,9 @@ describe('chmod', () => {
137
143
await testChmod ( '0777' , 'ugo=x' , '0111' )
138
144
await testChmod ( '0777' , 'ugo=w' , '0222' )
139
145
await testChmod ( '0777' , 'ugo=r' , '0444' )
146
+ await testChmod ( '0777' , 'a=x' , '0111' )
147
+ await testChmod ( '0777' , 'a=w' , '0222' )
148
+ await testChmod ( '0777' , 'a=r' , '0444' )
140
149
} )
141
150
142
151
it ( 'should update modes with multiple symbolic notation' , async ( ) => {
@@ -149,4 +158,115 @@ describe('chmod', () => {
149
158
await testChmod ( '0000' , '+t' , '1000' )
150
159
await testChmod ( '0000' , '+s' , '6000' )
151
160
} )
161
+
162
+ it ( 'should apply special execute permissions to world' , async ( ) => {
163
+ const path = `/foo-${ Date . now ( ) } `
164
+ const sub = `${ path } /sub`
165
+ const file = `${ path } /sub/foo.txt`
166
+ const bin = `${ path } /sub/bar`
167
+
168
+ await mfs . mkdir ( sub , {
169
+ parents : true
170
+ } )
171
+ await mfs . touch ( file )
172
+ await mfs . touch ( bin )
173
+
174
+ await mfs . chmod ( path , 0o644 , {
175
+ recursive : true
176
+ } )
177
+ await mfs . chmod ( bin , 'u+x' )
178
+
179
+ expect ( ( await mfs . stat ( path ) ) . mode ) . to . equal ( 0o644 )
180
+ expect ( ( await mfs . stat ( sub ) ) . mode ) . to . equal ( 0o644 )
181
+ expect ( ( await mfs . stat ( file ) ) . mode ) . to . equal ( 0o644 )
182
+ expect ( ( await mfs . stat ( bin ) ) . mode ) . to . equal ( 0o744 )
183
+
184
+ await mfs . chmod ( path , 'a+X' , {
185
+ recursive : true
186
+ } )
187
+
188
+ // directories should be world-executable
189
+ expect ( ( await mfs . stat ( path ) ) . mode ) . to . equal ( 0o755 )
190
+ expect ( ( await mfs . stat ( sub ) ) . mode ) . to . equal ( 0o755 )
191
+
192
+ // files without prior execute bit should be untouched
193
+ expect ( ( await mfs . stat ( file ) ) . mode ) . to . equal ( 0o644 )
194
+
195
+ // files with prior execute bit should now be world-executable
196
+ expect ( ( await mfs . stat ( bin ) ) . mode ) . to . equal ( 0o755 )
197
+ } )
198
+
199
+ it ( 'should apply special execute permissions to user' , async ( ) => {
200
+ const path = `/foo-${ Date . now ( ) } `
201
+ const sub = `${ path } /sub`
202
+ const file = `${ path } /sub/foo.txt`
203
+ const bin = `${ path } /sub/bar`
204
+
205
+ await mfs . mkdir ( sub , {
206
+ parents : true
207
+ } )
208
+ await mfs . touch ( file )
209
+ await mfs . touch ( bin )
210
+
211
+ await mfs . chmod ( path , 0o644 , {
212
+ recursive : true
213
+ } )
214
+ await mfs . chmod ( bin , 'u+x' )
215
+
216
+ expect ( ( await mfs . stat ( path ) ) . mode ) . to . equal ( 0o644 )
217
+ expect ( ( await mfs . stat ( sub ) ) . mode ) . to . equal ( 0o644 )
218
+ expect ( ( await mfs . stat ( file ) ) . mode ) . to . equal ( 0o644 )
219
+ expect ( ( await mfs . stat ( bin ) ) . mode ) . to . equal ( 0o744 )
220
+
221
+ await mfs . chmod ( path , 'u+X' , {
222
+ recursive : true
223
+ } )
224
+
225
+ // directories should be user executable
226
+ expect ( ( await mfs . stat ( path ) ) . mode ) . to . equal ( 0o744 )
227
+ expect ( ( await mfs . stat ( sub ) ) . mode ) . to . equal ( 0o744 )
228
+
229
+ // files without prior execute bit should be untouched
230
+ expect ( ( await mfs . stat ( file ) ) . mode ) . to . equal ( 0o644 )
231
+
232
+ // files with prior execute bit should now be user executable
233
+ expect ( ( await mfs . stat ( bin ) ) . mode ) . to . equal ( 0o744 )
234
+ } )
235
+
236
+ it ( 'should apply special execute permissions to user and group' , async ( ) => {
237
+ const path = `/foo-${ Date . now ( ) } `
238
+ const sub = `${ path } /sub`
239
+ const file = `${ path } /sub/foo.txt`
240
+ const bin = `${ path } /sub/bar`
241
+
242
+ await mfs . mkdir ( sub , {
243
+ parents : true
244
+ } )
245
+ await mfs . touch ( file )
246
+ await mfs . touch ( bin )
247
+
248
+ await mfs . chmod ( path , 0o644 , {
249
+ recursive : true
250
+ } )
251
+ await mfs . chmod ( bin , 'u+x' )
252
+
253
+ expect ( ( await mfs . stat ( path ) ) . mode ) . to . equal ( 0o644 )
254
+ expect ( ( await mfs . stat ( sub ) ) . mode ) . to . equal ( 0o644 )
255
+ expect ( ( await mfs . stat ( file ) ) . mode ) . to . equal ( 0o644 )
256
+ expect ( ( await mfs . stat ( bin ) ) . mode ) . to . equal ( 0o744 )
257
+
258
+ await mfs . chmod ( path , 'ug+X' , {
259
+ recursive : true
260
+ } )
261
+
262
+ // directories should be user and group executable
263
+ expect ( ( await mfs . stat ( path ) ) . mode ) . to . equal ( 0o754 )
264
+ expect ( ( await mfs . stat ( sub ) ) . mode ) . to . equal ( 0o754 )
265
+
266
+ // files without prior execute bit should be untouched
267
+ expect ( ( await mfs . stat ( file ) ) . mode ) . to . equal ( 0o644 )
268
+
269
+ // files with prior execute bit should now be user and group executable
270
+ expect ( ( await mfs . stat ( bin ) ) . mode ) . to . equal ( 0o754 )
271
+ } )
152
272
} )
0 commit comments