git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 17/20] t0021: refactor `generate_random_characters()` to not depend on Perl

From
Patrick Steinhardt <ps@pks.im>
Date
Mar 20, 2025, 09:35 UTC
Message-ID
<20250320-b4-pks-t-perlless-v1-17-b1eefe27ac55@pks.im>
In-Reply-To
<20250320-b4-pks-t-perlless-v1-0-b1eefe27ac55@pks.im>

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 <ps@pks.im>
---
 t/t0021-conversion.sh | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh
index 4a892a91780..bf10d253ec4 100755
--- a/t/t0021-conversion.sh
+++ b/t/t0021-conversion.sh
@@ -20,8 +20,7 @@ EOF
 generate_random_characters () {
 	LEN=$1
 	NAME=$2
-	test-tool genrandom some-seed $LEN |
-		perl -pe "s/./chr((ord($&) % 26) + ord('a'))/sge" >"$TEST_ROOT/$NAME"
+	test-tool genrandom some-seed | tr -dc 'a-z' | test_copy_bytes "$LEN" >"$TEST_ROOT/$NAME"
 }
 
 filter_git () {
@@ -619,7 +618,7 @@ test_expect_success 'required process filter should be used only for "clean" ope
 	)
 '
 
-test_expect_success PERL_TEST_HELPERS 'required process filter should process multiple packets' '
+test_expect_success 'required process filter should process multiple packets' '
 	test_config_global filter.protocol.process "test-tool rot13-filter --log=debug.log clean smudge" &&
 	test_config_global filter.protocol.required true &&
 
@@ -684,7 +683,7 @@ test_expect_success PERL_TEST_HELPERS 'required process filter should process mu
 	)
 '
 
-test_expect_success PERL_TEST_HELPERS 'required process filter with clean error should fail' '
+test_expect_success 'required process filter with clean error should fail' '
 	test_config_global filter.protocol.process "test-tool rot13-filter --log=debug.log clean smudge" &&
 	test_config_global filter.protocol.required true &&
 	rm -rf repo &&
