ci/new_test_coverage.py: a glob ending in /, a [...] class and a second pytest after && are read differently from bash and pytest

Open
#1,885 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
github-actions, python, shell
Domain
ci-cd, testing

Research direction

Start in ci/new_test_coverage.py at the path normalisation (posixpath.normpath, which drops a trailing slash), at glob_re (which reads [ literally), and at pytest_commands and read_command (which stop at &&). Reproduce each row of the three tables with pytest --co under bash in a tree shaped like python/tests/, then compare with what the script reports. Done means each row matches bash and pytest, and a line with two pytest commands has both read.

Written by the indexing model from the issue text.

Description

Three misreadings in ci/new_test_coverage.py, found in the review of the fix for #1874 and not changed by it. Each is checked with pytest 9.2.0 (--co, the command run under bash) in a tree with python/tests/{test_a.py, smoke_test.py, sub/test_x.py, sub/test_w.py, sub/deep/test_d.py, subx/test_y.py}, and with the script on main and with #1874's fix. None of the six workflows that run pytest has any of these shapes. --co with named paths is #1866's item 2 and is left out here.

1. A glob ending in / is read as matching files too

bash expands a glob that ends in / to directories only, but the script's posixpath.normpath drops the slash first.

command pytest the script
python/tests/s*/ python/tests/sub/test_x.py --ignore python/tests/sub/test_x.py smoke_test.py is not collected reads smoke_test.py as run
python/tests --deselect python/tests/su?/ subx/test_y.py is collected (the prefix is python/tests/sub/) reads subx/test_y.py as left out

The first silences the warning; the second warns where nothing is wrong.

2. A [...] class in a pytest argument is read literally

glob_re reads [ as itself, but bash expands su[b] to sub.

command pytest the script
python/tests/su[b] python/tests/sub/test_x.py --ignore python/tests/sub/test_x.py sub/test_x.py is not collected reads it as run
python/tests --deselect python/tests/su[b] every test under sub/ (and subx/) is deselected reads sub/test_w.py as run

Both silence the warning. A paths filter that holds [ is already refused before it is matched, so reading bash's classes in glob_re would change only pytest arguments.

3. A second pytest on one line is not read

pytest_commands returns one command per line, and read_command stops at &&, so in run: python -m pytest python/tests/test_a.py && python -m pytest python/tests/test_h1.py the second command is never read: test_h1.py reads as run by no workflow, though pytest runs it. This warns where nothing is wrong. Splitting a line at &&, || and ; into its commands, each read on its own as #1874's fix reads a command, would take it.

Dominant language
Python
Stars
3
Forks
6
Avg merge
1d 1h
Merged PRs (30d)
295

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lanl/bngsim

All issues in lanl/bngsim

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.