File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+ // Refs: https://github.com/nodejs/node/pull/12022
3
+ // If the cwd is deleted, Node cannot run files because the module system
4
+ // relies on uv_cwd(). The -e and -p flags still work though.
5
+ const common = require ( '../common' ) ;
6
+ const assert = require ( 'assert' ) ;
7
+
8
+ if ( common . isSunOS || common . isWindows || common . isAix ) {
9
+ // The current working directory cannot be removed on these platforms.
10
+ // Change this to common.skip() when this is no longer a known issue test.
11
+ assert . fail ( 'cannot rmdir current working directory' ) ;
12
+ return ;
13
+ }
14
+
15
+ const cp = require ( 'child_process' ) ;
16
+ const fs = require ( 'fs' ) ;
17
+
18
+ if ( process . argv [ 2 ] === 'child' ) {
19
+ // Do nothing.
20
+ } else {
21
+ common . refreshTmpDir ( ) ;
22
+ const dir = fs . mkdtempSync ( common . tmpDir + '/' ) ;
23
+ process . chdir ( dir ) ;
24
+ fs . rmdirSync ( dir ) ;
25
+ assert . throws ( process . cwd ,
26
+ / ^ E r r o r : E N O E N T : n o s u c h f i l e o r d i r e c t o r y , u v _ c w d $ / ) ;
27
+
28
+ const r = cp . spawnSync ( process . execPath , [ __filename , 'child' ] ) ;
29
+
30
+ assert . strictEqual ( r . status , 0 ) ;
31
+ assert . strictEqual ( r . signal , null ) ;
32
+ assert . strictEqual ( r . stdout . toString ( ) . trim ( ) , '' ) ;
33
+ assert . strictEqual ( r . stderr . toString ( ) . trim ( ) , '' ) ;
34
+ }
You can’t perform that action at this time.
0 commit comments