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

Re: [PATCH 3/4] t1300: add more tests for whitespace and inline comments

From
DSDragan Simic <dsimic@manjaro.org>
Date
Mar 15, 2024, 20:04 UTC
Message-ID
<eb550eebb158064f1780f610669bbda1@manjaro.org>
In-Reply-To
<CAPig+cRMPNExbG34xJ0w5npUc3DDwxQUGS_AQfam_mi4s53=sA@mail.gmail.com>
Hello Eric,
On 2024-03-15 20:39, Eric Sunshine wrote:
Show 63 quoted lines
> On Fri, Mar 15, 2024 at 9:22 AM Dragan Simic <dsimic@manjaro.org> 
> wrote:
>> Add a handful of additional automated tests, to improve the coverage 
>> of
>> configuration file entries whose values contain internal whitespace, 
>> leading
>> and/or trailing whitespace, or which contain an additional inline 
>> comment.
>> 
>> Signed-off-by: Dragan Simic <dsimic@manjaro.org>
> 
> Just some minor style-related comments...
> 
>> diff --git a/t/t1300-config.sh b/t/t1300-config.sh
>> @@ -11,6 +11,96 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
>> +cat > .git/config << EOF
>> +[section]
>> +       solid = rock
>> +       sparse = big             blue
>> +       sparseAndTail = big              blue
>> +       sparseAndTailQuoted = "big               blue "
>> +       sparseAndBiggerTail = big                blue
>> +       sparseAndBiggerTailQuoted = "big                 blue          
>>  "
>> +       sparseAndBiggerTailQuotedPlus =  "big            blue          
>>  "
>> +       headAndTail =   big blue
>> +       headAndTailQuoted = "   big blue "
>> +       headAndTailQuotedPlus =  "      big blue "
>> +       annotated = big blue    # to be discarded
>> +       annotatedQuoted = "big blue"    # to be discarded
>> +EOF
> 
> These days we try to place all test-related code inside a
> test_expect_success() context rather than having it standalone. In
> this case, since the file being created is (presumably) shared by
> multiple tests in this script, you may want to add a new test which
> performs this setup step.
> 
> Use \EOF rather than EOF to signal to readers that we don't expect any
> variable interpolation to happen within the here-doc body.
> 
> Further, use -\EOF inside test_expect_success() to allow us to indent
> the body of the heredoc to match the test indentation.
> 
> Style guideline says to omit whitespace after redirection operators
> (such as `<<` and `>`).
> 
> We have a q_to_tab() function which lets us state explicitly for
> readers the location of TAB characters in the heredoc body. You'll
> often see that used instead of literal TABs.
> 
> Taking all the above into account, perhaps:
> 
>     test_expect_success 'setup whitespace' '
>         q_to_tab >.git/config <<-\EOF
>         [section]
>         solid = rock
>         sparse = bigQblue
>         ...
>         EOF
> 
> Same comments apply to rest of patch.

Thank you for your review and all suggestions! I'll make sure to rework the tests in v2, in the way you described it above.

I'll come back with any questions I might have while reworking the new tests. I hope that's fine.

Previous: Eric SunshineNext: Eric Sunshine
Message 5 of 11 in “Fix a bug in configuration parsing, and improve tests and documentation”
  1. 0/4 Fix a bug in configuration parsing, and improve tests and documentationDragan Simic, Mar 15, 2024
  2. 1/4 config: minor addition of whitespaceDragan Simic, Mar 15, 2024
  3. 3/4 t1300: add more tests for whitespace and inline commentsDragan Simic, Mar 15, 2024
  4. Eric SunshineMar 15, 2024
  5. Dragan SimicMar 15, 2024
  6. Eric SunshineMar 15, 2024
  7. Dragan SimicMar 15, 2024
  8. 2/4 config: really keep value-internal whitespace verbatimDragan Simic, Mar 15, 2024
  9. Junio C HamanoMar 15, 2024
  10. Dragan SimicMar 15, 2024
  11. 4/4 config.txt: describe handling of whitespace furtherDragan Simic, Mar 15, 2024

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.