{"thread":{"id":"44306","subject":"[PATCH] t0040: convert all possible tests to use `test-parse-options --expect`","startedAt":"2016-10-16T00:34:22Z","lastAt":"2016-10-17T21:51:12Z","messageCount":2,"participants":["Pranit Bauva","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"304213","messageId":"01020157c8505fc5-cb313aa8-0182-4e19-95fa-cb36c573ee4c-000000@eu-west-1.amazonses.com","threadId":"44306","inReplyTo":null,"subject":"[PATCH] t0040: convert all possible tests to use `test-parse-options --expect`","fromName":"Pranit Bauva","fromEmail":"pranit.bauva@gmail.com","sentAt":"2016-10-15T12:28:13Z","receivedAt":"2016-10-16T00:34:22Z","isPatch":true,"sender":{"key":"pranit.bauva@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2959938?v=4"},"body":"Use \"test-parse-options --expect\" to rewrite the tests to avoid checking\nthe whole variable dump by just testing what is required. This commit is\nbased on 8ca65aeb (t0040: convert a few tests to use test-parse-options;\nJunio C Hamano; May 6, 2016).\n\nSigned-off-by: Pranit Bauva <pranit.bauva@gmail.com>\n---\n t/t0040-parse-options.sh | 183 ++++-------------------------------------------\n 1 file changed, 13 insertions(+), 170 deletions(-)\n\ndiff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh\nindex db5f60d..74d2cd7 100755\n--- a/t/t0040-parse-options.sh\n+++ b/t/t0040-parse-options.sh\n@@ -208,32 +208,15 @@ test_expect_success 'unambiguously abbreviated option' '\n '\n \n test_expect_success 'unambiguously abbreviated option with \"=\"' '\n-\ttest-parse-options --int=2 >output 2>output.err &&\n-\ttest_must_be_empty output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options --expect=\"integer: 2\" --int=2\n '\n \n test_expect_success 'ambiguously abbreviated option' '\n \ttest_expect_code 129 test-parse-options --strin 123\n '\n \n-cat >expect <<\\EOF\n-boolean: 0\n-integer: 0\n-magnitude: 0\n-timestamp: 0\n-string: 123\n-abbrev: 7\n-verbose: -1\n-quiet: 0\n-dry run: no\n-file: (not set)\n-EOF\n-\n test_expect_success 'non ambiguous option (after two options it abbreviates)' '\n-\ttest-parse-options --st 123 >output 2>output.err &&\n-\ttest_must_be_empty output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options --expect=\"string: 123\" --st 123\n '\n \n cat >typo.err <<\\EOF\n@@ -256,24 +239,8 @@ test_expect_success 'detect possible typos' '\n \ttest_cmp typo.err output.err\n '\n \n-cat >expect <<\\EOF\n-boolean: 0\n-integer: 0\n-magnitude: 0\n-timestamp: 0\n-string: (not set)\n-abbrev: 7\n-verbose: -1\n-quiet: 0\n-dry run: no\n-file: (not set)\n-arg 00: --quux\n-EOF\n-\n test_expect_success 'keep some options as arguments' '\n-\ttest-parse-options --quux >output 2>output.err &&\n-\ttest_must_be_empty output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options --expect=\"arg 00: --quux\" --quux\n '\n \n cat >expect <<\\EOF\n@@ -350,54 +317,20 @@ test_expect_success 'OPT_NEGBIT() and OPT_SET_INT() work' '\n \ttest_cmp expect output\n '\n \n-cat >expect <<\\EOF\n-boolean: 6\n-integer: 0\n-magnitude: 0\n-timestamp: 0\n-string: (not set)\n-abbrev: 7\n-verbose: -1\n-quiet: 0\n-dry run: no\n-file: (not set)\n-EOF\n-\n test_expect_success 'OPT_BIT() works' '\n-\ttest-parse-options -bb --or4 >output 2>output.err &&\n-\ttest_must_be_empty output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options --expect=\"boolean: 6\" -bb --or4\n '\n \n test_expect_success 'OPT_NEGBIT() works' '\n-\ttest-parse-options -bb --no-neg-or4 >output 2>output.err &&\n-\ttest_must_be_empty output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options --expect=\"boolean: 6\" -bb --no-neg-or4\n '\n \n test_expect_success 'OPT_COUNTUP() with PARSE_OPT_NODASH works' '\n-\ttest-parse-options + + + + + + >output 2>output.err &&\n-\ttest_must_be_empty output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options --expect=\"boolean: 6\" + + + + + +\n '\n \n-cat >expect <<\\EOF\n-boolean: 0\n-integer: 12345\n-magnitude: 0\n-timestamp: 0\n-string: (not set)\n-abbrev: 7\n-verbose: -1\n-quiet: 0\n-dry run: no\n-file: (not set)\n-EOF\n-\n test_expect_success 'OPT_NUMBER_CALLBACK() works' '\n-\ttest-parse-options -12345 >output 2>output.err &&\n-\ttest_must_be_empty output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options --expect=\"integer: 12345\" -12345\n '\n \n cat >expect <<\\EOF\n@@ -435,118 +368,28 @@ test_expect_success '--no-list resets list' '\n \ttest_cmp expect output\n '\n \n-cat >expect <<\\EOF\n-boolean: 0\n-integer: 0\n-magnitude: 0\n-timestamp: 0\n-string: (not set)\n-abbrev: 7\n-verbose: -1\n-quiet: 3\n-dry run: no\n-file: (not set)\n-EOF\n-\n test_expect_success 'multiple quiet levels' '\n-\ttest-parse-options -q -q -q >output 2>output.err &&\n-\ttest_must_be_empty output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options --expect=\"quiet: 3\" -q -q -q\n '\n \n-cat >expect <<\\EOF\n-boolean: 0\n-integer: 0\n-magnitude: 0\n-timestamp: 0\n-string: (not set)\n-abbrev: 7\n-verbose: 3\n-quiet: 0\n-dry run: no\n-file: (not set)\n-EOF\n-\n test_expect_success 'multiple verbose levels' '\n-\ttest-parse-options -v -v -v >output 2>output.err &&\n-\ttest_must_be_empty output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options --expect=\"verbose: 3\" -v -v -v\n '\n \n-cat >expect <<\\EOF\n-boolean: 0\n-integer: 0\n-magnitude: 0\n-timestamp: 0\n-string: (not set)\n-abbrev: 7\n-verbose: -1\n-quiet: 0\n-dry run: no\n-file: (not set)\n-EOF\n-\n test_expect_success '--no-quiet sets --quiet to 0' '\n-\ttest-parse-options --no-quiet >output 2>output.err &&\n-\ttest_must_be_empty output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options --expect=\"quiet: 0\" --no-quiet\n '\n \n-cat >expect <<\\EOF\n-boolean: 0\n-integer: 0\n-magnitude: 0\n-timestamp: 0\n-string: (not set)\n-abbrev: 7\n-verbose: -1\n-quiet: 0\n-dry run: no\n-file: (not set)\n-EOF\n-\n test_expect_success '--no-quiet resets multiple -q to 0' '\n-\ttest-parse-options -q -q -q --no-quiet >output 2>output.err &&\n-\ttest_must_be_empty output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options --expect=\"quiet: 0\" -q -q -q --no-quiet\n '\n \n-cat >expect <<\\EOF\n-boolean: 0\n-integer: 0\n-magnitude: 0\n-timestamp: 0\n-string: (not set)\n-abbrev: 7\n-verbose: 0\n-quiet: 0\n-dry run: no\n-file: (not set)\n-EOF\n-\n test_expect_success '--no-verbose sets verbose to 0' '\n-\ttest-parse-options --no-verbose >output 2>output.err &&\n-\ttest_must_be_empty output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options --expect=\"verbose: 0\" --no-verbose\n '\n \n-cat >expect <<\\EOF\n-boolean: 0\n-integer: 0\n-magnitude: 0\n-timestamp: 0\n-string: (not set)\n-abbrev: 7\n-verbose: 0\n-quiet: 0\n-dry run: no\n-file: (not set)\n-EOF\n-\n test_expect_success '--no-verbose resets multiple verbose to 0' '\n-\ttest-parse-options -v -v -v --no-verbose >output 2>output.err &&\n-\ttest_must_be_empty output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options --expect=\"verbose: 0\" -v -v -v --no-verbose\n '\n \n test_done\n\n--\nhttps://github.com/git/git/pull/299\n"},{"id":"304312","messageId":"xmqqzim2skzb.fsf@gitster.mtv.corp.google.com","threadId":"44306","inReplyTo":"01020157c8505fc5-cb313aa8-0182-4e19-95fa-cb36c573ee4c-000000@eu-west-1.amazonses.com","subject":"Re: [PATCH] t0040: convert all possible tests to use `test-parse-options --expect`","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-10-17T21:51:04Z","receivedAt":"2016-10-17T21:51:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pranit Bauva <pranit.bauva@gmail.com> writes:\n\n> Use \"test-parse-options --expect\" to rewrite the tests to avoid checking\n> the whole variable dump by just testing what is required. This commit is\n> based on 8ca65aeb (t0040: convert a few tests to use test-parse-options;\n> Junio C Hamano; May 6, 2016).\n>\n> Signed-off-by: Pranit Bauva <pranit.bauva@gmail.com>\n> ---\n>  t/t0040-parse-options.sh | 183 ++++-------------------------------------------\n>  1 file changed, 13 insertions(+), 170 deletions(-)\n\nWhoa.  Quite a lot of repetitions removed.\n\n"}]}