@@ -423,5 +423,217 @@ sdk: ^3.8.0
423423 });
424424 }),
425425 );
426+
427+ test (
428+ 'completes normally '
429+ 'and ignores example by default (non-recursive)' ,
430+ withRunner ((commandRunner, logger, pubUpdater, printLogs) async {
431+ final tempDirectory = Directory .systemTemp.createTempSync ();
432+ addTearDown (() => tempDirectory.deleteSync (recursive: true ));
433+
434+ final directoryA = Directory (path.join (tempDirectory.path, 'plugin' ));
435+
436+ File (
437+ path.join (directoryA.path, 'pubspec.yaml' ),
438+ )
439+ ..createSync (recursive: true )
440+ ..writeAsStringSync ('''
441+ name: plugin
442+ version: 0.1.0
443+
444+ environment:
445+ sdk: ^3.8.0
446+ ''' );
447+
448+ File (
449+ path.join (directoryA.path, 'example' , 'pubspec.yaml' ),
450+ )
451+ ..createSync (recursive: true )
452+ ..writeAsStringSync ('''
453+ name: example
454+ version: 0.1.0
455+
456+ environment:
457+ sdk: ^3.8.0
458+ ''' );
459+
460+ final result = await commandRunner.run ([
461+ 'packages' ,
462+ 'get' ,
463+ '${tempDirectory .path }/plugin' ,
464+ ]);
465+
466+ expect (result, equals (ExitCode .success.code));
467+ verify (() {
468+ logger.progress (
469+ any (
470+ that: contains (
471+ '''Running "flutter pub get" in .''' ,
472+ ),
473+ ),
474+ );
475+ }).called (1 );
476+
477+ verifyNever (() {
478+ logger.progress (
479+ any (
480+ that: contains (
481+ '''Running "flutter pub get" in example''' ,
482+ ),
483+ ),
484+ );
485+ });
486+ }),
487+ );
488+
489+ test (
490+ 'completes normally '
491+ 'and does not ignore example when is recursive' ,
492+ withRunner ((commandRunner, logger, pubUpdater, printLogs) async {
493+ final tempDirectory = Directory .systemTemp.createTempSync ();
494+ addTearDown (() => tempDirectory.deleteSync (recursive: true ));
495+
496+ final directoryA = Directory (path.join (tempDirectory.path, 'plugin' ));
497+
498+ File (
499+ path.join (directoryA.path, 'pubspec.yaml' ),
500+ )
501+ ..createSync (recursive: true )
502+ ..writeAsStringSync ('''
503+ name: plugin
504+ version: 0.1.0
505+
506+ environment:
507+ sdk: ^3.8.0
508+ ''' );
509+
510+ File (
511+ path.join (directoryA.path, 'example' , 'pubspec.yaml' ),
512+ )
513+ ..createSync (recursive: true )
514+ ..writeAsStringSync ('''
515+ name: example
516+ version: 0.1.0
517+
518+ environment:
519+ sdk: ^3.8.0
520+ ''' );
521+
522+ final result = await commandRunner.run ([
523+ 'packages' ,
524+ 'get' ,
525+ '--recursive' ,
526+ '${tempDirectory .path }/plugin' ,
527+ ]);
528+
529+ expect (result, equals (ExitCode .success.code));
530+
531+ verify (() {
532+ logger.progress (
533+ any (
534+ that: contains (
535+ '''Running "flutter pub get" in . ''' ,
536+ ),
537+ ),
538+ );
539+ }).called (1 );
540+
541+ verify (() {
542+ logger.progress (
543+ any (
544+ that: contains (
545+ '''Running "flutter pub get" in ./example''' ,
546+ ),
547+ ),
548+ );
549+ }).called (1 );
550+ }),
551+ );
552+
553+ test (
554+ 'completes normally '
555+ 'and ignores example when using --ignore=example (recursive)' ,
556+ withRunner ((commandRunner, logger, pubUpdater, printLogs) async {
557+ final tempDirectory = Directory .systemTemp.createTempSync ();
558+ addTearDown (() => tempDirectory.deleteSync (recursive: true ));
559+
560+ final directoryA = Directory (path.join (tempDirectory.path, 'plugin' ));
561+
562+ File (
563+ path.join (directoryA.path, 'pubspec.yaml' ),
564+ )
565+ ..createSync (recursive: true )
566+ ..writeAsStringSync ('''
567+ name: plugin
568+ version: 0.1.0
569+
570+ environment:
571+ sdk: ^3.8.0
572+ ''' );
573+
574+ File (
575+ path.join (directoryA.path, 'example' , 'pubspec.yaml' ),
576+ )
577+ ..createSync (recursive: true )
578+ ..writeAsStringSync ('''
579+ name: example
580+ version: 0.1.0
581+
582+ environment:
583+ sdk: ^3.8.0
584+ ''' );
585+
586+ File (
587+ path.join (directoryA.path, 'my_sub_package' , 'pubspec.yaml' ),
588+ )
589+ ..createSync (recursive: true )
590+ ..writeAsStringSync ('''
591+ name: my_sub_package
592+ version: 0.1.0
593+
594+ environment:
595+ sdk: ^3.8.0
596+ ''' );
597+
598+ final result = await commandRunner.run ([
599+ 'packages' ,
600+ 'get' ,
601+ '--recursive' ,
602+ '--ignore=example' ,
603+ '${tempDirectory .path }/plugin' ,
604+ ]);
605+
606+ expect (result, equals (ExitCode .success.code));
607+ verify (() {
608+ logger.progress (
609+ any (
610+ that: contains (
611+ '''Running "flutter pub get" in . ''' ,
612+ ),
613+ ),
614+ );
615+ }).called (1 );
616+
617+ verify (() {
618+ logger.progress (
619+ any (
620+ that: contains (
621+ '''Running "flutter pub get" in ./my_sub_package''' ,
622+ ),
623+ ),
624+ );
625+ }).called (1 );
626+
627+ verifyNever (() {
628+ logger.progress (
629+ any (
630+ that: contains (
631+ '''Running "flutter pub get" in example''' ,
632+ ),
633+ ),
634+ );
635+ });
636+ }),
637+ );
426638 });
427639}
0 commit comments