From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.6 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id 09BC91F54E for ; Tue, 30 Aug 2022 09:32:43 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="nmlODru8"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230132AbiH3Jck (ORCPT ); Tue, 30 Aug 2022 05:32:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231810AbiH3Jc0 (ORCPT ); Tue, 30 Aug 2022 05:32:26 -0400 Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D873BDEA69 for ; Tue, 30 Aug 2022 02:32:05 -0700 (PDT) Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-11eb44f520dso11113644fac.10 for ; Tue, 30 Aug 2022 02:32:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=TOdWyA4vLzoKhdbmwho4LOtuzKicaiLbf4P0+UFvws8=; b=nmlODru8ZjQMKRYfcQCcIO2yLoyK9DQdqrgtcdAdo1EI51Xq+79SA6k0Zk26Et72iV y8NfQOECRrYseCb66JFqqQ5eCVDDTCpCSy3ohSj7d0htRldKMtl2NiSz0uCzmmlhMP7W ioT60kzN5uPAJBBw/XOkNyu0Bi54ONzebgbdhJfPwRNIYZcHvP8RHU6613aS3QShYIij Hy5VIt41OHTIbyNvIVcaGa90FkcsOzHO+G1rk/uFnPgkUWA4LyWYszSAda06kYSZf9r2 1g08ES1JoReGv1lF3dz1BOTtnWWZUPe5NPfmq2459vieirMr+3xReXuP5xhp0i2TiB2H 46OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=TOdWyA4vLzoKhdbmwho4LOtuzKicaiLbf4P0+UFvws8=; b=BifaVvpoPSJyBCILaei9G10/Y/JiRh6AVqOToGB5n1BJRXjxp/F7vpGvdoS6W8WtKl MsBjIDxXmFyK6UYFGeX2NOErVGKpnTNGiQ1FjAECEHmJ6fXQU3sP0JCgKpJ5Usubj/yY hwZt1t+1M2OgkKj5NfCFub2+MmbHUVFW2IkAPeiM5HxOlHgnXZRVQ+44MqoxEi42LtQJ 0ei16/vrNr5sCCBDu4yZ5+bcVmOiTQAG6PQI8BOMBJLfOFylk++jUKYc7KLVccRWeWh/ 3CjrQV6w8QH03rS+4rM8GNA+aox8+mQDMMSJi1IUKSzAOMSfYmnoxa8gkbfNHINo01iJ MJ2g== X-Gm-Message-State: ACgBeo2Cn7Jui66syRZIws+1I7Z0wdNNS2w45QS8qBvv5RZRCSmyIbQk vCy2NqSGoV2+Shj13sK9QjLVMJ6LEcc= X-Google-Smtp-Source: AA6agR615htzUKVPqrd9FML8S0TTk7LGK+TtKh9vHle32j0KQJyBPH3ns0gazexxMf0PzKbkn2psmQ== X-Received: by 2002:a05:6870:9590:b0:de:27ca:c60c with SMTP id k16-20020a056870959000b000de27cac60cmr9965855oao.108.1661851925110; Tue, 30 Aug 2022 02:32:05 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id h11-20020a9d6f8b000000b0061c9f9c54e4sm7137223otq.80.2022.08.30.02.32.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:04 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 15/51] test: completion: add run_func() helper Date: Tue, 30 Aug 2022 04:31:02 -0500 Message-Id: <20220830093138.1581538-16-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Pretty straightforward: runs functions. Signed-off-by: Felipe Contreras --- t/t9902-completion.sh | 58 ++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 34 deletions(-) diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 2fe056ab59..91dfb618c1 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -75,6 +75,12 @@ run_completion () __git_wrap__git_main && print_comp } +run_func () +{ + local -a COMPREPLY && + "$@" && print_comp +} + # Test high-level completion # Arguments are: # 1: typed text so far (cur) @@ -452,8 +458,7 @@ test_expect_success '__gitcomp_direct - puts everything into COMPREPLY as-is' ' EOF ( cur=should_be_ignored && - __gitcomp_direct "$(cat expected)" && - print_comp + run_func __gitcomp_direct "$(cat expected)" ) && test_cmp expected out ' @@ -547,7 +552,7 @@ test_expect_success '__gitcomp - equal skip' ' ' test_expect_success '__gitcomp - doesnt fail because of invalid variable name' ' - __gitcomp "$invalid_variable_name" + run_func __gitcomp "$invalid_variable_name" ' read -r -d "" refs <<-\EOF @@ -586,7 +591,7 @@ test_expect_success '__gitcomp_nl - no suffix' ' ' test_expect_success '__gitcomp_nl - doesnt fail because of invalid variable name' ' - __gitcomp_nl "$invalid_variable_name" + run_func __gitcomp_nl "$invalid_variable_name" ' test_expect_success '__git_remotes - list remotes from $GIT_DIR/remotes and from config file' ' @@ -1087,8 +1092,7 @@ test_expect_success '__git_complete_refs - simple' ' EOF ( cur= && - __git_complete_refs && - print_comp + run_func __git_complete_refs ) && test_cmp expected out ' @@ -1100,8 +1104,7 @@ test_expect_success '__git_complete_refs - matching' ' EOF ( cur=mat && - __git_complete_refs && - print_comp + run_func __git_complete_refs ) && test_cmp expected out ' @@ -1114,8 +1117,7 @@ test_expect_success '__git_complete_refs - remote' ' EOF ( cur= && - __git_complete_refs --remote=other && - print_comp + run_func __git_complete_refs --remote=other ) && test_cmp expected out ' @@ -1133,8 +1135,7 @@ test_expect_success '__git_complete_refs - track' ' EOF ( cur= && - __git_complete_refs --track && - print_comp + run_func __git_complete_refs --track ) && test_cmp expected out ' @@ -1146,8 +1147,7 @@ test_expect_success '__git_complete_refs - current word' ' EOF ( cur="--option=mat" && - __git_complete_refs --cur="${cur#*=}" && - print_comp + run_func __git_complete_refs --cur="${cur#*=}" ) && test_cmp expected out ' @@ -1159,8 +1159,7 @@ test_expect_success '__git_complete_refs - prefix' ' EOF ( cur=v1.0..mat && - __git_complete_refs --pfx=v1.0.. --cur=mat && - print_comp + run_func __git_complete_refs --pfx=v1.0.. --cur=mat ) && test_cmp expected out ' @@ -1176,8 +1175,7 @@ test_expect_success '__git_complete_refs - suffix' ' EOF ( cur= && - __git_complete_refs --sfx=. && - print_comp + run_func __git_complete_refs --sfx=. ) && test_cmp expected out ' @@ -1190,8 +1188,7 @@ test_expect_success '__git_complete_fetch_refspecs - simple' ' EOF ( cur= && - __git_complete_fetch_refspecs other && - print_comp + run_func __git_complete_fetch_refspecs other ) && test_cmp expected out ' @@ -1202,8 +1199,7 @@ test_expect_success '__git_complete_fetch_refspecs - matching' ' EOF ( cur=br && - __git_complete_fetch_refspecs other "" br && - print_comp + run_func __git_complete_fetch_refspecs other "" br ) && test_cmp expected out ' @@ -1216,8 +1212,7 @@ test_expect_success '__git_complete_fetch_refspecs - prefix' ' EOF ( cur="+" && - __git_complete_fetch_refspecs other "+" "" && - print_comp + run_func __git_complete_fetch_refspecs other "+" "" ) && test_cmp expected out ' @@ -1230,8 +1225,7 @@ test_expect_success '__git_complete_fetch_refspecs - fully qualified' ' EOF ( cur=refs/ && - __git_complete_fetch_refspecs other "" refs/ && - print_comp + run_func __git_complete_fetch_refspecs other "" refs/ ) && test_cmp expected out ' @@ -1244,8 +1238,7 @@ test_expect_success '__git_complete_fetch_refspecs - fully qualified & prefix' ' EOF ( cur=+refs/ && - __git_complete_fetch_refspecs other + refs/ && - print_comp + run_func __git_complete_fetch_refspecs other + refs/ ) && test_cmp expected out ' @@ -1931,8 +1924,7 @@ test_path_completion () # unusual characters in path names. By requesting only # untracked files we do not have to bother adding any # paths to the index in those tests. - __git_complete_index_file --others && - print_comp + run_func __git_complete_index_file --others ) && test_cmp expected out } @@ -2457,8 +2449,7 @@ do words=(git push '$flag' other ma) && cword=${#words[@]} cur=${words[cword-1]} && __git_cmd_idx=1 && - __git_complete_remote_or_refspec && - print_comp + run_func __git_complete_remote_or_refspec ) && test_cmp expected out ' @@ -2471,8 +2462,7 @@ do words=(git push other '$flag' ma) && cword=${#words[@]} cur=${words[cword-1]} && __git_cmd_idx=1 && - __git_complete_remote_or_refspec && - print_comp + run_func __git_complete_remote_or_refspec ) && test_cmp expected out ' -- 2.37.2.351.g9bf691b78c.dirty