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
Eric Sunshine <sunshine@sunshineco.com>
Date
Mar 15, 2024, 20:29 UTC
Message-ID
<CAPig+cRG8eFxepkaiN54H+fa7D=rFGsmEHdvTP+HSSaLO_6T_A@mail.gmail.com>
In-Reply-To
<CAPig+cRMPNExbG34xJ0w5npUc3DDwxQUGS_AQfam_mi4s53=sA@mail.gmail.com>
On Fri, Mar 15, 2024 at 3:39 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 17 quoted lines
> 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.
>
> 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.

To be clear, this case is special because the file being created is shared by multiple tests, so it deserves being placed in its own test_expect_success() invocation.

For the remaining cases where you're doing some set-up outside of test_expect_success(), just move the set-up code into the corresponding test_expect_success() invocation. For instance, rather than:

    echo 'big               blue' > expect
    test_expect_success 'internal whitespace' '
        git config --get section.sparse > output &&
        test_cmp expect output
    '
do this:
    test_expect_success 'internal whitespace' '
        echo 'bigQblue' | q_to_tab >expect
        git config --get section.sparse >actual &&
        test_cmp expect actual
    '

(I changed "output" to "actual" above since the names "expect" and "actual" are common in the tests.)

Previous: Dragan SimicNext: Dragan Simic
Message 6 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.