diff mbox series

[v3,25/30] t/test-lib-functions.sh: support `--date` in `test_commit_bulk()`

Message ID 890f6c4b9deb9e3bf02aa180c7ad4ced7f7b6a80.1716318089.git.me@ttaylorr.com (mailing list archive)
State Superseded
Headers show
Series pack-bitmap: pseudo-merge reachability bitmaps | expand

Commit Message

Taylor Blau May 21, 2024, 7:02 p.m. UTC
One of the tests we'll want to add for pseudo-merge bitmaps needs to be
able to generate a large number of commits at a specific date.

Support the `--date` option (with identical semantics to the `--date`
option for `test_commit()`) within `test_commit_bulk` as a prerequisite
for that.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 t/test-lib-functions.sh | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Jeff King May 23, 2024, 10:42 a.m. UTC | #1
On Tue, May 21, 2024 at 03:02:59PM -0400, Taylor Blau wrote:

> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
> index 862d80c9748..16fd585e34b 100644
> --- a/t/test-lib-functions.sh
> +++ b/t/test-lib-functions.sh
> @@ -458,6 +458,7 @@ test_commit_bulk () {
>  	indir=.
>  	ref=HEAD
>  	n=1
> +	notick=
>  	message='commit %s'
>  	filename='%s.t'
>  	contents='content %s'
> @@ -488,6 +489,12 @@ test_commit_bulk () {
>  			filename="${1#--*=}-%s.t"
>  			contents="${1#--*=} %s"
>  			;;
> +		--date)
> +			notick=yes
> +			GIT_COMMITTER_DATE="$2"
> +			GIT_AUTHOR_DATE="$2"
> +			shift
> +			;;

This gives all of the bulk commits the same date. Which is kind of
unrealistic. Conceivably you'd want to be set the starting date at some
old spot, and then tick forward from there. It may not matter much in
practice, though.

-Peff
Junio C Hamano May 23, 2024, 3:45 p.m. UTC | #2
Jeff King <peff@peff.net> writes:

> On Tue, May 21, 2024 at 03:02:59PM -0400, Taylor Blau wrote:
>
>> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
>> index 862d80c9748..16fd585e34b 100644
>> --- a/t/test-lib-functions.sh
>> +++ b/t/test-lib-functions.sh
>> @@ -458,6 +458,7 @@ test_commit_bulk () {
>>  	indir=.
>>  	ref=HEAD
>>  	n=1
>> +	notick=
>>  	message='commit %s'
>>  	filename='%s.t'
>>  	contents='content %s'
>> @@ -488,6 +489,12 @@ test_commit_bulk () {
>>  			filename="${1#--*=}-%s.t"
>>  			contents="${1#--*=} %s"
>>  			;;
>> +		--date)
>> +			notick=yes
>> +			GIT_COMMITTER_DATE="$2"
>> +			GIT_AUTHOR_DATE="$2"
>> +			shift
>> +			;;
>
> This gives all of the bulk commits the same date. Which is kind of
> unrealistic.

Yeah, giving this helper function a "--notick" option, without
adding this "--date" option, is a better design, I suspect.

The callers Taylor expected to use --date can set the _DATE
variables and pass "--notick", and callers that want the same
timestamp without caring which exact timestamp can just pass
"--notick" without futzing with _DATE variables.

Thanks.
Taylor Blau May 23, 2024, 6:23 p.m. UTC | #3
On Thu, May 23, 2024 at 08:45:24AM -0700, Junio C Hamano wrote:
> Jeff King <peff@peff.net> writes:
>
> > On Tue, May 21, 2024 at 03:02:59PM -0400, Taylor Blau wrote:
> >
> >> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
> >> index 862d80c9748..16fd585e34b 100644
> >> --- a/t/test-lib-functions.sh
> >> +++ b/t/test-lib-functions.sh
> >> @@ -458,6 +458,7 @@ test_commit_bulk () {
> >>  	indir=.
> >>  	ref=HEAD
> >>  	n=1
> >> +	notick=
> >>  	message='commit %s'
> >>  	filename='%s.t'
> >>  	contents='content %s'
> >> @@ -488,6 +489,12 @@ test_commit_bulk () {
> >>  			filename="${1#--*=}-%s.t"
> >>  			contents="${1#--*=} %s"
> >>  			;;
> >> +		--date)
> >> +			notick=yes
> >> +			GIT_COMMITTER_DATE="$2"
> >> +			GIT_AUTHOR_DATE="$2"
> >> +			shift
> >> +			;;
> >
> > This gives all of the bulk commits the same date. Which is kind of
> > unrealistic.
>
> Yeah, giving this helper function a "--notick" option, without
> adding this "--date" option, is a better design, I suspect.

Agreed. Thanks, both.

Thanks,
Taylor
diff mbox series

Patch

diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 862d80c9748..16fd585e34b 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -458,6 +458,7 @@  test_commit_bulk () {
 	indir=.
 	ref=HEAD
 	n=1
+	notick=
 	message='commit %s'
 	filename='%s.t'
 	contents='content %s'
@@ -488,6 +489,12 @@  test_commit_bulk () {
 			filename="${1#--*=}-%s.t"
 			contents="${1#--*=} %s"
 			;;
+		--date)
+			notick=yes
+			GIT_COMMITTER_DATE="$2"
+			GIT_AUTHOR_DATE="$2"
+			shift
+			;;
 		-*)
 			BUG "invalid test_commit_bulk option: $1"
 			;;
@@ -507,7 +514,10 @@  test_commit_bulk () {
 
 	while test "$total" -gt 0
 	do
-		test_tick &&
+		if test -z "$notick"
+		then
+			test_tick
+		fi &&
 		echo "commit $ref"
 		printf 'author %s <%s> %s\n' \
 			"$GIT_AUTHOR_NAME" \