Re: [PATCH v2 8/8] test-lib: clear watchman watches at test completion
- From
Derrick Stolee <stolee@gmail.com>
- Date
- Dec 10, 2019, 01:49 UTC
- Message-ID
- <bfa73fab-ce2c-a05e-3568-cd406dd5c31f@gmail.com>
- In-Reply-To
- <xmqqwob5ru27.fsf@gitster-ct.c.googlers.com>
On 12/9/2019 5:52 PM, Junio C Hamano wrote:
Show 14 quoted lines
> "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
>> +test_clear_watchman () {
>> + if test -n "$GIT_TEST_FSMONITOR"
>> + then
>> + watchman watch-list |
>> + grep "$TRASH_DIRECTORY" |
>> + sed "s/\",//g" |
>> + sed "s/\"//g" >repo-list
>
> Whoa, this is scary. "$TRASH_DIRECTORY" comes from $(pwd) and the
> leading part of it can have arbitrary garbage like "[a-z]*" that may
> match paths "watchman watch-list" may emit that does not have
> anything to do with the temporary directory used by this test.Hm. That is a good point. Can we assume that our version of grep has a "-F" or "--fixed-strings" option? ([1] seems to say that "-F" would work.)
[1] https://www.gnu.org/savannah-checkouts/gnu/grep/manual/grep.html#index-grep-programs
> What are these stripping of ", and " about? Could you tell readers > how a typical output from the program we are reading from looks like > perhaps in the log message or in-code comment around here?
Watchman outputs its list of paths in JSON format. Luckily, it formats the output so the path lines are on separate lines, each quoted.
For example:
{
"version": "4.9.0",
"roots": [
"<path1>",
"<path2>",
"<path3>"
]
}Thanks, -Stolee