From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Jeff Hostetler via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Jeff Hostetler <jeffhost@microsoft.com>
Subject: Re: [PATCH 08/16] t7527: add parameters to start_daemon to handle args and subshell
Date: Mon, 14 Mar 2022 09:03:36 +0100 [thread overview]
Message-ID: <220314.8635jlez4c.gmgdl@evledraar.gmail.com> (raw)
In-Reply-To: <6693900600f5b27525dfe7de78e73900306e0ab5.1647033303.git.gitgitgadget@gmail.com>
On Fri, Mar 11 2022, Jeff Hostetler via GitGitGadget wrote:
> From: Jeff Hostetler <jeffhost@microsoft.com>
>
> fixup! t7527: create test for fsmonitor--daemon
>
> Add parameters to start_daemon() and handle subshell and logging args.
>
> Remove /dev/null from commands.
>
> Fix &&-chaining of functions.
>
> Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
> ---
> t/t7527-builtin-fsmonitor.sh | 217 ++++++++++++++++++-----------------
> 1 file changed, 111 insertions(+), 106 deletions(-)
>
> diff --git a/t/t7527-builtin-fsmonitor.sh b/t/t7527-builtin-fsmonitor.sh
> index 0ccbfb9616f..026382a0d86 100755
> --- a/t/t7527-builtin-fsmonitor.sh
> +++ b/t/t7527-builtin-fsmonitor.sh
> @@ -11,30 +11,85 @@ then
> fi
>
> stop_daemon_delete_repo () {
> - r=$1
> - git -C $r fsmonitor--daemon stop >/dev/null 2>/dev/null
> + r=$1 &&
> + test_might_fail git -C $r fsmonitor--daemon stop &&
> rm -rf $1
> - return 0
> }
>
> start_daemon () {
> - case "$#" in
> - 1) r="-C $1";;
> - *) r="";
> - esac
> + r="" &&
> + tf="" &&
> + t2="" &&
> + tk="" &&
We usually just do :
x= &&
Not:
x="" &&
I.e. no need for the "".
>
> - git $r fsmonitor--daemon start || return $?
> - git $r fsmonitor--daemon status || return $?
> + while test "$#" -ne 0
> + do
> + case "$1" in
> + -C)
> + shift;
> + test "$#" -ne 0 ||
> + { echo >&2 "error: -C requires arg"; exit 1; }
IMO this exhaustive checking is better just skipped, we e.g.don't do
this in "test_commit". Can't you just...
> + r="-C $1"
> + shift
...properly &&-chain these whole things and have the "shift too many"
and exit code from "shift" catch this?
> + ;;
> + -tf)
> + shift;
> + test "$#" -ne 0 ||
> + { echo >&2 "error: -tf requires arg"; exit 1; }
> + tf="$1"
> + shift
> + ;;
> + -t2)
> + shift;
> + test "$#" -ne 0 ||
> + { echo >&2 "error: -t2 requires arg"; exit 1; }
> + t2="$1"
> + shift
> + ;;
> + -tk)
> + shift;
> + test "$#" -ne 0 ||
> + { echo >&2 "error: -tk requires arg"; exit 1; }
> + tk="$1"
> + shift
> + ;;
> + *)
ditto.
> + echo >&2 "error: unknown option: '$1'"
> + exit 1
But this sort of case is needed, but should use BUG "..."
> + ;;
> + esac
> + done &&
> +
> + (
> + if test ! -z "$tf"
Instead of "! -z x" use "-n x" ?
> + then
> + GIT_TRACE_FSMONITOR="$tf"
> + export GIT_TRACE_FSMONITOR
> + fi &&
> +
> + if test ! -z "$t2"
> + then
> + GIT_TRACE2_PERF="$t2"
> + export GIT_TRACE2_PERF
> + fi &&
> +
> + if test ! -z "$tk"
ditto.
> + then
> + GIT_TEST_FSMONITOR_TOKEN="$tk"
> + export GIT_TEST_FSMONITOR_TOKEN
> + fi &&
> - touch test_flush/file_1 &&
> - touch test_flush/file_2 &&
> + > test_flush/file_1 &&
> + > test_flush/file_2 &&
style: ">x" not "> x" (ditto below).
next prev parent reply other threads:[~2022-03-14 8:07 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-11 21:14 [PATCH 00/16] Builtin FSMonitor Part 2.5 Jeff Hostetler via GitGitGadget
2022-03-11 21:14 ` [PATCH 01/16] t/test-lib: avoid using git on LHS of pipe Jeff Hostetler via GitGitGadget
2022-03-14 6:00 ` Junio C Hamano
2022-03-11 21:14 ` [PATCH 02/16] update-index: convert advise() messages back to warning() Jeff Hostetler via GitGitGadget
2022-03-14 6:08 ` Junio C Hamano
2022-03-21 18:47 ` Jeff Hostetler
2022-03-11 21:14 ` [PATCH 03/16] compat/fsmonitor/fsm-listen-darwin: split out GCC-specific declarations Jeff Hostetler via GitGitGadget
2022-03-11 21:14 ` [PATCH 04/16] t/helper/fsmonitor-client: cleanup call to parse_options() Jeff Hostetler via GitGitGadget
2022-03-14 7:58 ` Ævar Arnfjörð Bjarmason
2022-03-11 21:14 ` [PATCH 05/16] fsmonitor--daemon: refactor cookie handling for readability Jeff Hostetler via GitGitGadget
2022-03-14 8:00 ` Ævar Arnfjörð Bjarmason
2022-03-14 14:49 ` Derrick Stolee
2022-03-14 17:47 ` Junio C Hamano
2022-03-21 19:26 ` Jeff Hostetler
2022-03-11 21:14 ` [PATCH 06/16] t/perf/p7519: use grep rather than egrep in test Jeff Hostetler via GitGitGadget
2022-03-11 21:14 ` [PATCH 07/16] t/perf/p7519: cleanup coding style Jeff Hostetler via GitGitGadget
2022-03-14 8:01 ` Ævar Arnfjörð Bjarmason
2022-03-11 21:14 ` [PATCH 08/16] t7527: add parameters to start_daemon to handle args and subshell Jeff Hostetler via GitGitGadget
2022-03-14 8:03 ` Ævar Arnfjörð Bjarmason [this message]
2022-03-11 21:14 ` [PATCH 09/16] t7527: fix && chaining in matrix_try() Jeff Hostetler via GitGitGadget
2022-03-14 6:15 ` Junio C Hamano
2022-03-11 21:14 ` [PATCH 10/16] t7527: delete unused verify_status() function Jeff Hostetler via GitGitGadget
2022-03-11 21:14 ` [PATCH 11/16] fsmonitor-ipc: add _() to calls to die() Jeff Hostetler via GitGitGadget
2022-03-11 21:14 ` [PATCH 12/16] compat/fsmonitor/fsm-listen-darwin: add _() to calls to error() Jeff Hostetler via GitGitGadget
2022-03-11 21:15 ` [PATCH 13/16] compat/fsmonitor/fsm-listen-win32: " Jeff Hostetler via GitGitGadget
2022-03-11 21:15 ` [PATCH 14/16] fsmonitor--daemon: add _() to calls to die() Jeff Hostetler via GitGitGadget
2022-03-11 21:15 ` [PATCH 15/16] fsmonitor--daemon: add _() to calls to error() Jeff Hostetler via GitGitGadget
2022-03-11 21:15 ` [PATCH 16/16] fsmonitor-settings: simplify initialization of settings data Jeff Hostetler via GitGitGadget
2022-03-14 19:49 ` Junio C Hamano
2022-03-15 18:26 ` Jeff Hostetler
2022-03-15 19:06 ` Junio C Hamano
2022-03-13 8:02 ` [PATCH 00/16] Builtin FSMonitor Part 2.5 Junio C Hamano
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=220314.8635jlez4c.gmgdl@evledraar.gmail.com \
--to=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=jeffhost@microsoft.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).