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

Re: [GSoC][PATCH v4 4/4] credential-cache: add tests for XDG functionality

From
Jeff King <peff@peff.net>
Date
Mar 16, 2017, 17:58 UTC
Message-ID
<20170316175857.77tftld54gqqm22c@sigill.intra.peff.net>
In-Reply-To
<xmqq8to5chh5.fsf@gitster.mtv.corp.google.com>
On Thu, Mar 16, 2017 at 09:29:58AM -0700, Junio C Hamano wrote:
Show 11 quoted lines
> Devin Lehmacher <lehmacdj@gmail.com> writes:
> 
> > @@ -20,4 +21,67 @@ helper_test_timeout cache --timeout=1
> >  # our socket, leaving us with no way to access the daemon.
> >  git credential-cache exit
> >  
> > +# we need to use rm -rf here since sometimes the daemon hasn't finished
> > +# cleaning up after itself and rmdir fails
> 
> Hmmmm.  Peff, do you have ideas on better ways to do this (or
> explanation why this is the best we could do)?

If you call "git credential-cache exit", that should be deterministic. The client program won't exit until the other side closes the descriptor, which it won't do until it has cleaned up the socket. See the comment at line 130 of credential-cache--daemon.c.

So here:
Show 11 quoted lines
> > +test_expect_success 'credential-cache --socket option overrides default location' '
> > +	test_when_finished "rm -rf \"$HOME\"/dir/" &&
> > +	check approve "cache --socket \"$HOME/dir/socket\"" <<-\EOF &&
> > +	protocol=https
> > +	host=example.com
> > +	username=store-user
> > +	password=store-pass
> > +	EOF
> > +	test -S "$HOME/dir/socket" &&
> > +	git credential-cache exit
> > +'
This is almost right, except:
  - the "exit" needs to be told which socket to use
  - we should do the "exit" even when the test fails early (so in
    test_when_finished)
  - the test_when_finished block will interpolate $HOME when setting up
    the block, which will break if it contains double-quotes or other
    special characters. It should use \$HOME.
    I suspect the "check" invocation needs to do so as well, though it
    is even trickier (we shove it into a single-quoted "-c" argument).
    I think you could get by in both cases with relative paths.
So all together, probably:
  test_when_finished "
	git credential-cache --socket dir/socket &&
	rmdir dir
  " &&
  check approve "cache --socket dir/socket" <<-\EOF &&
  ...
  EOF
  test -S dir/socket

The final "test -S" should be OK in practice. We're assuming that the cache-daemon is still running, but it has a 900 second timeout by default (and besides, all the other tests have exact same race).

-Peff
Previous: Junio C HamanoNext: Devin Lehmacher
Message 24 of 54 in “Move ~/.git-credential-cache to ~/.cache/git”
  1. Devin LehmacherMar 13, 2017
  2. [GSoC][PATCH 1/3] path.c: Add xdg_cache_home to get paths under XDG_CACHE_HOMEDevin Lehmacher, Mar 13, 2017
  3. Jeff KingMar 13, 2017
  4. Devin LehmacherMar 13, 2017
  5. [GSoC][PATCH 3/3] Update documentation to reflect new socket locationDevin Lehmacher, Mar 13, 2017
  6. Junio C HamanoMar 13, 2017
  7. [GSoC][PATCH v2 2/2] credential-cache: use XDG_CACHE_HOME for socketDevin Lehmacher, Mar 13, 2017
  8. [GSoC][PATCH v2 1/2] path.c: add xdg_cache_homeDevin Lehmacher, Mar 13, 2017
  9. [GSoC][PATCH v2 2/2] credential-cache: use XDG_CACHE_HOME for socketDevin Lehmacher, Mar 13, 2017
  10. Junio C HamanoMar 13, 2017
  11. [GSoC][PATCH/RFC v3 0/3] Fix commit messages, check if socket is socketDevin Lehmacher, Mar 14, 2017
  12. [GSoC][PATCH/RFC v3 3/3] credential-cache: only use user_socket if a socketDevin Lehmacher, Mar 14, 2017
  13. Devin LehmacherMar 14, 2017
  14. Brandon WilliamsMar 14, 2017
  15. Devin LehmacherMar 14, 2017
  16. Brandon WilliamsMar 14, 2017
  17. Junio C HamanoMar 14, 2017
  18. Junio C HamanoMar 14, 2017
  19. Devin LehmacherMar 14, 2017
  20. [GSoC][PATCH v4 0/4] Moving credential-cache socket to xdg pathDevin Lehmacher, Mar 16, 2017
  21. [GSoC][PATCH v4 1/4] path.c: add xdg_cache_homeDevin Lehmacher, Mar 16, 2017
  22. [GSoC][PATCH v4 4/4] credential-cache: add tests for XDG functionalityDevin Lehmacher, Mar 16, 2017
  23. Junio C HamanoMar 16, 2017
  24. Jeff KingMar 16, 2017
  25. [GSoC][PATCH v5 1/3] path.c: add xdg_cache_homeDevin Lehmacher, Mar 17, 2017
  26. [GSoC][PATCH v5 2/3] credential-cache: use XDG_CACHE_HOME for socketDevin Lehmacher, Mar 17, 2017
  27. Ramsay JonesMar 17, 2017
  28. Devin LehmacherMar 17, 2017
  29. [GSoC][PATCH v5 3/3] credential-cache: add tests for XDG functionalityDevin Lehmacher, Mar 17, 2017
  30. Junio C HamanoMar 17, 2017
  31. [GSoC][PATCH v6 1/3] path.c: add xdg_cache_homeDevin Lehmacher, Mar 17, 2017
  32. [GSoC][PATCH v6 2/3] credential-cache: use XDG_CACHE_HOME for socketDevin Lehmacher, Mar 17, 2017
  33. Jeff KingMar 17, 2017
  34. [GSoC][PATCH v6 3/3] credential-cache: add tests for XDG functionalityDevin Lehmacher, Mar 17, 2017
  35. Jeff KingMar 17, 2017
  36. Jeff KingMar 17, 2017
  37. [GSoC][PATCH v4 2/4] dir: add directory_existsDevin Lehmacher, Mar 16, 2017
  38. Junio C HamanoMar 16, 2017
  39. Junio C HamanoMar 16, 2017
  40. [GSoC][PATCH v4 3/4] credential-cache: use XDG_CACHE_HOME for socketDevin Lehmacher, Mar 16, 2017
  41. Junio C HamanoMar 16, 2017
  42. Jeff KingMar 16, 2017
  43. [GSoC][PATCH/RFC v3 2/3] credential-cache: use XDG_CACHE_HOME for socketDevin Lehmacher, Mar 14, 2017
  44. Junio C HamanoMar 14, 2017
  45. [GSoC][PATCH/RFC v3 1/3] path.c: add xdg_cache_homeDevin Lehmacher, Mar 14, 2017
  46. Junio C HamanoMar 13, 2017
  47. [GSoC][PATCH 2/3] credential-cache.c: Make git use XDG_CACHE_HOME for credentialsDevin Lehmacher, Mar 13, 2017
  48. Junio C HamanoMar 13, 2017
  49. Jeff KingMar 13, 2017
  50. Junio C HamanoMar 13, 2017
  51. Devin LehmacherMar 13, 2017
  52. Devin LehmacherMar 13, 2017
  53. Junio C HamanoMar 13, 2017
  54. Jeff KingMar 13, 2017

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.