Subject: Re: [BUG?] setting ulimit in test suite broken for me

From: Jeff King <[email-masked]>
Date: Wed, 21 Jan 2015 14:03:49 -0500

On Wed, Jan 21, 2015 at 10:59:06AM -0800, Stefan Beller wrote:

> so I wanted to create a new test for large transactions, which should look like:
> 
> 	run_with_limited_open_files () {
> 		(ulimit -n 64 && "$@")
> 	}
> 
> 	test_lazy_prereq ULIMIT 'run_with_limited_open_files true'
> 
> 	test_expect_success ULIMIT 'large transaction creating branches does not burst open file limit' '
> 	(
> 		echo $(ulimit -n)
> 		for i in $(seq 65)
> 		do
> 			echo "create refs/heads/$i HEAD"
> 		done >large_input &&
> 		git update-ref --stdin <large_input &&
> 		git rev-parse --verify -q refs/heads/65
> 	)
> 	'
> 
> Mind the "echo $(ulimit -n)" in there as a debugging output.
> So if I run the test with "-d -v" to actually see the debugging output,
> I see ulimit -n set to 32768 instead of the desired 64.

You define run_with_limited_open_files, which starts a subshell, drops
the limit inside the subshell, and then spawns the child. But you never
call it in the test. Were you expecting that tests with the ULIMIT
prereq to automatically respect the limit? The prereq is just about
checking whether we can set the ulimit at all.

Try:

  run_with_limited_open_files ulimit -n

in your debugging statement (and of course use run_with... for the
actual git command you want to limit).

-Peff