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

Re: [PATCH 11/13] contrib/subtree: Make each test self-contained

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 5, 2013, 05:13 UTC
Message-ID
<7vwqunwdfk.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1360037173-23291-12-git-send-email-greened@obbligato.org>
"David A. Greene" <greened@obbligato.org> writes:
Show 6 quoted lines
> +test_create_commit() (
> +	repo=$1
> +	commit=$2
> +	cd "$repo"
> +	mkdir -p "$(dirname "$commit")"
> +	echo "$commit" > "$commit"
Style.
> +	git add "$commit"
> +	git commit -m "$commit"
> +)

Very nice, but don't we want to check for possible errors in any of the above commands?

Show 26 quoted lines
>  last_commit_message()
>  {
>  	git log --pretty=format:%s -1
>  }
>  
> +#
> +# Tests for 'git subtree add'
> +#
>  
> -test_expect_success 'fetch subproj history' '
> -		git fetch ./subproj sub1 &&
> -		git branch sub1 FETCH_HEAD
> -'
>  
>  test_expect_success 'no pull from non-existant subtree' '
> -		test_must_fail git subtree pull --prefix=subdir ./subproj sub1
> +	test_create_repo "$test_count" &&
> +	test_create_repo "$test_count/subproj" &&
> +	test_create_commit "$test_count" main1 &&
> +	test_create_commit "$test_count/subproj" sub1 &&
> +	(
> +		cd "$test_count" &&
> +		git fetch ./subproj master &&
> +		test_must_fail git subtree pull --prefix=subdir ./subproj master
> +	)
>  '

The goal of making each tests indenendent is a very good one, but we'd really prefer not to see $test_count which is an implementation detail of the test framework to be used like this. It will make it unnecessarily harder to improve the test framework (e.g. it may want to stop using the $test_count variable).

This is not limited to this variable, but all other $test_anything variable. Earlier I wanted to update the definition of test_tick which happens to be decimal number of seconds since epoch, but some tests were comparing it with the raw values read from cat-file output for a commit object, and it was really painful.

Previous: David A. GreeneNext: David A. Greene
Message 18 of 28 in “Assorted contrib/subtree Patches”
  1. David A. GreeneFeb 5, 2013
  2. 01/13 contrib/subtree: Remove Test Number CommentsDavid A. Greene, Feb 5, 2013
  3. Junio C HamanoFeb 5, 2013
  4. 02/13 contrib/subtree: Use %B for Split Subject/BodyDavid A. Greene, Feb 5, 2013
  5. 03/13 contrib/subtree: Better Error Handling for addDavid A. Greene, Feb 5, 2013
  6. 04/13 contrib/subtree: Fix SynopsisDavid A. Greene, Feb 5, 2013
  7. 05/13 contrib/subtree: Honor DESTDIRDavid A. Greene, Feb 5, 2013
  8. 06/13 contrib/subtree: Make the Manual Directory if NeededDavid A. Greene, Feb 5, 2013
  9. 07/13 contrib/subtree: Fix whitespacesDavid A. Greene, Feb 5, 2013
  10. Junio C HamanoFeb 5, 2013
  11. 08/13 contrib/subtree: Add vim modelineDavid A. Greene, Feb 5, 2013
  12. Junio C HamanoFeb 5, 2013
  13. 09/13 contrib/subtree: Ignore testing directoryDavid A. Greene, Feb 5, 2013
  14. Junio C HamanoFeb 5, 2013
  15. 10/13 contrib/subtree: Code cleaning and refactoringDavid A. Greene, Feb 5, 2013
  16. Junio C HamanoFeb 5, 2013
  17. 11/13 contrib/subtree: Make each test self-containedDavid A. Greene, Feb 5, 2013
  18. Junio C HamanoFeb 5, 2013
  19. 12/13 contrib/subtree: Handle '--prefix' argument with a slash appendedDavid A. Greene, Feb 5, 2013
  20. Junio C HamanoFeb 5, 2013
  21. 13/13 contrib/subtree: Remove --annotateDavid A. Greene, Feb 5, 2013
  22. Junio C HamanoFeb 5, 2013
  23. Jakub SuderFeb 5, 2013
  24. James NylenFeb 5, 2013
  25. greened@obbligato.orgFeb 18, 2013
  26. James NylenFeb 18, 2013
  27. Junio C HamanoFeb 5, 2013
  28. greened@obbligato.orgFeb 18, 2013

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.