Skip to content

Commit

Permalink
teach test_seq a -f option
Browse files Browse the repository at this point in the history
With some example conversions. Note that some prefer that the newline is
implied, and some would prefer that it can be supressed.
  • Loading branch information
peff committed Dec 10, 2024
1 parent caacdb5 commit 2170411
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 51 deletions.
4 changes: 2 additions & 2 deletions t/t0021-conversion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ test_expect_success 'required filter with absent smudge field' '
test_expect_success 'filtering large input to small output should use little memory' '
test_config filter.devnull.clean "cat >/dev/null" &&
test_config filter.devnull.required true &&
for i in $(test_seq 1 30); do printf "%1048576d" 1 || return 1; done >30MB &&
test_seq -f "%1048576d" 1 30 >30MB &&
echo "30MB filter=devnull" >.gitattributes &&
GIT_MMAP_LIMIT=1m GIT_ALLOC_LIMIT=1m git add 30MB
'
Expand All @@ -300,7 +300,7 @@ test_expect_success 'filter that does not read is fine' '
test_expect_success EXPENSIVE 'filter large file' '
test_config filter.largefile.smudge cat &&
test_config filter.largefile.clean cat &&
for i in $(test_seq 1 2048); do printf "%1048576d" 1 || return 1; done >2GB &&
test_seq -f "%1048576d" 1 2048 >2GB &&
echo "2GB filter=largefile" >.gitattributes &&
git add 2GB 2>err &&
test_must_be_empty err &&
Expand Down
13 changes: 5 additions & 8 deletions t/t0612-reftable-jgit-compatibility.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,11 @@ test_expect_success 'JGit can read multi-level index' '
cd repo &&
test_commit A &&
awk "
BEGIN {
print \"start\";
for (i = 0; i < 10000; i++)
printf \"create refs/heads/branch-%d HEAD\n\", i;
print \"commit\";
}
" >input &&
{
echo start &&
test_seq -f "create refs/heads/branch-%d HEAD" 10000 &&
echo commit
} >input &&
git update-ref --stdin <input &&
test_same_refs &&
Expand Down
24 changes: 4 additions & 20 deletions t/t0613-reftable-write-options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,7 @@ test_expect_success 'many refs results in multiple blocks' '
(
cd repo &&
test_commit initial &&
for i in $(test_seq 200)
do
printf "update refs/heads/branch-%d HEAD\n" "$i" ||
return 1
done >input &&
test_seq -f "update refs/heads/branch-%d HEAD" 200 >input &&
git update-ref --stdin <input &&
git pack-refs &&
Expand Down Expand Up @@ -177,11 +173,7 @@ test_expect_success 'restart interval at every single record' '
(
cd repo &&
test_commit initial &&
for i in $(test_seq 10)
do
printf "update refs/heads/branch-%d HEAD\n" "$i" ||
return 1
done >input &&
test_seq -f "update refs/heads/branch-%d HEAD" 10 >input &&
git update-ref --stdin <input &&
git -c reftable.restartInterval=1 pack-refs &&
Expand Down Expand Up @@ -221,11 +213,7 @@ test_expect_success 'object index gets written by default with ref index' '
(
cd repo &&
test_commit initial &&
for i in $(test_seq 5)
do
printf "update refs/heads/branch-%d HEAD\n" "$i" ||
return 1
done >input &&
test_seq -f "update refs/heads/branch-%d HEAD" 5 >input &&
git update-ref --stdin <input &&
git -c reftable.blockSize=100 pack-refs &&
Expand Down Expand Up @@ -257,11 +245,7 @@ test_expect_success 'object index can be disabled' '
(
cd repo &&
test_commit initial &&
for i in $(test_seq 5)
do
printf "update refs/heads/branch-%d HEAD\n" "$i" ||
return 1
done >input &&
test_seq -f "update refs/heads/branch-%d HEAD" 5 >input &&
git update-ref --stdin <input &&
git -c reftable.blockSize=100 -c reftable.indexObjects=false pack-refs &&
Expand Down
10 changes: 2 additions & 8 deletions t/t1400-update-ref.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1380,21 +1380,15 @@ test_expect_success 'fails with duplicate ref update via symref' '

test_expect_success ULIMIT_FILE_DESCRIPTORS 'large transaction creating branches does not burst open file limit' '
(
for i in $(test_seq 33)
do
echo "create refs/heads/$i HEAD" || exit 1
done >large_input &&
test_seq -f "create refs/heads/%d HEAD" 33 >large_input &&
run_with_limited_open_files git update-ref --stdin <large_input &&
git rev-parse --verify -q refs/heads/33
)
'

test_expect_success ULIMIT_FILE_DESCRIPTORS 'large transaction deleting branches does not burst open file limit' '
(
for i in $(test_seq 33)
do
echo "delete refs/heads/$i HEAD" || exit 1
done >large_input &&
test_seq -f "delete refs/heads/%d HEAD" 33 >large_input &&
run_with_limited_open_files git update-ref --stdin <large_input &&
test_must_fail git rev-parse --verify -q refs/heads/33
)
Expand Down
5 changes: 1 addition & 4 deletions t/t5004-archive-corner-cases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,7 @@ test_expect_success EXPENSIVE,UNZIP,UNZIP_ZIP64_SUPPORT \
blob=$(echo $s | git hash-object -w --stdin) &&
# create tree containing 65500 entries of that blob
for i in $(test_seq 1 65500)
do
echo "100644 blob $blob $i" || return 1
done >tree &&
test_seq -f "100644 blob $blob\t%d" 1 65500 >tree &&
tree=$(git mktree <tree) &&
# zip it, creating an archive a bit bigger than 4GB
Expand Down
10 changes: 2 additions & 8 deletions t/t6422-merge-rename-corner-cases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1163,10 +1163,7 @@ test_conflicts_with_adds_and_renames() {
cd simple_${sideL}_${sideR} &&

# Create some related files now
for i in $(test_seq 1 10)
do
echo Random base content line $i
done >file_v1 &&
test_seq -f "Random base content line %d" 1 10 >file_v1 &&
cp file_v1 file_v2 &&
echo modification >>file_v2 &&

Expand Down Expand Up @@ -1310,10 +1307,7 @@ test_setup_nested_conflicts_from_rename_rename () {
cd nested_conflicts_from_rename_rename &&

# Create some related files now
for i in $(test_seq 1 10)
do
echo Random base content line $i
done >file_v1 &&
test_seq -f "Random base content line %d" 1 10 >file_v1 &&

cp file_v1 file_v2 &&
cp file_v1 file_v3 &&
Expand Down
9 changes: 8 additions & 1 deletion t/test-lib-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,13 @@ test_cmp_fspath () {
# from 1.

test_seq () {
local fmt="%d"
case "$1" in
-f)
fmt="$2"
shift 2
;;
esac
case $# in
1) set 1 "$@" ;;
2) ;;
Expand All @@ -1447,7 +1454,7 @@ test_seq () {
test_seq_counter__=$1
while test "$test_seq_counter__" -le "$2"
do
echo "$test_seq_counter__"
printf "$fmt\n" "$test_seq_counter__"
test_seq_counter__=$(( $test_seq_counter__ + 1 ))
done
}
Expand Down

0 comments on commit 2170411

Please sign in to comment.