test-lib: don't use ulimit in test prerequisites on cygwin

On cygwin (and MinGW), the 'ulimit' built-in bash command does not have the desired effect of limiting the resources of new processes, at least for the stack and file descriptors. However, it always returns success and leads to several test prerequisites being erroneously set to true. Add a check for cygwin and MinGW to the prerequisite expressions, using a 'test_have_prereq !MINGW,!CYGWIN' clause, to guard against using ulimit. This affects the prerequisite expressions for the ULIMIT_STACK_SIZE, CMDLINE_LIMIT and ULIMIT_FILE_DESCRIPTORS prerequisites. Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ramsay Jones committed Sep 14, 2017 at 18:24 UTC 21dac1deee58df80f7b2cd17d661864c8db5d28a
4 files changed +12 -5
t/t1400-update-ref.sh
+4 -1
@@ -1253,7 +1253,10 @@ run_with_limited_open_files () {
1253 (ulimit -n 32 && "$@")
1254 }
1255
1256 -test_lazy_prereq ULIMIT_FILE_DESCRIPTORS 'run_with_limited_open_files true'
1256 +test_lazy_prereq ULIMIT_FILE_DESCRIPTORS '
1257 + test_have_prereq !MINGW,!CYGWIN &&
1258 + run_with_limited_open_files true
1259 +'
1260
1261 test_expect_success ULIMIT_FILE_DESCRIPTORS 'large transaction creating branches does not burst open file limit' '
1262 (
t/t6120-describe.sh
-1
@@ -279,7 +279,6 @@ test_expect_success 'describe ignoring a borken submodule' '
279 grep broken out
280 '
281
282 -# we require ulimit, this excludes Windows
282 test_expect_failure ULIMIT_STACK_SIZE 'name-rev works in a deep repo' '
283 i=1 &&
284 while test $i -lt 8000
t/t7004-tag.sh
-1
@@ -1863,7 +1863,6 @@ test_expect_success 'version sort with very long prerelease suffix' '
1863 git tag -l --sort=version:refname
1864 '
1865
1866 -# we require ulimit, this excludes Windows
1866 test_expect_success ULIMIT_STACK_SIZE '--contains and --no-contains work in a deep repo' '
1867 >expect &&
1868 i=1 &&
t/test-lib.sh
+8 -2
@@ -1165,13 +1165,19 @@ run_with_limited_cmdline () {
1165 (ulimit -s 128 && "$@")
1166 }
1167
1168 -test_lazy_prereq CMDLINE_LIMIT 'run_with_limited_cmdline true'
1168 +test_lazy_prereq CMDLINE_LIMIT '
1169 + test_have_prereq !MINGW,!CYGWIN &&
1170 + run_with_limited_cmdline true
1171 +'
1172
1173 run_with_limited_stack () {
1174 (ulimit -s 128 && "$@")
1175 }
1176
1174 -test_lazy_prereq ULIMIT_STACK_SIZE 'run_with_limited_stack true'
1177 +test_lazy_prereq ULIMIT_STACK_SIZE '
1178 + test_have_prereq !MINGW,!CYGWIN &&
1179 + run_with_limited_stack true
1180 +'
1181
1182 build_option () {
1183 git version --build-options |