git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrei Rybak <rybak.a.v@gmail.com>
To: git@vger.kernel.org
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	"Martin Stenberg" <martin@gnutiken.se>,
	"Øystein Walle" <oystwa@gmail.com>,
	"Junio C Hamano" <gitster@pobox.com>
Subject: [PATCH v1 0/6] t: fix unused files, part 2
Date: Sat,  1 Apr 2023 23:28:52 +0200	[thread overview]
Message-ID: <20230401212858.266508-1-rybak.a.v@gmail.com> (raw)

Creation of files from redirecting output of Git commands in tests has been
removed for files which aren't being used for assertions.  CC'ed are authors of
the affected tests.

This is a continuation of part 1:
  https://lore.kernel.org/git/20230312201520.370234-1-rybak.a.v@gmail.com/T/#u

Overall, this is similar to part 1, except that additionally in patch 4/6
creation of an unused file that isn't output of a git command has been removed.
Patch 2/6 fixes broken comments, found during development of this series.

Since part 1 I've upgraded my 'check_unused_files.py' script (invoked in the
same way as in part 1) and found a bit more issues in t0??? and t1???, and
overall have gone up to t2???.

Upgraded script:

    from sys import argv
    import re

    script = argv[1]

    git_with_outputs_pattern = re.compile('git [^&\"]*?[>](?!/)([-a-z_./]*)( 2[>](?!/)([a-z_.-]*))?')

    out_read_index = -1
    err_read_index = -1

    def clean_up_filename(fn):
        if fn and '/' in fn:
            from os import path
            return path.basename(fn)
        return fn

    while True:
        res = git_with_outputs_pattern.search(script)
        if res is None:
            break
        end_index = res.span()[1]
        out_filename = clean_up_filename(res.group(1))
        err_filename = clean_up_filename(res.group(3))

        script = script[end_index:]

        if out_filename:
            out_read_index = script.find(out_filename)
            if out_read_index < 0:
                print("File '" + out_filename + "' is unused")
                print("Script: ")
                print(script)
                from sys import exit
                exit(1)
        if err_filename and err_filename != '&1':
            err_read_index = script.find(err_filename)
            if err_read_index < 0:
                print("File '" + err_filename + "' is unused")
                print("Script: ")
                print(script)
                from sys import exit
                exit(2)
        if out_read_index >= 0:
            script = script[out_read_index + len(out_filename):]
        elif err_read_index >= 0:
            script = script[err_read_index + len(err_filename):]

Andrei Rybak (6):
  t0300: don't create unused file
  t1300: fix config file syntax error descriptions
  t1300: don't create unused files
  t1450: don't create unused files
  t1502: don't create unused files
  t2019: don't create unused files

 t/t0300-credentials.sh            |  2 +-
 t/t1300-config.sh                 | 10 +++++-----
 t/t1450-fsck.sh                   |  5 +----
 t/t1502-rev-parse-parseopt.sh     |  6 +++---
 t/t2019-checkout-ambiguous-ref.sh |  4 ++--
 5 files changed, 12 insertions(+), 15 deletions(-)

