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

Re: [PATCHv2] git-p4: ticket expiry test: use a fake p4 to avoid use of 'sleep'

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Feb 8, 2019, 20:14 UTC
Message-ID
<20190208201445.GB10587@szeder.dev>
In-Reply-To
<20190208190231.8134-1-luke@diamand.org>
On Fri, Feb 08, 2019 at 07:02:31PM +0000, Luke Diamand wrote:
Show 7 quoted lines
> +# create a fake version of "p4" which returns a TicketExpiration based
> +# on $EXPIRY, for testing login expiration
> +create_fake_p4() {
> +	(
> +		cd "$git" && mkdir expire-p4 &&
> +		cat >>expire-p4/p4 <<-EOF &&
> +		#!/usr/bin/python
I think this should be $PYTHON_PATH.
Show 32 quoted lines
> +		import marshal, os, subprocess, sys
> +		if "login" in sys.argv:
> +		    marshal.dump({"foo" : "bar", "code" : "stat", "TicketExpiration" : os.environ["EXPIRY"]}, sys.stdout)
> +		else:
> +		    subprocess.check_call([os.environ["P4"]] + sys.argv[1:])
> +		EOF
> +		chmod 0755 expire-p4/p4
> +	)
> +}
>  
>  test_expect_success 'git operation with expired ticket' '
> -	P4TICKETS="$cli/tickets" &&
> -	P4USER=short_expiry_user &&
> -	echo "password" | p4 login &&
> +	create_fake_p4 &&
> +	echo "newpassword" | p4 login &&
>  	(
>  		cd "$git" &&
> -		git p4 sync &&
> -		sleep 5 &&
> -		test_must_fail git p4 sync 2>errmsg &&
> -		grep "failure accessing depot" errmsg
> +		P4=$(command -v p4) && export P4 &&
> +		EXPIRY=3600 PATH=$PWD/expire-p4:$PATH git p4 sync &&
> +		EXPIRY=1 PATH=$PWD/expire-p4:$PATH test_must_fail git p4 sync -v 2>errmsg &&
> +		grep "failure accessing depot.*expires in 1 second" errmsg
>  	)
>  '
>  
> -- 
> 2.20.1.612.g17ebf93fb6.dirty
> 
Previous: Luke DiamandNext: Junio C Hamano
Message 2 of 4 in “[PATCHv2] git-p4: ticket expiry test: use a fake p4 to avoid use of 'sleep'”
  1. Luke DiamandFeb 8, 2019
  2. SZEDER GáborFeb 8, 2019
  3. Junio C HamanoFeb 9, 2019
  4. Luke DiamandFeb 9, 2019

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.