@@ -567,54 +567,112 @@ func TestBomb(t *testing.T) {
567
567
568
568
repo := testRepo .Repository (t )
569
569
570
- refRoots , err := sizes .CollectReferences (ctx , repo , refGrouper {})
571
- require .NoError (t , err )
570
+ t .Run ("full" , func (t * testing.T ) {
571
+ refRoots , err := sizes .CollectReferences (ctx , repo , refGrouper {})
572
+ require .NoError (t , err )
572
573
573
- h , err := sizes .ScanRepositoryUsingGraph (
574
- ctx , repo ,
575
- refRoots , sizes .NameStyleFull , meter .NoProgressMeter ,
576
- )
577
- require .NoError (t , err )
574
+ roots := make ([]sizes.Root , 0 , len (refRoots ))
575
+ for _ , refRoot := range refRoots {
576
+ roots = append (roots , refRoot )
577
+ }
578
+
579
+ h , err := sizes .ScanRepositoryUsingGraph (
580
+ ctx , repo , roots , sizes .NameStyleFull , meter .NoProgressMeter ,
581
+ )
582
+ require .NoError (t , err )
583
+
584
+ assert .Equal (t , counts .Count32 (1 ), h .UniqueCommitCount , "unique commit count" )
585
+ assert .Equal (t , counts .Count64 (172 ), h .UniqueCommitSize , "unique commit size" )
586
+ assert .Equal (t , counts .Count32 (172 ), h .MaxCommitSize , "max commit size" )
587
+ assert .Equal (t , "refs/heads/master" , h .MaxCommitSizeCommit .BestPath (), "max commit size commit" )
588
+ assert .Equal (t , counts .Count32 (1 ), h .MaxHistoryDepth , "max history depth" )
589
+ assert .Equal (t , counts .Count32 (0 ), h .MaxParentCount , "max parent count" )
590
+ assert .Equal (t , "refs/heads/master" , h .MaxParentCountCommit .BestPath (), "max parent count commit" )
591
+
592
+ assert .Equal (t , counts .Count32 (10 ), h .UniqueTreeCount , "unique tree count" )
593
+ assert .Equal (t , counts .Count64 (2910 ), h .UniqueTreeSize , "unique tree size" )
594
+ assert .Equal (t , counts .Count64 (100 ), h .UniqueTreeEntries , "unique tree entries" )
595
+ assert .Equal (t , counts .Count32 (10 ), h .MaxTreeEntries , "max tree entries" )
596
+ assert .Equal (t , "refs/heads/master:d0/d0/d0/d0/d0/d0/d0/d0/d0" , h .MaxTreeEntriesTree .BestPath (), "max tree entries tree" )
597
+
598
+ assert .Equal (t , counts .Count32 (1 ), h .UniqueBlobCount , "unique blob count" )
599
+ assert .Equal (t , counts .Count64 (6 ), h .UniqueBlobSize , "unique blob size" )
600
+ assert .Equal (t , counts .Count32 (6 ), h .MaxBlobSize , "max blob size" )
601
+ assert .Equal (t , "refs/heads/master:d0/d0/d0/d0/d0/d0/d0/d0/d0/f0" , h .MaxBlobSizeBlob .BestPath (), "max blob size blob" )
602
+
603
+ assert .Equal (t , counts .Count32 (0 ), h .UniqueTagCount , "unique tag count" )
604
+ assert .Equal (t , counts .Count32 (0 ), h .MaxTagDepth , "max tag depth" )
605
+
606
+ assert .Equal (t , counts .Count32 (1 ), h .ReferenceCount , "reference count" )
607
+
608
+ assert .Equal (t , counts .Count32 (10 ), h .MaxPathDepth , "max path depth" )
609
+ assert .Equal (t , "refs/heads/master^{tree}" , h .MaxPathDepthTree .BestPath (), "max path depth tree" )
610
+ assert .Equal (t , counts .Count32 (29 ), h .MaxPathLength , "max path length" )
611
+ assert .Equal (t , "refs/heads/master^{tree}" , h .MaxPathLengthTree .BestPath (), "max path length tree" )
612
+
613
+ assert .Equal (t , counts .Count32 ((pow (10 , 10 )- 1 )/ (10 - 1 )), h .MaxExpandedTreeCount , "max expanded tree count" )
614
+ assert .Equal (t , "refs/heads/master^{tree}" , h .MaxExpandedTreeCountTree .BestPath (), "max expanded tree count tree" )
615
+ assert .Equal (t , counts .Count32 (0xffffffff ), h .MaxExpandedBlobCount , "max expanded blob count" )
616
+ assert .Equal (t , "refs/heads/master^{tree}" , h .MaxExpandedBlobCountTree .BestPath (), "max expanded blob count tree" )
617
+ assert .Equal (t , counts .Count64 (6 * pow (10 , 10 )), h .MaxExpandedBlobSize , "max expanded blob size" )
618
+ assert .Equal (t , "refs/heads/master^{tree}" , h .MaxExpandedBlobSizeTree .BestPath (), "max expanded blob size tree" )
619
+ assert .Equal (t , counts .Count32 (0 ), h .MaxExpandedLinkCount , "max expanded link count" )
620
+ assert .Nil (t , h .MaxExpandedLinkCountTree , "max expanded link count tree" )
621
+ assert .Equal (t , counts .Count32 (0 ), h .MaxExpandedSubmoduleCount , "max expanded submodule count" )
622
+ assert .Nil (t , h .MaxExpandedSubmoduleCountTree , "max expanded submodule count tree" )
623
+ })
624
+
625
+ t .Run ("partial" , func (t * testing.T ) {
626
+ name := "master:d0/d0"
627
+ oid , err := repo .ResolveObject (name )
628
+ require .NoError (t , err )
629
+ roots := []sizes.Root {sizes .NewExplicitRoot (name , oid )}
578
630
579
- assert .Equal (t , counts .Count32 (1 ), h .UniqueCommitCount , "unique commit count" )
580
- assert .Equal (t , counts .Count64 (172 ), h .UniqueCommitSize , "unique commit size" )
581
- assert .Equal (t , counts .Count32 (172 ), h .MaxCommitSize , "max commit size" )
582
- assert .Equal (t , "refs/heads/master" , h .MaxCommitSizeCommit .Path (), "max commit size commit" )
583
- assert .Equal (t , counts .Count32 (1 ), h .MaxHistoryDepth , "max history depth" )
584
- assert .Equal (t , counts .Count32 (0 ), h .MaxParentCount , "max parent count" )
585
- assert .Equal (t , "refs/heads/master" , h .MaxParentCountCommit .Path (), "max parent count commit" )
586
-
587
- assert .Equal (t , counts .Count32 (10 ), h .UniqueTreeCount , "unique tree count" )
588
- assert .Equal (t , counts .Count64 (2910 ), h .UniqueTreeSize , "unique tree size" )
589
- assert .Equal (t , counts .Count64 (100 ), h .UniqueTreeEntries , "unique tree entries" )
590
- assert .Equal (t , counts .Count32 (10 ), h .MaxTreeEntries , "max tree entries" )
591
- assert .Equal (t , "refs/heads/master:d0/d0/d0/d0/d0/d0/d0/d0/d0" , h .MaxTreeEntriesTree .Path (), "max tree entries tree" )
592
-
593
- assert .Equal (t , counts .Count32 (1 ), h .UniqueBlobCount , "unique blob count" )
594
- assert .Equal (t , counts .Count64 (6 ), h .UniqueBlobSize , "unique blob size" )
595
- assert .Equal (t , counts .Count32 (6 ), h .MaxBlobSize , "max blob size" )
596
- assert .Equal (t , "refs/heads/master:d0/d0/d0/d0/d0/d0/d0/d0/d0/f0" , h .MaxBlobSizeBlob .Path (), "max blob size blob" )
597
-
598
- assert .Equal (t , counts .Count32 (0 ), h .UniqueTagCount , "unique tag count" )
599
- assert .Equal (t , counts .Count32 (0 ), h .MaxTagDepth , "max tag depth" )
600
-
601
- assert .Equal (t , counts .Count32 (1 ), h .ReferenceCount , "reference count" )
602
-
603
- assert .Equal (t , counts .Count32 (10 ), h .MaxPathDepth , "max path depth" )
604
- assert .Equal (t , "refs/heads/master^{tree}" , h .MaxPathDepthTree .Path (), "max path depth tree" )
605
- assert .Equal (t , counts .Count32 (29 ), h .MaxPathLength , "max path length" )
606
- assert .Equal (t , "refs/heads/master^{tree}" , h .MaxPathLengthTree .Path (), "max path length tree" )
607
-
608
- assert .Equal (t , counts .Count32 ((pow (10 , 10 )- 1 )/ (10 - 1 )), h .MaxExpandedTreeCount , "max expanded tree count" )
609
- assert .Equal (t , "refs/heads/master^{tree}" , h .MaxExpandedTreeCountTree .Path (), "max expanded tree count tree" )
610
- assert .Equal (t , counts .Count32 (0xffffffff ), h .MaxExpandedBlobCount , "max expanded blob count" )
611
- assert .Equal (t , "refs/heads/master^{tree}" , h .MaxExpandedBlobCountTree .Path (), "max expanded blob count tree" )
612
- assert .Equal (t , counts .Count64 (6 * pow (10 , 10 )), h .MaxExpandedBlobSize , "max expanded blob size" )
613
- assert .Equal (t , "refs/heads/master^{tree}" , h .MaxExpandedBlobSizeTree .Path (), "max expanded blob size tree" )
614
- assert .Equal (t , counts .Count32 (0 ), h .MaxExpandedLinkCount , "max expanded link count" )
615
- assert .Nil (t , h .MaxExpandedLinkCountTree , "max expanded link count tree" )
616
- assert .Equal (t , counts .Count32 (0 ), h .MaxExpandedSubmoduleCount , "max expanded submodule count" )
617
- assert .Nil (t , h .MaxExpandedSubmoduleCountTree , "max expanded submodule count tree" )
631
+ h , err := sizes .ScanRepositoryUsingGraph (
632
+ ctx , repo , roots , sizes .NameStyleFull , meter .NoProgressMeter ,
633
+ )
634
+ require .NoError (t , err )
635
+
636
+ assert .Equal (t , counts .Count32 (0 ), h .UniqueCommitCount , "unique commit count" )
637
+ assert .Equal (t , counts .Count64 (0 ), h .UniqueCommitSize , "unique commit size" )
638
+ assert .Equal (t , counts .Count32 (0 ), h .MaxCommitSize , "max commit size" )
639
+ assert .Nil (t , h .MaxCommitSizeCommit )
640
+ assert .Equal (t , counts .Count32 (0 ), h .MaxHistoryDepth , "max history depth" )
641
+ assert .Equal (t , counts .Count32 (0 ), h .MaxParentCount , "max parent count" )
642
+ assert .Nil (t , h .MaxParentCountCommit , "max parent count commit" )
643
+
644
+ assert .Equal (t , counts .Count32 (8 ), h .UniqueTreeCount , "unique tree count" )
645
+ assert .Equal (t , counts .Count64 (2330 ), h .UniqueTreeSize , "unique tree size" )
646
+ assert .Equal (t , counts .Count64 (80 ), h .UniqueTreeEntries , "unique tree entries" )
647
+ assert .Equal (t , counts .Count32 (10 ), h .MaxTreeEntries , "max tree entries" )
648
+ assert .Equal (t , "master:d0/d0/d0/d0/d0/d0/d0/d0/d0" , h .MaxTreeEntriesTree .BestPath (), "max tree entries tree" )
649
+
650
+ assert .Equal (t , counts .Count32 (1 ), h .UniqueBlobCount , "unique blob count" )
651
+ assert .Equal (t , counts .Count64 (6 ), h .UniqueBlobSize , "unique blob size" )
652
+ assert .Equal (t , counts .Count32 (6 ), h .MaxBlobSize , "max blob size" )
653
+ assert .Equal (t , "master:d0/d0/d0/d0/d0/d0/d0/d0/d0/f0" , h .MaxBlobSizeBlob .BestPath (), "max blob size blob" )
654
+
655
+ assert .Equal (t , counts .Count32 (0 ), h .UniqueTagCount , "unique tag count" )
656
+ assert .Equal (t , counts .Count32 (0 ), h .MaxTagDepth , "max tag depth" )
657
+
658
+ assert .Equal (t , counts .Count32 (0 ), h .ReferenceCount , "reference count" )
659
+
660
+ assert .Equal (t , counts .Count32 (8 ), h .MaxPathDepth , "max path depth" )
661
+ assert .Equal (t , "master:d0/d0" , h .MaxPathDepthTree .BestPath (), "max path depth tree" )
662
+ assert .Equal (t , counts .Count32 (23 ), h .MaxPathLength , "max path length" )
663
+ assert .Equal (t , "master:d0/d0" , h .MaxPathLengthTree .BestPath (), "max path length tree" )
664
+
665
+ assert .Equal (t , counts .Count32 ((pow (10 , 8 )- 1 )/ (10 - 1 )), h .MaxExpandedTreeCount , "max expanded tree count" )
666
+ assert .Equal (t , "master:d0/d0" , h .MaxExpandedTreeCountTree .BestPath (), "max expanded tree count tree" )
667
+ assert .Equal (t , counts .Count32 (pow (10 , 8 )), h .MaxExpandedBlobCount , "max expanded blob count" )
668
+ assert .Equal (t , "master:d0/d0" , h .MaxExpandedBlobCountTree .BestPath (), "max expanded blob count tree" )
669
+ assert .Equal (t , counts .Count64 (6 * pow (10 , 8 )), h .MaxExpandedBlobSize , "max expanded blob size" )
670
+ assert .Equal (t , "master:d0/d0" , h .MaxExpandedBlobSizeTree .BestPath (), "max expanded blob size tree" )
671
+ assert .Equal (t , counts .Count32 (0 ), h .MaxExpandedLinkCount , "max expanded link count" )
672
+ assert .Nil (t , h .MaxExpandedLinkCountTree , "max expanded link count tree" )
673
+ assert .Equal (t , counts .Count32 (0 ), h .MaxExpandedSubmoduleCount , "max expanded submodule count" )
674
+ assert .Nil (t , h .MaxExpandedSubmoduleCountTree , "max expanded submodule count tree" )
675
+ })
618
676
}
619
677
620
678
func TestTaggedTags (t * testing.T ) {
@@ -650,9 +708,14 @@ func TestTaggedTags(t *testing.T) {
650
708
refRoots , err := sizes .CollectReferences (ctx , repo , refGrouper {})
651
709
require .NoError (t , err )
652
710
711
+ roots := make ([]sizes.Root , 0 , len (refRoots ))
712
+ for _ , refRoot := range refRoots {
713
+ roots = append (roots , refRoot )
714
+ }
715
+
653
716
h , err := sizes .ScanRepositoryUsingGraph (
654
717
context .Background (), repo ,
655
- refRoots , sizes .NameStyleNone , meter .NoProgressMeter ,
718
+ roots , sizes .NameStyleNone , meter .NoProgressMeter ,
656
719
)
657
720
require .NoError (t , err , "scanning repository" )
658
721
assert .Equal (t , counts .Count32 (3 ), h .MaxTagDepth , "tag depth" )
@@ -679,9 +742,14 @@ func TestFromSubdir(t *testing.T) {
679
742
refRoots , err := sizes .CollectReferences (ctx , repo , refGrouper {})
680
743
require .NoError (t , err )
681
744
745
+ roots := make ([]sizes.Root , 0 , len (refRoots ))
746
+ for _ , refRoot := range refRoots {
747
+ roots = append (roots , refRoot )
748
+ }
749
+
682
750
h , err := sizes .ScanRepositoryUsingGraph (
683
751
context .Background (), testRepo .Repository (t ),
684
- refRoots , sizes .NameStyleNone , meter .NoProgressMeter ,
752
+ roots , sizes .NameStyleNone , meter .NoProgressMeter ,
685
753
)
686
754
require .NoError (t , err , "scanning repository" )
687
755
assert .Equal (t , counts .Count32 (2 ), h .MaxPathDepth , "max path depth" )
@@ -738,10 +806,15 @@ func TestSubmodule(t *testing.T) {
738
806
mainRefRoots , err := sizes .CollectReferences (ctx , mainRepo , refGrouper {})
739
807
require .NoError (t , err )
740
808
809
+ mainRoots := make ([]sizes.Root , 0 , len (mainRefRoots ))
810
+ for _ , refRoot := range mainRefRoots {
811
+ mainRoots = append (mainRoots , refRoot )
812
+ }
813
+
741
814
// Analyze the main repo:
742
815
h , err := sizes .ScanRepositoryUsingGraph (
743
816
context .Background (), mainTestRepo .Repository (t ),
744
- mainRefRoots , sizes .NameStyleNone , meter .NoProgressMeter ,
817
+ mainRoots , sizes .NameStyleNone , meter .NoProgressMeter ,
745
818
)
746
819
require .NoError (t , err , "scanning repository" )
747
820
assert .Equal (t , counts .Count32 (2 ), h .UniqueBlobCount , "unique blob count" )
@@ -758,9 +831,14 @@ func TestSubmodule(t *testing.T) {
758
831
submRefRoots2 , err := sizes .CollectReferences (ctx , submRepo2 , refGrouper {})
759
832
require .NoError (t , err )
760
833
834
+ submRoots2 := make ([]sizes.Root , 0 , len (submRefRoots2 ))
835
+ for _ , refRoot := range submRefRoots2 {
836
+ submRoots2 = append (submRoots2 , refRoot )
837
+ }
838
+
761
839
h , err = sizes .ScanRepositoryUsingGraph (
762
840
context .Background (), submRepo2 ,
763
- submRefRoots2 , sizes .NameStyleNone , meter .NoProgressMeter ,
841
+ submRoots2 , sizes .NameStyleNone , meter .NoProgressMeter ,
764
842
)
765
843
require .NoError (t , err , "scanning repository" )
766
844
assert .Equal (t , counts .Count32 (2 ), h .UniqueBlobCount , "unique blob count" )
0 commit comments