Skip to content

Commit 88ed7b8

Browse files
pks-tgitster
authored andcommitted
t0021: refactor generate_random_characters() to not depend on Perl
The `generate_random_characters()` helper function generates N random characters in the range 'a-z' and writes them into a file. The logic currently uses Perl, but it can be adapted rather easily by: - Making `test-tool genrandom` generate an infinite stream. - Using `tr -dc` to strip all characters which aren't in the range of 'a-z'. - Using `test_copy_bytes()` to copy the first N bytes. This allows us to drop the PERL_TEST_HELPERS prerequisite. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cee137b commit 88ed7b8

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

t/t0021-conversion.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ EOF
2020
generate_random_characters () {
2121
LEN=$1
2222
NAME=$2
23-
test-tool genrandom some-seed $LEN |
24-
perl -pe "s/./chr((ord($&) % 26) + ord('a'))/sge" >"$TEST_ROOT/$NAME"
23+
test-tool genrandom some-seed | tr -dc 'a-z' | test_copy_bytes "$LEN" >"$TEST_ROOT/$NAME"
2524
}
2625

2726
filter_git () {
@@ -619,7 +618,7 @@ test_expect_success 'required process filter should be used only for "clean" ope
619618
)
620619
'
621620

622-
test_expect_success PERL_TEST_HELPERS 'required process filter should process multiple packets' '
621+
test_expect_success 'required process filter should process multiple packets' '
623622
test_config_global filter.protocol.process "test-tool rot13-filter --log=debug.log clean smudge" &&
624623
test_config_global filter.protocol.required true &&
625624
@@ -684,7 +683,7 @@ test_expect_success PERL_TEST_HELPERS 'required process filter should process mu
684683
)
685684
'
686685

687-
test_expect_success PERL_TEST_HELPERS 'required process filter with clean error should fail' '
686+
test_expect_success 'required process filter with clean error should fail' '
688687
test_config_global filter.protocol.process "test-tool rot13-filter --log=debug.log clean smudge" &&
689688
test_config_global filter.protocol.required true &&
690689
rm -rf repo &&

0 commit comments

Comments
 (0)