-- 
2.49.0.472.ge94155a9ec.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 34 of 125 in “t: drop Perl as a mandatory prerequisite”
  1. 00/20 t: drop Perl as a mandatory prerequisitePatrick Steinhardt, Mar 20, 2025
  2. 01/20 t: skip chain lint when PERL_PATH is unsetPatrick Steinhardt, Mar 20, 2025
  3. Eric SunshineMar 20, 2025
  4. 02/20 t: refactor environment sanitization to not use PerlPatrick Steinhardt, Mar 20, 2025
  5. Karthik NayakMar 21, 2025
  6. 03/20 t: adapt character translation helpers to not use PerlPatrick Steinhardt, Mar 20, 2025
  7. 04/20 t: adapt `test_copy_bytes()` to not use PerlPatrick Steinhardt, Mar 20, 2025
  8. Karthik NayakMar 21, 2025
  9. 05/20 t: adapt `test_readlink()` to not use PerlPatrick Steinhardt, Mar 20, 2025
  10. 06/20 t: introduce PERL_TEST_HELPERS prerequisitePatrick Steinhardt, Mar 20, 2025
  11. Eric SunshineMar 20, 2025
  12. Patrick SteinhardtMar 24, 2025
  13. 07/20 t: adapt existing PERL prerequisitesPatrick Steinhardt, Mar 20, 2025
  14. 08/20 meson: stop requiring Perl when tests are enabledPatrick Steinhardt, Mar 20, 2025
  15. 09/20 Makefile: stop requiring Perl when running testsPatrick Steinhardt, Mar 20, 2025
  16. 11/20 t: refactor tests depending on Perl substitution operatorPatrick Steinhardt, Mar 20, 2025
  17. Phillip WoodMar 24, 2025
  18. 10/20 t: refactor tests depending on Perl transliteration operatorPatrick Steinhardt, Mar 20, 2025
  19. 13/20 t: refactor tests depending on Perl for textconv scriptsPatrick Steinhardt, Mar 20, 2025
  20. Eric SunshineMar 20, 2025
  21. Patrick SteinhardtMar 24, 2025
  22. Eric SunshineMar 24, 2025
  23. Patrick SteinhardtMar 25, 2025
  24. Phillip WoodMar 24, 2025
  25. Patrick SteinhardtMar 25, 2025
  26. 12/20 t: refactor tests depending on Perl to print dataPatrick Steinhardt, Mar 20, 2025
  27. Eric SunshineMar 20, 2025
  28. Patrick SteinhardtMar 24, 2025
  29. 14/20 t/lib-gpg: refactor `sanitize_pgp()` to not depend on PerlPatrick Steinhardt, Mar 20, 2025
  30. 15/20 t/lib-t6000: refactor `name_from_description()` to not depend on PerlPatrick Steinhardt, Mar 20, 2025
  31. Eric SunshineMar 20, 2025
  32. Patrick SteinhardtMar 24, 2025
  33. 16/20 t/lib-httpd: refactor "one-time-perl" CGI script to not depend on PerlPatrick Steinhardt, Mar 20, 2025
  34. 17/20 t0021: refactor `generate_random_characters()` to not depend on PerlPatrick Steinhardt, Mar 20, 2025
  35. 18/20 t0210: refactor trace2 scrubbing to not use PerlPatrick Steinhardt, Mar 20, 2025
  36. 19/20 t5316: refactor `max_chain()` to not depend on PerlPatrick Steinhardt, Mar 20, 2025
  37. 20/20 t5703: refactor test to not depend on PerlPatrick Steinhardt, Mar 20, 2025
  38. 00/20 t: drop Perl as a mandatory prerequisitePatrick Steinhardt, Mar 25, 2025
  39. 01/20 t: skip chain lint when PERL_PATH is unsetPatrick Steinhardt, Mar 25, 2025
  40. 02/20 t: refactor environment sanitization to not use PerlPatrick Steinhardt, Mar 25, 2025
  41. 03/20 t: adapt character translation helpers to not use PerlPatrick Steinhardt, Mar 25, 2025
  42. 05/20 t: adapt `test_readlink()` to not use PerlPatrick Steinhardt, Mar 25, 2025
  43. 04/20 t: adapt `test_copy_bytes()` to not use PerlPatrick Steinhardt, Mar 25, 2025
  44. 06/20 t: introduce PERL_TEST_HELPERS prerequisitePatrick Steinhardt, Mar 25, 2025
  45. 08/20 meson: stop requiring Perl when tests are enabledPatrick Steinhardt, Mar 25, 2025
  46. 07/20 t: adapt existing PERL prerequisitesPatrick Steinhardt, Mar 25, 2025
  47. 09/20 Makefile: stop requiring Perl when running testsPatrick Steinhardt, Mar 25, 2025
  48. 10/20 t: refactor tests depending on Perl transliteration operatorPatrick Steinhardt, Mar 25, 2025
  49. 11/20 t: refactor tests depending on Perl substitution operatorPatrick Steinhardt, Mar 25, 2025
  50. Phillip WoodMar 25, 2025
  51. Patrick SteinhardtMar 27, 2025
  52. 13/20 t: refactor tests depending on Perl for textconv scriptsPatrick Steinhardt, Mar 25, 2025
  53. 12/20 t: refactor tests depending on Perl to print dataPatrick Steinhardt, Mar 25, 2025
  54. 14/20 t/lib-gpg: refactor `sanitize_pgp()` to not depend on PerlPatrick Steinhardt, Mar 25, 2025
  55. 15/20 t/lib-t6000: refactor `name_from_description()` to not depend on PerlPatrick Steinhardt, Mar 25, 2025
  56. 16/20 t/lib-httpd: refactor "one-time-perl" CGI script to not depend on PerlPatrick Steinhardt, Mar 25, 2025
  57. 17/20 t0021: refactor `generate_random_characters()` to not depend on PerlPatrick Steinhardt, Mar 25, 2025
  58. 18/20 t0210: refactor trace2 scrubbing to not use PerlPatrick Steinhardt, Mar 25, 2025
  59. 19/20 t5316: refactor `max_chain()` to not depend on PerlPatrick Steinhardt, Mar 25, 2025
  60. 20/20 t5703: refactor test to not depend on PerlPatrick Steinhardt, Mar 25, 2025
  61. 00/20 t: drop Perl as a mandatory prerequisitePatrick Steinhardt, Mar 27, 2025
  62. 01/20 t: skip chain lint when PERL_PATH is unsetPatrick Steinhardt, Mar 27, 2025
  63. 03/20 t: adapt character translation helpers to not use PerlPatrick Steinhardt, Mar 27, 2025
  64. 02/20 t: refactor environment sanitization to not use PerlPatrick Steinhardt, Mar 27, 2025
  65. 04/20 t: adapt `test_copy_bytes()` to not use PerlPatrick Steinhardt, Mar 27, 2025
  66. 05/20 t: adapt `test_readlink()` to not use PerlPatrick Steinhardt, Mar 27, 2025
  67. 07/20 t: adapt existing PERL prerequisitesPatrick Steinhardt, Mar 27, 2025
  68. 06/20 t: introduce PERL_TEST_HELPERS prerequisitePatrick Steinhardt, Mar 27, 2025
  69. Johannes SchindelinApr 1, 2025
  70. Patrick SteinhardtApr 2, 2025
  71. Johannes SchindelinApr 2, 2025
  72. Patrick SteinhardtApr 3, 2025
  73. 09/20 Makefile: stop requiring Perl when running testsPatrick Steinhardt, Mar 27, 2025
  74. 08/20 meson: stop requiring Perl when tests are enabledPatrick Steinhardt, Mar 27, 2025
  75. 10/20 t: refactor tests depending on Perl transliteration operatorPatrick Steinhardt, Mar 27, 2025
  76. 11/20 t: refactor tests depending on Perl substitution operatorPatrick Steinhardt, Mar 27, 2025
  77. Johannes SchindelinApr 1, 2025
  78. Patrick SteinhardtApr 2, 2025
  79. 12/20 t: refactor tests depending on Perl to print dataPatrick Steinhardt, Mar 27, 2025
  80. Johannes SchindelinApr 1, 2025
  81. Patrick SteinhardtApr 2, 2025
  82. 13/20 t: refactor tests depending on Perl for textconv scriptsPatrick Steinhardt, Mar 27, 2025
  83. Johannes SchindelinApr 1, 2025
  84. Patrick SteinhardtApr 2, 2025
  85. Johannes SchindelinApr 2, 2025
  86. 14/20 t/lib-gpg: refactor `sanitize_pgp()` to not depend on PerlPatrick Steinhardt, Mar 27, 2025
  87. Johannes SchindelinApr 1, 2025
  88. Patrick SteinhardtApr 2, 2025
  89. 15/20 t/lib-t6000: refactor `name_from_description()` to not depend on PerlPatrick Steinhardt, Mar 27, 2025
  90. 16/20 t/lib-httpd: refactor "one-time-perl" CGI script to not depend on PerlPatrick Steinhardt, Mar 27, 2025
  91. 17/20 t0021: refactor `generate_random_characters()` to not depend on PerlPatrick Steinhardt, Mar 27, 2025
  92. Johannes SchindelinApr 1, 2025
  93. Patrick SteinhardtApr 2, 2025
  94. 18/20 t0210: refactor trace2 scrubbing to not use PerlPatrick Steinhardt, Mar 27, 2025
  95. 19/20 t5316: refactor `max_chain()` to not depend on PerlPatrick Steinhardt, Mar 27, 2025
  96. 20/20 t5703: refactor test to not depend on PerlPatrick Steinhardt, Mar 27, 2025
  97. Phillip WoodMar 28, 2025
  98. Johannes SchindelinApr 2, 2025
  99. 00/20 t: drop Perl as a mandatory prerequisitePatrick Steinhardt, Apr 3, 2025
  100. 01/20 t: skip chain lint when PERL_PATH is unsetPatrick Steinhardt, Apr 3, 2025
  101. 02/20 t: refactor environment sanitization to not use PerlPatrick Steinhardt, Apr 3, 2025
  102. 03/20 t: adapt character translation helpers to not use PerlPatrick Steinhardt, Apr 3, 2025
  103. 04/20 t: adapt `test_copy_bytes()` to not use PerlPatrick Steinhardt, Apr 3, 2025
  104. 05/20 t: adapt `test_readlink()` to not use PerlPatrick Steinhardt, Apr 3, 2025
  105. 06/20 t: introduce PERL_TEST_HELPERS prerequisitePatrick Steinhardt, Apr 3, 2025
  106. 07/20 t: adapt existing PERL prerequisitesPatrick Steinhardt, Apr 3, 2025
  107. 08/20 meson: stop requiring Perl when tests are enabledPatrick Steinhardt, Apr 3, 2025
  108. 09/20 Makefile: stop requiring Perl when running testsPatrick Steinhardt, Apr 3, 2025
  109. 10/20 t: refactor tests depending on Perl transliteration operatorPatrick Steinhardt, Apr 3, 2025
  110. 11/20 t: refactor tests depending on Perl substitution operatorPatrick Steinhardt, Apr 3, 2025
  111. 13/20 t: refactor tests depending on Perl for textconv scriptsPatrick Steinhardt, Apr 3, 2025
  112. 14/20 t/lib-gpg: refactor `sanitize_pgp()` to not depend on PerlPatrick Steinhardt, Apr 3, 2025
  113. 12/20 t: refactor tests depending on Perl to print dataPatrick Steinhardt, Apr 3, 2025
  114. SZEDER GáborJun 10, 2025
  115. Junio C HamanoJun 10, 2025
  116. Patrick SteinhardtJul 7, 2025
  117. Junio C HamanoJun 10, 2025
  118. 15/20 t/lib-t6000: refactor `name_from_description()` to not depend on PerlPatrick Steinhardt, Apr 3, 2025
  119. 17/20 t0021: refactor `generate_random_characters()` to not depend on PerlPatrick Steinhardt, Apr 3, 2025
  120. 16/20 t/lib-httpd: refactor "one-time-perl" CGI script to not depend on PerlPatrick Steinhardt, Apr 3, 2025
  121. 18/20 t0210: refactor trace2 scrubbing to not use PerlPatrick Steinhardt, Apr 3, 2025
  122. 19/20 t5316: refactor `max_chain()` to not depend on PerlPatrick Steinhardt, Apr 3, 2025
  123. 20/20 t5703: refactor test to not depend on PerlPatrick Steinhardt, Apr 3, 2025
  124. Johannes SchindelinApr 3, 2025
  125. Junio C HamanoApr 8, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.