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

Re: Re: [PATCH v3] ls-files: update test style

From
Llilinchao@oschina.cn <lilinchao@oschina.cn>
Date
Jun 29, 2022, 07:12 UTC
Message-ID
<2022062915111229306214@oschina.cn>
In-Reply-To
<xmqqzghwim3m.fsf@gitster.g>
Show 29 quoted lines
>"Li Linchao via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
>> diff --git a/t/README b/t/README
>> index 309a31133c6..5e0539412b4 100644
>> --- a/t/README
>> +++ b/t/README
>> @@ -547,6 +547,52 @@ This test harness library does the following things:
>>     consistently when command line arguments --verbose (or -v),
>>     --debug (or -d), and --immediate (or -i) is given.
>> 
>> +Recommended style
>> +-----------------
>> +Here are some recommented styles when writing test case.
>> +
>> + - Keep test title the same line with test helper function itself.
>> +
>> +   Take test_expect_success helper for example, write it like:
>> +
>> +  test_expect_success 'test title' '
>> +  ... test body ...
>> +  '
>
>Indent the body further to the right?
>
>> + - Indent the body of here-document, and use "<< -" instead of "<<" to strip prefix TAB:
>
>Overly long line.
>
>Did you mean to have a space between "<<" and "-"? 

Ops, I'll fix it. This came from an extension in VS code which is to preview AsciiDoc, it mistakenly render "<<-" into "<←", so I put a space between "<<" and "-".

Show 6 quoted lines
>
>"prefix TAB" -> "leading TABs used for indentation" (plural is the
>important part)?  
>
>Mention end of here-document marker should by default be quoted,
>unless the body needs $variable_interpolation? 
Sorry, I don't get it. I don't see many of ending "EOF" are quoted in our tests.
Show 25 quoted lines
>
>> +  test_expect_success 'test something' '
>> +      cat >expect <<-\EOF &&
>> +      one
>> +      two
>> +      three
>> +      EOF
>> +      test_something > actual &&
>> +      test_cmp expect actual
>> +  '
>> +
>> +   Instead of:
>> +
>> +  test_expect_success 'test something' '
>> +      cat >expect <<\EOF &&
>> +  one
>> +  two
>> +  three
>> +  EOF
>> +      test_something > actual &&
>> +      test_cmp expect actual
>> +  '
>
>
>Thanks.
Previous: Junio C HamanoNext: Junio C Hamano
Message 9 of 14 in “ls-files: update test style”
  1. ls-files: update test styleLi Linchao via GitGitGadget, Jun 23, 2022
  2. Ævar Arnfjörð BjarmasonJun 23, 2022
  3. lilinchao@oschina.cnJun 24, 2022
  4. Junio C HamanoJun 23, 2022
  5. lilinchao@oschina.cnJun 24, 2022
  6. ls-files: update test styleLi Linchao via GitGitGadget, Jun 28, 2022
  7. ls-files: update test styleLi Linchao via GitGitGadget, Jun 28, 2022
  8. Junio C HamanoJun 28, 2022
  9. lilinchao@oschina.cnJun 29, 2022
  10. Junio C HamanoJun 30, 2022
  11. ls-files: update test styleLi Linchao via GitGitGadget, Jun 30, 2022
  12. ls-files: update test styleLi Linchao via GitGitGadget, Jul 1, 2022
  13. Junio C HamanoJul 1, 2022
  14. ls-files: update test styleLi Linchao via GitGitGadget, Jul 3, 2022

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.