From: Junio C Hamano <gitster@pobox.com>
To: Daniel Ferreira <bnmvco@gmail.com>
Cc: git@vger.kernel.org, sbeller@google.com, pclouds@gmail.com,
mhagger@alum.mit.edu
Subject: Re: [PATCH v9 1/5] dir_iterator: add tests for dir_iterator API
Date: Mon, 17 Apr 2017 21:12:03 -0700 [thread overview]
Message-ID: <xmqqinm2fj70.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <1492462296-4990-2-git-send-email-bnmvco@gmail.com> (Daniel Ferreira's message of "Mon, 17 Apr 2017 17:51:32 -0300")
Daniel Ferreira <bnmvco@gmail.com> writes:
> +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.
> +
> +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.
next prev parent reply other threads:[~2017-04-18 4:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-17 20:51 [PATCH v9 0/5] [GSoC] remove_subtree(): reimplement using iterators Daniel Ferreira
2017-04-17 20:51 ` [PATCH v9 1/5] dir_iterator: add tests for dir_iterator API Daniel Ferreira
2017-04-18 4:12 ` Junio C Hamano [this message]
2017-04-18 4:37 ` Junio C Hamano
2017-04-17 20:51 ` [PATCH v9 2/5] remove_subtree(): test removing nested directories Daniel Ferreira
2017-04-17 20:51 ` [PATCH v9 3/5] dir_iterator: add helpers to dir_iterator_advance Daniel Ferreira
2017-04-18 4:23 ` Junio C Hamano
2017-04-17 20:51 ` [PATCH v9 4/5] dir_iterator: refactor state machine model Daniel Ferreira
2017-04-18 4:35 ` Junio C Hamano
2017-04-18 5:13 ` Junio C Hamano
2017-04-17 20:51 ` [PATCH v9 5/5] remove_subtree(): reimplement using iterators Daniel Ferreira
2017-04-18 4:09 ` [PATCH v9 0/5] [GSoC] " Junio C Hamano
2017-04-18 18:45 ` Stefan Beller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqinm2fj70.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=bnmvco@gmail.com \
--cc=git@vger.kernel.org \
--cc=mhagger@alum.mit.edu \
--cc=pclouds@gmail.com \
--cc=sbeller@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.