test(scripts): enforce CLI positional file argument compatibility across all check scripts in test_lint.py

Aperta Adatta ai principianti
#543 4 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go, python
Ambito
testing, tooling

Direzione di ricerca

Inizia da scripts/test_lint.py e verifica come esegue gli script di controllo; poi esamina scripts/check_validator_spec_parity.py e scripts/check_spec_validator.py insieme agli script correlati menzionati nell’issue. Aggiungi test per --help e argomenti posizionali fittizi relativi a file in scripts/check_*.py, e fai in modo che i due script nominati accettino e ignorino tali argomenti. Il lavoro è completato quando python3 -m unittest scripts/test_lint.py passa e conferma che nessuno script di controllo termina con lo stato 2 di argparse.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug infra triaged

What happened

In PR #530, the code agent created scripts/check_validator_fixtures.py patterned after scripts/check_validator_spec_parity.py. Because the corresponding hook in .pre-commit-config.yaml configured pass_filenames: false, the script's argparse configuration only defined --repo-root and omitted positional file arguments. When human reviewer John Strunk tested the script manually with file arguments (python3 scripts/check_validator_fixtures.py $(git ls-files 'validator/...')), Python's argparse raised unrecognized arguments: ... and exited with status 2. Maintainer review flagged this as non-blocking item m4: scripts/check_validator_fixtures.py:243-256: the checker accepts no file arguments, unlike its siblings... Fix: accept and ignore files, or state in --help that the script takes no file arguments. The fix agent updated check_validator_fixtures.py to accept positional arguments (parser.add_argument('files', nargs='')). However, sibling scripts scripts/check_validator_spec_parity.py and scripts/check_spec_validator.py still lack positional argument handling and fail with exit code 2 if invoked directly with filenames, and scripts/test_lint.py lacks any test validating CLI invocation parity across scripts/check_.py.

What could go better

scripts/lint.py wraps pre-commit run. When developers, CI workflows, or subagents run check scripts directly (or when lint.py --files or pre-commit invokes hooks under different configurations), check scripts should behave uniformly and accept positional file arguments without crashing. Currently, script authors must remember this convention ad-hoc, leading to review churn and inconsistent CLI ergonomics across the test toolchain.

Proposed change

  1. In scripts/test_lint.py, add a test case that discovers all scripts/check_*.py scripts and executes each script with --help and with dummy positional file arguments (e.g. python3 scripts/check_<name>.py dummy_file.go), asserting that none exit with exit code 2 (unrecognized arguments).
  2. Update scripts/check_validator_spec_parity.py and scripts/check_spec_validator.py to add parser.add_argument('files', nargs='*', help='positional file arguments accepted and ignored for CLI compatibility with sibling check scripts') to match check_validator_fixtures.py, check_gofmt.py, check_govet.py, check_portable_null_device.py, and check_adr_amendments.py.

Validation criteria

Running python3 -m unittest scripts/test_lint.py passes and validates that every scripts/check_*.py script in scripts/ accepts positional file arguments without failing with argparse error status 2.

Related issues checked

Searched: positional files repo:redhat-et/ProtoBot is:issue; check_validator_spec_parity arguments repo:redhat-et/ProtoBot is:issue; test_lint positional repo:redhat-et/ProtoBot is:issue; unrecognized arguments repo:redhat-et/ProtoBot is:issue; positional arguments pre-commit hook repo:fullsend-ai/fullsend repo:fullsend-ai/agents repo:redhat-et/ProtoBot is:issue; pass_filenames arguments repo:fullsend-ai/fullsend repo:fullsend-ai/agents repo:redhat-et/ProtoBot is:issue
Considered: fullsend-ai/fullsend#5721, fullsend-ai/agents#42, #432
fullsend-ai/fullsend#5721 discusses pass_filenames in the ty linter hook within fullsend, not ProtoBot's check scripts.
fullsend-ai/agents#42 discusses GitHub Actions pinact pre-commit hook coverage in fullsend-ai/agents.
#432 replaced ProtoBot's custom lint engine with an offline pre-commit wrapper but did not establish CLI argument parity or automated tests for positional arguments across check scripts.


Generated by retro agent from https://github.com/redhat-et/ProtoBot/pull/530

Lingua principale
Go
Stelle
7
Fork
9
Merge medio
22h 37m
PR unite (30g)
118

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di redhat-et/ProtoBot

Tutte le issue di redhat-et/ProtoBot

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.