git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dragan Simic <dsimic@manjaro.org>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: git@vger.kernel.org, gitster@pobox.com, rsbecker@nexbridge.com,
	github@seichter.de
Subject: Re: [PATCH 3/4] t1300: add more tests for whitespace and inline comments
Date: Fri, 15 Mar 2024 22:42:11 +0100	[thread overview]
Message-ID: <ac99ea0a24c257eab8f29466589b6eef@manjaro.org> (raw)
In-Reply-To: <CAPig+cRG8eFxepkaiN54H+fa7D=rFGsmEHdvTP+HSSaLO_6T_A@mail.gmail.com>

On 2024-03-15 21:29, Eric Sunshine wrote:
> On Fri, Mar 15, 2024 at 3:39 PM Eric Sunshine <sunshine@sunshineco.com> 
> wrote:
>> 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.)

This looks nice, thanks again.  It keeps the expected results and
the test execution in a single "block", making it a bit easier to
keep track of different tests and their expected results.

  reply	other threads:[~2024-03-15 21:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-15 13:22 [PATCH 0/4] Fix a bug in configuration parsing, and improve tests and documentation Dragan Simic
2024-03-15 13:22 ` [PATCH 1/4] config: minor addition of whitespace Dragan Simic
2024-03-15 13:22 ` [PATCH 2/4] config: really keep value-internal whitespace verbatim Dragan Simic
2024-03-15 17:46   ` Junio C Hamano
2024-03-15 19:50     ` Dragan Simic
2024-03-15 13:22 ` [PATCH 3/4] t1300: add more tests for whitespace and inline comments Dragan Simic
2024-03-15 19:39   ` Eric Sunshine
2024-03-15 20:04     ` Dragan Simic
2024-03-15 20:29     ` Eric Sunshine
2024-03-15 21:42       ` Dragan Simic [this message]
2024-03-15 13:22 ` [PATCH 4/4] config.txt: describe handling of whitespace further Dragan Simic

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=ac99ea0a24c257eab8f29466589b6eef@manjaro.org \
    --to=dsimic@manjaro.org \
    --cc=git@vger.kernel.org \
    --cc=github@seichter.de \
    --cc=gitster@pobox.com \
    --cc=rsbecker@nexbridge.com \
    --cc=sunshine@sunshineco.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).