@@ -9,6 +9,7 @@ const execa = require('execa');
9
9
const { unlinkAsync } = require ( '../helpers/fs' ) ;
10
10
const testBin = require ( '../helpers/test-bin' ) ;
11
11
const port1 = require ( '../ports-map' ) . cli [ 0 ] ;
12
+ const timer = require ( '../helpers/timer' ) ;
12
13
13
14
const httpsCertificateDirectory = resolve (
14
15
__dirname ,
@@ -119,6 +120,47 @@ describe('CLI', () => {
119
120
. catch ( done ) ;
120
121
} ) ;
121
122
123
+ it ( 'without --stdin, with stdin "end" event should time out' , async ( done ) => {
124
+ const configPath = resolve (
125
+ __dirname ,
126
+ '../fixtures/simple-config/webpack.config.js'
127
+ ) ;
128
+ const childProcess = testBin ( false , configPath , true ) ;
129
+
130
+ childProcess . once ( 'exit' , ( ) => {
131
+ expect ( childProcess . killed ) . toBeTruthy ( ) ;
132
+ done ( ) ;
133
+ } ) ;
134
+
135
+ await timer ( 500 ) ;
136
+ // this is meant to confirm that it does not have any effect on the running process
137
+ // since options.stdin is not enabled
138
+ childProcess . stdin . emit ( 'end' ) ;
139
+ childProcess . stdin . pause ( ) ;
140
+
141
+ await timer ( 500 ) ;
142
+
143
+ childProcess . kill ( ) ;
144
+ } ) ;
145
+
146
+ it ( '--stdin, with "end" event should exit without time out' , async ( ) => {
147
+ const configPath = resolve (
148
+ __dirname ,
149
+ '../fixtures/simple-config/webpack.config.js'
150
+ ) ;
151
+ const childProcess = testBin ( '--stdin' , configPath ) ;
152
+
153
+ await timer ( 500 ) ;
154
+
155
+ childProcess . stdin . emit ( 'end' ) ;
156
+ childProcess . stdin . pause ( ) ;
157
+
158
+ const { exitCode, timedOut, killed } = await childProcess ;
159
+ expect ( exitCode ) . toEqual ( 0 ) ;
160
+ expect ( timedOut ) . toBeFalsy ( ) ;
161
+ expect ( killed ) . toBeFalsy ( ) ;
162
+ } ) ;
163
+
122
164
it ( 'should accept the promise function of webpack.config.js' , async ( ) => {
123
165
try {
124
166
const { exitCode } = await testBin (
0 commit comments