@@ -246,6 +246,50 @@ describe.sequential("install all", () => {
246246 "f-0.0.1/package.oo.yaml" ,
247247 ] ) ) ;
248248 } ) ;
249+
250+ it ( "should fail with cancel signal" , async ( ctx ) => {
251+ const p = fixture ( "install_all" ) ;
252+
253+ // publish `remote_storage` to registry
254+ {
255+ const remoteStorage = path . join ( p , "remote_storage" ) ;
256+ await Promise . all ( [
257+ publish ( path . join ( remoteStorage , "a-0.0.1" ) , ctx . registry . endpoint , "fake-token" ) ,
258+ publish ( path . join ( remoteStorage , "b-0.0.1" ) , ctx . registry . endpoint , "fake-token" ) ,
259+ publish ( path . join ( remoteStorage , "c-0.0.2" ) , ctx . registry . endpoint , "fake-token" ) ,
260+ publish ( path . join ( remoteStorage , "d-0.0.1" ) , ctx . registry . endpoint , "fake-token" ) ,
261+ publish ( path . join ( remoteStorage , "e-0.0.1" ) , ctx . registry . endpoint , "fake-token" ) ,
262+ publish ( path . join ( remoteStorage , "e-0.0.2" ) , ctx . registry . endpoint , "fake-token" ) ,
263+ publish ( path . join ( remoteStorage , "f-0.0.1" ) , ctx . registry . endpoint , "fake-token" ) ,
264+ publish ( path . join ( remoteStorage , "e-0.0.3" ) , ctx . registry . endpoint , "fake-token" ) ,
265+ ] ) ;
266+ }
267+
268+ // Copy `local_storage` to distDir
269+ const distDir = await tempDir ( ) ;
270+ {
271+ const localStorage = path . join ( p , "local_storage" ) ;
272+ await Promise . all ( [
273+ copyDir ( path . join ( localStorage , "c-0.0.1" ) , path . join ( distDir , "c-0.0.1" ) ) ,
274+ copyDir ( path . join ( localStorage , "e-0.0.1" ) , path . join ( distDir , "e-0.0.1" ) ) ,
275+ ] ) ;
276+ }
277+
278+ // Copy `entry` to workdir
279+ await copyDir ( path . join ( p , "entry" ) , ctx . workdir ) ;
280+
281+ const controller = new AbortController ( ) ;
282+ controller . abort ( ) ;
283+
284+ await expect ( install ( {
285+ all : true ,
286+ token : "fake-token" ,
287+ workdir : ctx . workdir ,
288+ distDir,
289+ registry : ctx . registry . endpoint ,
290+ cancelSignal : controller . signal ,
291+ } ) ) . rejects . toThrow ( "This operation was aborted" ) ;
292+ } ) ;
249293} ) ;
250294
251295describe . sequential ( "install deps" , ( ) => {
@@ -559,6 +603,49 @@ describe.sequential("install deps", () => {
559603 } ,
560604 } ) ;
561605 } ) ;
606+
607+ it ( "should fail with cancel signal" , async ( ctx ) => {
608+ const p = fixture ( "install_deps" ) ;
609+
610+ // publish `remote_storage` to registry
611+ {
612+ const remoteStorage = path . join ( p , "remote_storage" ) ;
613+ await Promise . all ( [
614+ publish ( path . join ( remoteStorage , "a-0.0.2" ) , ctx . registry . endpoint , "fake-token" ) ,
615+ publish ( path . join ( remoteStorage , "b-0.0.1" ) , ctx . registry . endpoint , "fake-token" ) ,
616+ publish ( path . join ( remoteStorage , "c-0.0.1" ) , ctx . registry . endpoint , "fake-token" ) ,
617+ publish ( path . join ( remoteStorage , "d-0.0.1" ) , ctx . registry . endpoint , "fake-token" ) ,
618+ ] ) ;
619+ await publish ( path . join ( remoteStorage , "b-0.0.2" ) , ctx . registry . endpoint , "fake-token" ) ;
620+ }
621+
622+ // Copy `local_storage` to distDir
623+ const distDir = await tempDir ( ) ;
624+ {
625+ const localStorage = path . join ( p , "local_storage" ) ;
626+ await copyDir ( path . join ( localStorage , "a-0.0.1" ) , path . join ( distDir , "a-0.0.1" ) ) ;
627+ }
628+
629+ // Copy `entry` to workdir
630+ await copyDir ( path . join ( p , "entry" ) , ctx . workdir ) ;
631+
632+ const controller = new AbortController ( ) ;
633+ controller . abort ( ) ;
634+
635+ await expect ( install ( {
636+ deps : [
637+ { name : "a" } ,
638+ { name : "b" } ,
639+ { name : "c" , version : "0.0.1" } ,
640+ ] ,
641+ save : true ,
642+ token : "fake-token" ,
643+ workdir : ctx . workdir ,
644+ distDir,
645+ registry : ctx . registry . endpoint ,
646+ cancelSignal : controller . signal ,
647+ } ) ) . rejects . toThrow ( "This operation was aborted" ) ;
648+ } ) ;
562649} ) ;
563650
564651describe . sequential ( "unknown type" , ( ) => {
0 commit comments