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

Re: [PATCH v9 1/5] dir_iterator: add tests for dir_iterator API

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 18, 2017, 04:12 UTC
Message-ID
<xmqqinm2fj70.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1492462296-4990-2-git-send-email-bnmvco@gmail.com>
Daniel Ferreira <bnmvco@gmail.com> writes:
Show 34 quoted lines
> +test_expect_success 'setup' '
> +	mkdir -p dir &&
> +	mkdir -p dir/a/b/c/ &&
> +	>dir/b &&
> +	>dir/c &&
> +	mkdir -p dir/d/e/d/ &&
> +	>dir/a/b/c/d &&
> +	>dir/a/e &&
> +	>dir/d/e/d/a &&
> +
> +	mkdir -p dir2/a/b/c/ &&
> +	>dir2/a/b/c/d
> +'
> +
> +cat >expect-sorted-output <<-\EOF &&
> +[d] (a) [a] ./dir/a
> +[d] (a/b) [b] ./dir/a/b
> +[d] (a/b/c) [c] ./dir/a/b/c
> +[d] (d) [d] ./dir/d
> +[d] (d/e) [e] ./dir/d/e
> +[d] (d/e/d) [d] ./dir/d/e/d
> +[f] (a/b/c/d) [d] ./dir/a/b/c/d
> +[f] (a/e) [e] ./dir/a/e
> +[f] (b) [b] ./dir/b
> +[f] (c) [c] ./dir/c
> +[f] (d/e/d/a) [a] ./dir/d/e/d/a
> +EOF
> +
> +test_expect_success 'dir-iterator should iterate through all files' '
> +	test-dir-iterator ./dir >out &&
> +	sort <out >./actual-pre-order-sorted-output &&
> +
> +	test_cmp expect-sorted-output actual-pre-order-sorted-output
> +'

OK, if you can get multiple entries from a single directory, the order of these entries are not known because they come in readdir() order, and you'd need to sort the output to see if you got the same thing. Sort of makes sense.

Show 13 quoted lines
> +
> +cat >expect-pre-order-output <<-\EOF &&
> +[d] (a) [a] ./dir2/a
> +[d] (a/b) [b] ./dir2/a/b
> +[d] (a/b/c) [c] ./dir2/a/b/c
> +[f] (a/b/c/d) [d] ./dir2/a/b/c/d
> +EOF
> +
> +test_expect_success 'dir-iterator should list files in the correct order' '
> +	test-dir-iterator ./dir2 >actual-pre-order-output &&
> +
> +	test_cmp expect-pre-order-output actual-pre-order-output
> +'

And this example has only one item per each recursion level, so the order of output is predictable. Again, makes sense.

Previous: Daniel FerreiraNext: Junio C Hamano
Message 3 of 13 in “[GSoC] remove_subtree(): reimplement using iterators”
  1. 0/5 [GSoC] remove_subtree(): reimplement using iteratorsDaniel Ferreira, Apr 17, 2017
  2. 1/5 dir_iterator: add tests for dir_iterator APIDaniel Ferreira, Apr 17, 2017
  3. Junio C HamanoApr 18, 2017
  4. Junio C HamanoApr 18, 2017
  5. 2/5 remove_subtree(): test removing nested directoriesDaniel Ferreira, Apr 17, 2017
  6. 4/5 dir_iterator: refactor state machine modelDaniel Ferreira, Apr 17, 2017
  7. Junio C HamanoApr 18, 2017
  8. Junio C HamanoApr 18, 2017
  9. 3/5 dir_iterator: add helpers to dir_iterator_advanceDaniel Ferreira, Apr 17, 2017
  10. Junio C HamanoApr 18, 2017
  11. 5/5 remove_subtree(): reimplement using iteratorsDaniel Ferreira, Apr 17, 2017
  12. Junio C HamanoApr 18, 2017
  13. Stefan BellerApr 18, 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.