@@ -71,7 +71,6 @@ runInEachFileSystem(() => {
71
71
}
72
72
return lockFileContents ;
73
73
} ) ;
74
- spyOn ( process , 'kill' ) . and . returnValue ( ) ;
75
74
76
75
const promise = locker . lock ( async ( ) => log . push ( 'fn()' ) ) ;
77
76
// The lock is now waiting on the lock-file becoming free, so no `fn()` in the log.
@@ -81,7 +80,6 @@ runInEachFileSystem(() => {
81
80
`(If you are sure no ngcc process is running then you should delete the lock-file at ${
82
81
lockFile . path } .)`
83
82
] ] ) ;
84
- expect ( process . kill ) . toHaveBeenCalledWith ( 188 , 0 ) ;
85
83
86
84
lockFileContents = null ;
87
85
// The lock-file has been removed, so we can create our own lock-file, call `fn()` and then
@@ -90,47 +88,6 @@ runInEachFileSystem(() => {
90
88
expect ( log ) . toEqual ( [ 'write()' , 'read() => 188' , 'write()' , 'fn()' , 'remove()' ] ) ;
91
89
} ) ;
92
90
93
- it ( 'should fail fast when waiting on a dead process' , async ( ) => {
94
- const fs = getFileSystem ( ) ;
95
- const log : string [ ] = [ ] ;
96
- const lockFile = new MockLockFile ( fs , log ) ;
97
- const logger = new MockLogger ( ) ;
98
- const locker = new AsyncLocker ( lockFile , logger , 100 , 10 ) ;
99
-
100
- let lockFileContents : string | null = '188' ;
101
- spyOn ( lockFile , 'write' ) . and . callFake ( ( ) => {
102
- log . push ( 'write()' ) ;
103
- if ( lockFileContents ) {
104
- throw { code : 'EEXIST' } ;
105
- }
106
- } ) ;
107
- spyOn ( lockFile , 'read' ) . and . callFake ( ( ) => {
108
- log . push ( 'read() => ' + lockFileContents ) ;
109
- if ( lockFileContents === null ) {
110
- throw { code : 'ENOENT' } ;
111
- }
112
- return lockFileContents ;
113
- } ) ;
114
- spyOn ( process , 'kill' ) . and . callFake ( ( ) => {
115
- throw { code : 'ESRCH' } ;
116
- } ) ;
117
-
118
- const promise = locker . lock ( async ( ) => log . push ( 'fn()' ) ) ;
119
- // The lock has already failed so no `fn()` in the log.
120
- expect ( log ) . toEqual ( [ 'write()' , 'read() => 188' , 'write()' , 'read() => 188' ] ) ;
121
- expect ( logger . logs . info ) . toEqual ( [ ] ) ;
122
- expect ( process . kill ) . toHaveBeenCalledWith ( 188 , 0 ) ;
123
- // Check that a missing process errors out.
124
- let error : Error ;
125
- await promise . catch ( e => error = e ) ;
126
- expect ( log ) . toEqual ( [ 'write()' , 'read() => 188' , 'write()' , 'read() => 188' ] ) ;
127
- expect ( error ! . message )
128
- . toEqual (
129
- `Lock found, but no process with PID 188 seems to be running.\n` +
130
- `(If you are sure no ngcc process is running then you should delete the lock-file at ${
131
- lockFile . path } .)`) ;
132
- } ) ;
133
-
134
91
it ( 'should extend the retry timeout if the other process locking the file changes' , async ( ) => {
135
92
const fs = getFileSystem ( ) ;
136
93
const log : string [ ] = [ ] ;
@@ -152,7 +109,6 @@ runInEachFileSystem(() => {
152
109
}
153
110
return lockFileContents ;
154
111
} ) ;
155
- spyOn ( process , 'kill' ) . and . returnValue ( ) ;
156
112
157
113
const promise = locker . lock ( async ( ) => log . push ( 'fn()' ) ) ;
158
114
// The lock is now waiting on the lock-file becoming free, so no `fn()` in the log.
@@ -162,7 +118,6 @@ runInEachFileSystem(() => {
162
118
`(If you are sure no ngcc process is running then you should delete the lock-file at ${
163
119
lockFile . path } .)`
164
120
] ] ) ;
165
- expect ( process . kill ) . toHaveBeenCalledWith ( 188 , 0 ) ;
166
121
167
122
lockFileContents = '444' ;
168
123
// The lock-file has been taken over by another process - wait for the next attempt
@@ -176,7 +131,6 @@ runInEachFileSystem(() => {
176
131
`(If you are sure no ngcc process is running then you should delete the lock-file at ${
177
132
lockFile . path } .)`]
178
133
] ) ;
179
- expect ( process . kill ) . toHaveBeenCalledWith ( 444 , 0 ) ;
180
134
181
135
lockFileContents = null ;
182
136
// The lock-file has been removed, so we can create our own lock-file, call `fn()` and
@@ -209,13 +163,11 @@ runInEachFileSystem(() => {
209
163
}
210
164
return lockFileContents ;
211
165
} ) ;
212
- spyOn ( process , 'kill' ) . and . returnValue ( ) ;
213
166
214
167
const promise = locker . lock ( async ( ) => log . push ( 'fn()' ) ) ;
215
168
216
169
// The lock is now waiting on the lock-file becoming free, so no `fn()` in the log.
217
170
expect ( log ) . toEqual ( [ 'write()' , 'read() => 188' ] ) ;
218
- expect ( process . kill ) . toHaveBeenCalledWith ( 188 , 0 ) ;
219
171
// Do not remove the lock-file and let the call to `lock()` timeout.
220
172
let error : Error ;
221
173
await promise . catch ( e => error = e ) ;
0 commit comments