Skip to content

Commit 55f7879

Browse files
committed
Merge branch 'ps/test-wo-perl-prereq' into ps/fewer-perl
* ps/test-wo-perl-prereq: t5703: refactor test to not depend on Perl t5316: refactor `max_chain()` to not depend on Perl t0210: refactor trace2 scrubbing to not use Perl t0021: refactor `generate_random_characters()` to not depend on Perl t/lib-httpd: refactor "one-time-perl" CGI script to not depend on Perl t/lib-t6000: refactor `name_from_description()` to not depend on Perl t/lib-gpg: refactor `sanitize_pgp()` to not depend on Perl t: refactor tests depending on Perl for textconv scripts t: refactor tests depending on Perl to print data t: refactor tests depending on Perl substitution operator t: refactor tests depending on Perl transliteration operator Makefile: stop requiring Perl when running tests meson: stop requiring Perl when tests are enabled t: adapt existing PERL prerequisites t: introduce PERL_TEST_HELPERS prerequisite t: adapt `test_readlink()` to not use Perl t: adapt `test_copy_bytes()` to not use Perl t: adapt character translation helpers to not use Perl t: refactor environment sanitization to not use Perl t: skip chain lint when PERL_PATH is unset
2 parents 485f5f8 + 7a7b602 commit 55f7879

File tree

84 files changed

+471
-373
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+471
-373
lines changed

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ endif
779779
# features. It is optional if you want to neither execute tests nor use any of
780780
# these optional features.
781781
perl_required = get_option('perl')
782-
if get_option('tests') or get_option('gitweb').enabled() or 'netrc' in get_option('credential_helpers') or get_option('docs') != []
782+
if get_option('gitweb').enabled() or 'netrc' in get_option('credential_helpers') or get_option('docs') != []
783783
perl_required = true
784784
endif
785785

t/Makefile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,21 @@ CHAINLINTSUPPRESS = GIT_TEST_EXT_CHAIN_LINT=0 && export GIT_TEST_EXT_CHAIN_LINT
5959

6060
all:: $(DEFAULT_TEST_TARGET)
6161

62-
test: pre-clean check-chainlint check-meson $(TEST_LINT)
62+
test: pre-clean check-meson $(TEST_LINT)
6363
$(CHAINLINTSUPPRESS) $(MAKE) aggregate-results-and-cleanup
6464

65+
ifneq ($(PERL_PATH),)
66+
test: check-chainlint
67+
prove: check-chainlint
68+
endif
69+
6570
failed:
6671
@failed=$$(cd '$(TEST_RESULTS_DIRECTORY_SQ)' && \
6772
grep -l '^failed [1-9]' *.counts | \
6873
sed -n 's/\.counts$$/.sh/p') && \
6974
test -z "$$failed" || $(MAKE) $$failed
7075

71-
prove: pre-clean check-chainlint $(TEST_LINT)
76+
prove: pre-clean $(TEST_LINT)
7277
@echo "*** prove (shell & unit tests) ***"
7378
@$(CHAINLINTSUPPRESS) TEST_OPTIONS='$(GIT_TEST_OPTS)' TEST_SHELL_PATH='$(TEST_SHELL_PATH_SQ)' $(PROVE) --exec ./run-test.sh $(GIT_PROVE_OPTS) $(T) $(UNIT_TESTS)
7479
$(MAKE) clean-except-prove-cache
@@ -132,8 +137,13 @@ check-meson:
132137
fi; \
133138
done
134139

135-
test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax \
140+
test-lint: test-lint-duplicates test-lint-executable \
136141
test-lint-filenames
142+
ifneq ($(PERL_PATH),)
143+
test-lint: test-lint-shell-syntax
144+
else
145+
GIT_TEST_CHAIN_LINT = 0
146+
endif
137147
ifneq ($(GIT_TEST_CHAIN_LINT),0)
138148
test-lint: test-chainlint
139149
endif

t/helper/test-path-utils.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,19 @@ int cmd__path_utils(int argc, const char **argv)
323323
return 0;
324324
}
325325

326+
if (argc >= 2 && !strcmp(argv[1], "readlink")) {
327+
struct strbuf target = STRBUF_INIT;
328+
while (argc > 2) {
329+
if (strbuf_readlink(&target, argv[2], 0) < 0)
330+
die_errno("cannot read link at '%s'", argv[2]);
331+
puts(target.buf);
332+
argc--;
333+
argv++;
334+
}
335+
strbuf_release(&target);
336+
return 0;
337+
}
338+
326339
if (argc >= 2 && !strcmp(argv[1], "absolute_path")) {
327340
while (argc > 2) {
328341
puts(absolute_path(argv[2]));

t/helper/test-sha1.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ do
1515
{
1616
test -z "$pfx" || echo "$pfx"
1717
dd if=/dev/zero bs=1048576 count=$cnt 2>/dev/null |
18-
perl -pe 'y/\000/g/'
18+
tr "\000" "g"
1919
} | ./t/helper/test-tool $sha1 $cnt
2020
)
2121
if test "$expect" = "$actual"
@@ -61,7 +61,7 @@ do
6161
{
6262
test -z "$pfx" || echo "$pfx"
6363
dd if=/dev/zero bs=1048576 count=$cnt 2>/dev/null |
64-
perl -pe 'y/\000/g/'
64+
tr "\000" "g"
6565
} | sha1sum |
6666
sed -e 's/ .*//'
6767
)