-- 
2.40.0


             reply	other threads:[~2023-04-01 21:29 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-01 21:28 Andrei Rybak [this message]
2023-04-01 21:28 ` [PATCH v1 1/6] t0300: don't create unused file Andrei Rybak
2023-04-02  1:30   ` Eric Sunshine
2023-04-01 21:28 ` [PATCH v1 2/6] t1300: fix config file syntax error descriptions Andrei Rybak
2023-04-01 21:28 ` [PATCH v1 3/6] t1300: don't create unused files Andrei Rybak
2023-04-01 21:28 ` [PATCH v1 4/6] t1450: " Andrei Rybak
2023-04-01 21:28 ` [PATCH v1 5/6] t1502: " Andrei Rybak
2023-04-01 21:28 ` [PATCH v1 6/6] t2019: " Andrei Rybak
2023-04-03 22:33 ` [PATCH v2 0/6] t: fix unused files, part 2 Andrei Rybak
2023-04-03 22:33   ` [PATCH v2 1/6] t0300: don't create unused file Andrei Rybak
2023-04-06  8:34     ` Ævar Arnfjörð Bjarmason
2023-04-06 21:01       ` Andrei Rybak
2023-04-03 22:33   ` [PATCH v2 2/6] t1300: fix config file syntax error descriptions Andrei Rybak
2023-04-03 22:33   ` [PATCH v2 3/6] t1300: don't create unused files Andrei Rybak
2023-04-06  8:38     ` Ævar Arnfjörð Bjarmason
2023-04-06 21:30       ` Andrei Rybak
2023-04-06 21:35         ` git config tests for "'git config ignores pairs ..." (was Re: [PATCH v2 3/6] t1300: don't create unused files) Andrei Rybak
2023-04-14  8:13           ` [PATCH v1 0/2] git config tests for "'git config ignores pairs ..." Andrei Rybak
2023-04-14  8:13             ` [PATCH v1 1/2] t1300: drop duplicate test Andrei Rybak
2023-04-14  8:13             ` [PATCH v1 2/2] t1300: check stderr for "ignores pairs" tests Andrei Rybak
2023-04-14 13:28               ` Andrei Rybak
2023-04-18 17:50             ` [PATCH v2 0/3] git config tests for "'git config ignores pairs ..." Andrei Rybak
2023-04-18 17:50               ` [PATCH v2 1/3] t1300: drop duplicate test Andrei Rybak
2023-04-18 18:37                 ` Junio C Hamano
2023-04-18 17:50               ` [PATCH v2 2/3] t1300: check stderr for "ignores pairs" tests Andrei Rybak
2023-04-18 18:39                 ` Junio C Hamano
2023-04-18 17:50               ` [RFC PATCH v2 3/3] t1300: add tests for missing keys Andrei Rybak
2023-04-18 19:31                 ` Junio C Hamano
2023-04-18 17:53               ` [PATCH v2 0/3] git config tests for "'git config ignores pairs ..." Andrei Rybak
2023-04-23 13:46               ` [PATCH v3 " Andrei Rybak
2023-04-23 13:46                 ` [PATCH v3 1/3] t1300: drop duplicate test Andrei Rybak
2023-04-23 13:46                 ` [PATCH v3 2/3] t1300: check stderr for "ignores pairs" tests Andrei Rybak
2023-04-23 13:46                 ` [PATCH v3 3/3] t1300: add tests for missing keys Andrei Rybak
2023-05-01 22:02                 ` [PATCH v3 0/3] git config tests for "'git config ignores pairs ..." Junio C Hamano
2023-05-02 19:58                   ` Andrei Rybak
2023-04-03 22:33   ` [PATCH v2 4/6] t1450: don't create unused files Andrei Rybak
2023-04-06  8:41     ` Ævar Arnfjörð Bjarmason
2023-04-06 22:19       ` Andrei Rybak
2023-04-03 22:33   ` [PATCH v2 5/6] t1502: " Andrei Rybak
2023-04-06  8:15     ` Øystein Walle
2023-04-06  8:47     ` Ævar Arnfjörð Bjarmason
2023-04-06 19:51       ` Andrei Rybak
2023-04-03 22:33   ` [PATCH v2 6/6] t2019: " Andrei Rybak
2023-04-06  8:44     ` Ævar Arnfjörð Bjarmason
2023-04-07  2:19       ` Andrei Rybak
2023-04-08 20:54       ` [PATCH] t2024: fix loose/strict local base branch DWIM test Andrei Rybak
2023-04-10 17:37         ` Junio C Hamano
2023-04-17 19:10   ` [PATCH v3 0/6] t: fix unused files, part 2 Andrei Rybak
2023-04-17 19:10     ` [PATCH v3 1/6] t0300: don't create unused file Andrei Rybak
2023-04-17 19:10     ` [PATCH v3 2/6] t1300: fix config file syntax error descriptions Andrei Rybak
2023-04-17 19:10     ` [PATCH v3 3/6] t1300: don't create unused files Andrei Rybak
2023-04-17 19:10     ` [PATCH v3 4/6] t1450: " Andrei Rybak
2023-04-17 19:10     ` [PATCH v3 5/6] t1502: " Andrei Rybak
2023-04-17 19:10     ` [PATCH v3 6/6] t2019: " Andrei Rybak
2023-05-01 21:52     ` [PATCH v3 0/6] t: fix unused files, part 2 Junio C Hamano
2023-05-02 21:03       ` Andrei Rybak
2023-05-03  4:11       ` Elijah Newren
2023-05-03 15:54         ` Junio C Hamano

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=20230401212858.266508-1-rybak.a.v@gmail.com \
    --to=rybak.a.v@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=martin@gnutiken.se \
    --cc=oystwa@gmail.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).