@@ -246,7 +246,7 @@ describe("Compiler", () => {
246246 } ) ;
247247 } ) ;
248248 } ) ;
249- it ( "should not emit on errors" , function ( done ) {
249+ it ( "should not emit on errors" , function ( done ) {
250250 const compiler = webpack ( {
251251 context : __dirname ,
252252 mode : "production" ,
@@ -282,5 +282,154 @@ describe("Compiler", () => {
282282 return done ( new Error ( "Bundle should not be created on error" ) ) ;
283283 done ( ) ;
284284 } ) ;
285+ } ) ;
286+ it ( "should not be run twice at a time (run)" , function ( done ) {
287+ const compiler = webpack ( {
288+ context : __dirname ,
289+ mode : "production" ,
290+ entry : "./c" ,
291+ output : {
292+ path : "/" ,
293+ filename : "bundle.js"
294+ }
295+ } ) ;
296+ compiler . outputFileSystem = new MemoryFs ( ) ;
297+ compiler . run ( ( err , stats ) => {
298+ if ( err ) return done ( err ) ;
299+ } ) ;
300+ compiler . run ( ( err , stats ) => {
301+ if ( err ) return done ( ) ;
302+ } ) ;
303+ } ) ;
304+ it ( "should not be run twice at a time (watch)" , function ( done ) {
305+ const compiler = webpack ( {
306+ context : __dirname ,
307+ mode : "production" ,
308+ entry : "./c" ,
309+ output : {
310+ path : "/" ,
311+ filename : "bundle.js"
312+ }
313+ } ) ;
314+ compiler . outputFileSystem = new MemoryFs ( ) ;
315+ compiler . watch ( { } , ( err , stats ) => {
316+ if ( err ) return done ( err ) ;
317+ } ) ;
318+ compiler . watch ( { } , ( err , stats ) => {
319+ if ( err ) return done ( ) ;
320+ } ) ;
321+ } ) ;
322+ it ( "should not be run twice at a time (run - watch)" , function ( done ) {
323+ const compiler = webpack ( {
324+ context : __dirname ,
325+ mode : "production" ,
326+ entry : "./c" ,
327+ output : {
328+ path : "/" ,
329+ filename : "bundle.js"
330+ }
331+ } ) ;
332+ compiler . outputFileSystem = new MemoryFs ( ) ;
333+ compiler . run ( ( err , stats ) => {
334+ if ( err ) return done ( err ) ;
335+ } ) ;
336+ compiler . watch ( { } , ( err , stats ) => {
337+ if ( err ) return done ( ) ;
338+ } ) ;
339+ } ) ;
340+ it ( "should not be run twice at a time (watch - run)" , function ( done ) {
341+ const compiler = webpack ( {
342+ context : __dirname ,
343+ mode : "production" ,
344+ entry : "./c" ,
345+ output : {
346+ path : "/" ,
347+ filename : "bundle.js"
348+ }
349+ } ) ;
350+ compiler . outputFileSystem = new MemoryFs ( ) ;
351+ compiler . watch ( { } , ( err , stats ) => {
352+ if ( err ) return done ( err ) ;
353+ } ) ;
354+ compiler . run ( ( err , stats ) => {
355+ if ( err ) return done ( ) ;
356+ } ) ;
357+ } ) ;
358+ it ( "should not be run twice at a time (instance cb)" , function ( done ) {
359+ const compiler = webpack ( {
360+ context : __dirname ,
361+ mode : "production" ,
362+ entry : "./c" ,
363+ output : {
364+ path : "/" ,
365+ filename : "bundle.js"
366+ }
367+ } , ( ) => { } ) ;
368+ compiler . outputFileSystem = new MemoryFs ( ) ;
369+ compiler . run ( ( err , stats ) => {
370+ if ( err ) return done ( ) ;
371+ } ) ;
372+ } ) ;
373+ it ( "should run again correctly after first compilation" , function ( done ) {
374+ const compiler = webpack ( {
375+ context : __dirname ,
376+ mode : "production" ,
377+ entry : "./c" ,
378+ output : {
379+ path : "/" ,
380+ filename : "bundle.js"
381+ }
382+ } ) ;
383+ compiler . outputFileSystem = new MemoryFs ( ) ;
384+ compiler . run ( ( err , stats ) => {
385+ if ( err ) return done ( err ) ;
386+
387+ compiler . run ( ( err , stats ) => {
388+ if ( err ) return done ( err ) ;
389+ done ( )
390+ } ) ;
391+ } ) ;
392+ } ) ;
393+ it ( "should watch again correctly after first compilation" , function ( done ) {
394+ const compiler = webpack ( {
395+ context : __dirname ,
396+ mode : "production" ,
397+ entry : "./c" ,
398+ output : {
399+ path : "/" ,
400+ filename : "bundle.js"
401+ }
402+ } ) ;
403+ compiler . outputFileSystem = new MemoryFs ( ) ;
404+ compiler . run ( ( err , stats ) => {
405+ if ( err ) return done ( err ) ;
406+
407+ compiler . watch ( { } , ( err , stats ) => {
408+ if ( err ) return done ( err ) ;
409+ done ( )
410+ } ) ;
411+ } ) ;
412+ } ) ;
413+ it ( "should run again correctly after first closed watch" , function ( done ) {
414+ const compiler = webpack ( {
415+ context : __dirname ,
416+ mode : "production" ,
417+ entry : "./c" ,
418+ output : {
419+ path : "/" ,
420+ filename : "bundle.js"
421+ }
422+ } ) ;
423+ compiler . outputFileSystem = new MemoryFs ( ) ;
424+ const watching = compiler . watch ( { } , ( err , stats ) => {
425+ if ( err ) return done ( err ) ;
426+ done ( )
427+ } ) ;
428+ watching . close ( ( ) => {
429+ compiler . run ( ( err , stats ) => {
430+ if ( err ) return done ( err ) ;
431+ done ( )
432+ } ) ;
433+ } )
285434 } ) ;
286435} ) ;
0 commit comments