t/lib-diff.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ compare_diff_raw_z () {
2121
# Also we do not check SHA1 hash generation in this test, which
2222
# is a job for t0000-basic.sh
2323

24-
perl -pe 'y/\000/\012/' <"$1" | sed -e "$sanitize_diff_raw_z" >.tmp-1
25-
perl -pe 'y/\000/\012/' <"$2" | sed -e "$sanitize_diff_raw_z" >.tmp-2
24+
tr "\000" "\012" <"$1" | sed -e "$sanitize_diff_raw_z" >.tmp-1
25+
tr "\000" "\012" <"$2" | sed -e "$sanitize_diff_raw_z" >.tmp-2
2626
test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
2727
}
2828

t/lib-gpg.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,5 @@ test_lazy_prereq GPGSSH_VERIFYTIME '
192192
'
193193

194194
sanitize_pgp() {
195-
perl -ne '
196-
/^-----END PGP/ and $in_pgp = 0;
197-
print unless $in_pgp;
198-
/^-----BEGIN PGP/ and $in_pgp = 1;
199-
'
195+
sed "/^-----BEGIN PGP/,/^-----END PGP/{/^-/p;d;}"
200196
}

t/lib-httpd.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ prepare_httpd() {
165165
install_script broken-smart-http.sh
166166
install_script error-smart-http.sh
167167
install_script error.sh
168-
install_script apply-one-time-perl.sh
168+
install_script apply-one-time-script.sh
169169
install_script nph-custom-auth.sh
170170

171171
ln -s "$LIB_HTTPD_MODULE_PATH" "$HTTPD_ROOT_PATH/modules"

t/lib-httpd/apache.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ SetEnv PERL_PATH ${PERL_PATH}
135135
SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH}
136136
SetEnv GIT_HTTP_EXPORT_ALL
137137
</LocationMatch>
138-
<LocationMatch /one_time_perl/>
138+
<LocationMatch /one_time_script/>
139139
SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH}
140140
SetEnv GIT_HTTP_EXPORT_ALL
141141
</LocationMatch>
@@ -159,7 +159,7 @@ ScriptAliasMatch /smart_*[^/]*/(.*) ${GIT_EXEC_PATH}/git-http-backend/$1
159159
ScriptAlias /broken_smart/ broken-smart-http.sh/
160160
ScriptAlias /error_smart/ error-smart-http.sh/
161161
ScriptAlias /error/ error.sh/
162-
ScriptAliasMatch /one_time_perl/(.*) apply-one-time-perl.sh/$1
162+
ScriptAliasMatch /one_time_script/(.*) apply-one-time-script.sh/$1
163163
ScriptAliasMatch /custom_auth/(.*) nph-custom-auth.sh/$1
164164
<Directory ${GIT_EXEC_PATH}>
165165
Options FollowSymlinks
@@ -182,7 +182,7 @@ ScriptAliasMatch /custom_auth/(.*) nph-custom-auth.sh/$1
182182
<Files error.sh>
183183
Options ExecCGI
184184
</Files>
185-
<Files apply-one-time-perl.sh>
185+
<Files apply-one-time-script.sh>
186186
Options ExecCGI
187187
</Files>
188188
<Files ${GIT_EXEC_PATH}/git-http-backend>

t/lib-httpd/apply-one-time-perl.sh

Lines changed: 0 additions & 27 deletions
This file was deleted.

t/lib-httpd/apply-one-time-script.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/sh
2+
3+
# If "one-time-script" exists in $HTTPD_ROOT_PATH, run the script on the HTTP
4+
# response. If the response was modified as a result, delete "one-time-script"
5+
# so that subsequent HTTP responses are no longer modified.
6+
#
7+
# This can be used to simulate the effects of the repository changing in
8+
# between HTTP request-response pairs.
9+
if test -f one-time-script
10+
then
11+
LC_ALL=C
12+
export LC_ALL
13+
14+
"$GIT_EXEC_PATH/git-http-backend" >out
15+
./one-time-script out >out_modified
16+
17+
if cmp -s out out_modified
18+
then
19+
cat out
20+
else
21+
cat out_modified
22+
rm one-time-script
23+
fi
24+
else
25+
"$GIT_EXEC_PATH/git-http-backend"
26+
fi

0 commit comments

Comments
 (0)