@@ -2,112 +2,129 @@ use crate::{check_common, graph_and_expected, graph_and_expected_named};
22
33#[ test]
44fn single_parent ( ) {
5- let ( cg, refs) = graph_and_expected ( "single_parent.sh" , & [ "parent" , "child" ] ) ;
6- check_common ( & cg, & refs) ;
5+ for hash_kind in gix_hash:: Kind :: all ( ) {
6+ let ( cg, refs) = graph_and_expected ( * hash_kind, "single_parent.sh" , & [ "parent" , "child" ] ) ;
7+ check_common ( & cg, & refs) ;
78
8- assert_eq ! ( cg. commit_at( refs[ "parent" ] . pos( ) ) . generation( ) , 1 ) ;
9- assert_eq ! ( cg. commit_at( refs[ "child" ] . pos( ) ) . generation( ) , 2 ) ;
9+ assert_eq ! ( cg. commit_at( refs[ "parent" ] . pos( ) ) . generation( ) , 1 ) ;
10+ assert_eq ! ( cg. commit_at( refs[ "child" ] . pos( ) ) . generation( ) , 2 ) ;
11+ }
1012}
1113
1214#[ test]
1315fn single_commit_huge_dates_generation_v2_also_do_not_allow_huge_dates ( ) {
14- let ( cg, refs) = graph_and_expected_named ( "single_commit_huge_dates.sh" , "v2" , & [ "HEAD" ] ) ;
15- let info = & refs[ "HEAD" ] ;
16- let actual = cg. commit_by_id ( info. id ) . expect ( "present" ) ;
17- assert_eq ! (
18- actual. committer_timestamp( ) ,
19- 1 ,
20- "overflow happened, can't represent huge dates"
21- ) ;
22- assert_eq ! (
16+ for hash_kind in gix_hash:: Kind :: all ( ) {
17+ let ( cg, refs) = graph_and_expected_named ( * hash_kind, "single_commit_huge_dates.sh" , "v2" , & [ "HEAD" ] ) ;
18+ let info = & refs[ "HEAD" ] ;
19+ let actual = cg. commit_by_id ( info. id ) . expect ( "present" ) ;
20+ assert_eq ! (
21+ actual. committer_timestamp( ) ,
22+ 1 ,
23+ "overflow happened, can't represent huge dates"
24+ ) ;
25+ assert_eq ! (
2326 info. time. seconds, 68719476737 ,
2427 "this is the value we would want to see, but it's not possible in V2 either, as that is just about generations"
2528 ) ;
26- assert_eq ! ( actual. generation( ) , 1 , "generations are fine though" ) ;
29+ assert_eq ! ( actual. generation( ) , 1 , "generations are fine though" ) ;
30+ }
2731}
2832
2933#[ test]
3034fn single_commit_huge_dates_overflow_v1 ( ) {
31- let ( cg, refs) = graph_and_expected_named ( "single_commit_huge_dates.sh" , "v1" , & [ "HEAD" ] ) ;
32- let info = & refs[ "HEAD" ] ;
33- let actual = cg. commit_by_id ( info. id ) . expect ( "present" ) ;
34- assert_eq ! ( actual. committer_timestamp( ) , 1 , "overflow happened" ) ;
35- assert_eq ! (
36- info. time. seconds, 68719476737 ,
37- "this is the value we would want to see, but it's not possible in V1"
38- ) ;
39- assert_eq ! ( actual. generation( ) , 1 , "generations are fine though" ) ;
35+ for hash_kind in gix_hash:: Kind :: all ( ) {
36+ let ( cg, refs) = graph_and_expected_named ( * hash_kind, "single_commit_huge_dates.sh" , "v1" , & [ "HEAD" ] ) ;
37+ let info = & refs[ "HEAD" ] ;
38+ let actual = cg. commit_by_id ( info. id ) . expect ( "present" ) ;
39+ assert_eq ! ( actual. committer_timestamp( ) , 1 , "overflow happened" ) ;
40+ assert_eq ! (
41+ info. time. seconds, 68719476737 ,
42+ "this is the value we would want to see, but it's not possible in V1"
43+ ) ;
44+ assert_eq ! ( actual. generation( ) , 1 , "generations are fine though" ) ;
45+ }
4046}
4147
4248#[ test]
4349fn single_commit_future_64bit_dates_work ( ) {
44- let ( cg, refs) = graph_and_expected_named ( "single_commit_huge_dates.sh" , "max-date" , & [ "HEAD" ] ) ;
45- let info = & refs[ "HEAD" ] ;
46- let actual = cg. commit_by_id ( info. id ) . expect ( "present" ) ;
47- assert_eq ! (
50+ for hash_kind in gix_hash:: Kind :: all ( ) {
51+ let ( cg, refs) = graph_and_expected_named ( * hash_kind, "single_commit_huge_dates.sh" , "max-date" , & [ "HEAD" ] ) ;
52+ let info = & refs[ "HEAD" ] ;
53+ let actual = cg. commit_by_id ( info. id ) . expect ( "present" ) ;
54+ assert_eq ! (
4855 actual. committer_timestamp( ) ,
4956 info. time. seconds. try_into( ) . expect( "timestamps in bound" ) ,
5057 "this is close the highest representable value in the graph, like year 2500, so we are good for longer than I should care about"
5158 ) ;
52- assert_eq ! ( actual. generation( ) , 1 ) ;
59+ assert_eq ! ( actual. generation( ) , 1 ) ;
60+ }
5361}
5462
5563#[ test]
5664fn generation_numbers_overflow_is_handled_in_chained_graph ( ) {
5765 let names = [ "extra" , "old-2" , "future-2" , "old-1" , "future-1" ] ;
58- let ( cg, mut refs) = graph_and_expected ( "generation_number_overflow.sh" , & names) ;
59- for ( r, expected) in names
60- . iter ( )
61- . map ( |n| refs. remove ( n. to_owned ( ) ) . expect ( "present" ) )
62- . zip ( ( 1 ..=5 ) . rev ( ) )
63- {
64- assert_eq ! (
66+ for hash_kind in gix_hash:: Kind :: all ( ) {
67+ let ( cg, mut refs) = graph_and_expected ( * hash_kind, "generation_number_overflow.sh" , & names) ;
68+ for ( r, expected) in names
69+ . iter ( )
70+ . map ( |n| refs. remove ( n. to_owned ( ) ) . expect ( "present" ) )
71+ . zip ( ( 1 ..=5 ) . rev ( ) )
72+ {
73+ assert_eq ! (
6574 cg. commit_by_id( r. id) . expect( "present" ) . generation( ) ,
6675 expected,
6776 "actually, this test seems to have valid generation numbers from the get-go. How to repro the actual issue?"
6877 ) ;
78+ }
6979 }
7080}
7181
7282#[ test]
7383fn octopus_merges ( ) {
74- let ( cg, refs) = graph_and_expected (
75- "octopus_merges.sh" ,
76- & [
77- "root" ,
78- "parent1" ,
79- "parent2" ,
80- "parent3" ,
81- "parent4" ,
82- "three_parents" ,
83- "four_parents" ,
84- ] ,
85- ) ;
86- check_common ( & cg, & refs) ;
84+ for hash_kind in gix_hash:: Kind :: all ( ) {
85+ let ( cg, refs) = graph_and_expected (
86+ * hash_kind,
87+ "octopus_merges.sh" ,
88+ & [
89+ "root" ,
90+ "parent1" ,
91+ "parent2" ,
92+ "parent3" ,
93+ "parent4" ,
94+ "three_parents" ,
95+ "four_parents" ,
96+ ] ,
97+ ) ;
98+ check_common ( & cg, & refs) ;
8799
88- assert_eq ! ( cg. commit_at( refs[ "root" ] . pos( ) ) . generation( ) , 1 ) ;
89- assert_eq ! ( cg. commit_at( refs[ "parent1" ] . pos( ) ) . generation( ) , 2 ) ;
90- assert_eq ! ( cg. commit_at( refs[ "parent2" ] . pos( ) ) . generation( ) , 2 ) ;
91- assert_eq ! ( cg. commit_at( refs[ "parent3" ] . pos( ) ) . generation( ) , 2 ) ;
92- assert_eq ! ( cg. commit_at( refs[ "parent4" ] . pos( ) ) . generation( ) , 2 ) ;
93- assert_eq ! ( cg. commit_at( refs[ "three_parents" ] . pos( ) ) . generation( ) , 3 ) ;
94- assert_eq ! ( cg. commit_at( refs[ "four_parents" ] . pos( ) ) . generation( ) , 3 ) ;
100+ assert_eq ! ( cg. commit_at( refs[ "root" ] . pos( ) ) . generation( ) , 1 ) ;
101+ assert_eq ! ( cg. commit_at( refs[ "parent1" ] . pos( ) ) . generation( ) , 2 ) ;
102+ assert_eq ! ( cg. commit_at( refs[ "parent2" ] . pos( ) ) . generation( ) , 2 ) ;
103+ assert_eq ! ( cg. commit_at( refs[ "parent3" ] . pos( ) ) . generation( ) , 2 ) ;
104+ assert_eq ! ( cg. commit_at( refs[ "parent4" ] . pos( ) ) . generation( ) , 2 ) ;
105+ assert_eq ! ( cg. commit_at( refs[ "three_parents" ] . pos( ) ) . generation( ) , 3 ) ;
106+ assert_eq ! ( cg. commit_at( refs[ "four_parents" ] . pos( ) ) . generation( ) , 3 ) ;
107+ }
95108}
96109
97110#[ test]
98111fn single_commit ( ) {
99- let ( cg, refs) = graph_and_expected ( "single_commit.sh" , & [ "commit" ] ) ;
100- check_common ( & cg, & refs) ;
112+ for hash_kind in gix_hash:: Kind :: all ( ) {
113+ let ( cg, refs) = graph_and_expected ( * hash_kind, "single_commit.sh" , & [ "commit" ] ) ;
114+ check_common ( & cg, & refs) ;
101115
102- assert_eq ! ( cg. commit_at( refs[ "commit" ] . pos( ) ) . generation( ) , 1 ) ;
116+ assert_eq ! ( cg. commit_at( refs[ "commit" ] . pos( ) ) . generation( ) , 1 ) ;
117+ }
103118}
104119
105120#[ test]
106121fn two_parents ( ) {
107- let ( cg, refs) = graph_and_expected ( "two_parents.sh" , & [ "parent1" , "parent2" , "child" ] ) ;
108- check_common ( & cg, & refs) ;
122+ for hash_kind in gix_hash:: Kind :: all ( ) {
123+ let ( cg, refs) = graph_and_expected ( * hash_kind, "two_parents.sh" , & [ "parent1" , "parent2" , "child" ] ) ;
124+ check_common ( & cg, & refs) ;
109125
110- assert_eq ! ( cg. commit_at( refs[ "parent1" ] . pos( ) ) . generation( ) , 1 ) ;
111- assert_eq ! ( cg. commit_at( refs[ "parent2" ] . pos( ) ) . generation( ) , 1 ) ;
112- assert_eq ! ( cg. commit_at( refs[ "child" ] . pos( ) ) . generation( ) , 2 ) ;
126+ assert_eq ! ( cg. commit_at( refs[ "parent1" ] . pos( ) ) . generation( ) , 1 ) ;
127+ assert_eq ! ( cg. commit_at( refs[ "parent2" ] . pos( ) ) . generation( ) , 1 ) ;
128+ assert_eq ! ( cg. commit_at( refs[ "child" ] . pos( ) ) . generation( ) , 2 ) ;
129+ }
113130}
0 commit comments