diff mbox series

[1/2] t/README: document test_config

Message ID 20210514065508.247044-1-firminmartin24@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/2] t/README: document test_config | expand

Commit Message

Firmin Martin May 14, 2021, 6:55 a.m. UTC
test_config is used over one thousand times in the test suite, yet not
documented. Give it a place in the "Test harness library" section.

Signed-off-by: Firmin Martin <firminmartin24@gmail.com>
---
 t/README | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Eric Sunshine May 14, 2021, 7:02 a.m. UTC | #1
On Fri, May 14, 2021 at 2:55 AM Firmin Martin <firminmartin24@gmail.com> wrote:
> test_config is used over one thousand times in the test suite, yet not
> documented. Give it a place in the "Test harness library" section.
>
> Signed-off-by: Firmin Martin <firminmartin24@gmail.com>
> ---
> diff --git a/t/README b/t/README
> @@ -1046,6 +1046,21 @@ library for your script to use.
> + - test_config <config-option> [<value>]
> +
> +   Set the configuration option <config-option> to <value>, and unset it at the
> +   end of the current test. For a similar purpose, test_config_global for
> +   global configuration is also available. Note, however, that test_config_*
> +   should not be used under a subshell.

"should" is perhaps too weak of a word. test_config() will not
function correctly at all (just as test_when_finished() will not
function correctly) within a subshell. So, perhaps say "must not be
used in a subshell."
Firmin Martin May 15, 2021, 2:43 p.m. UTC | #2
Hi Eric,

Eric Sunshine <sunshine@sunshineco.com> writes:

> On Fri, May 14, 2021 at 2:55 AM Firmin Martin <firminmartin24@gmail.com> wrote:
>> test_config is used over one thousand times in the test suite, yet not
>> documented. Give it a place in the "Test harness library" section.
>>
>> Signed-off-by: Firmin Martin <firminmartin24@gmail.com>
>> ---
>> diff --git a/t/README b/t/README
>> @@ -1046,6 +1046,21 @@ library for your script to use.
>> + - test_config <config-option> [<value>]
>> +
>> +   Set the configuration option <config-option> to <value>, and unset it at the
>> +   end of the current test. For a similar purpose, test_config_global for
>> +   global configuration is also available. Note, however, that test_config_*
>> +   should not be used under a subshell.
>
> "should" is perhaps too weak of a word. test_config() will not
> function correctly at all (just as test_when_finished() will not
> function correctly) within a subshell. So, perhaps say "must not be
> used in a subshell."
Indeed, will correct this.

Thanks,

Firmin
diff mbox series

Patch

diff --git a/t/README b/t/README
index 8eb9e46b1d..f69aa05c61 100644
--- a/t/README
+++ b/t/README
@@ -1046,6 +1046,21 @@  library for your script to use.
    Abort the test script if either the value of the variable or the
    default are not valid bool values.
 
+ - test_config <config-option> [<value>]
+
+   Set the configuration option <config-option> to <value>, and unset it at the
+   end of the current test. For a similar purpose, test_config_global for
+   global configuration is also available. Note, however, that test_config_*
+   should not be used under a subshell.
+  
+   Example:
+
+	test_config format.coverLetter auto
+
+   Is a concise way to write:
+	test_when_finished "git config --unset format.coverLetter" &&
+	git config format.coverLetter auto
+
 
 Prerequisites
 -------------