mirror of
https://github.com/TECHNOFAB11/bumpver.git
synced 2025-12-12 14:30:09 +01:00
fix grep regression
This commit is contained in:
parent
b5df665251
commit
43fe8df1fd
3 changed files with 30 additions and 29 deletions
|
|
@ -18,7 +18,7 @@ lint:
|
|||
allow_failure: false
|
||||
|
||||
|
||||
unit:
|
||||
test:
|
||||
# NOTE: Resource_group is conservative and can be disabled
|
||||
# for simple tests. It should be enabled if the tests
|
||||
# need exclusive access to some common resource. The
|
||||
|
|
@ -29,7 +29,6 @@ unit:
|
|||
image: registry.gitlab.com/mbarkhau/pycalver/base
|
||||
script:
|
||||
- make test
|
||||
- make test_compat
|
||||
coverage: '/^(TOTAL|src).*?(\d+\%)$/'
|
||||
artifacts:
|
||||
reports:
|
||||
|
|
@ -39,6 +38,18 @@ unit:
|
|||
- reports/testcov/
|
||||
allow_failure: false
|
||||
|
||||
test_compat:
|
||||
# NOTE: Resource_group is conservative and can be disabled
|
||||
# for simple tests. It should be enabled if the tests
|
||||
# need exclusive access to some common resource. The
|
||||
# resource_group will prevent multiple pipelines from
|
||||
# running concurrently.
|
||||
# resource_group: test-unit
|
||||
stage: test
|
||||
image: registry.gitlab.com/mbarkhau/pycalver/base
|
||||
script:
|
||||
- make test_compat
|
||||
allow_failure: false
|
||||
|
||||
pages:
|
||||
stage: build
|
||||
|
|
|
|||
|
|
@ -285,21 +285,23 @@ def grep(
|
|||
)
|
||||
sys.exit(1)
|
||||
else:
|
||||
if is_version_pattern_required:
|
||||
normalize_pattern = v2patterns.normalize_pattern(version_pattern, raw_pattern)
|
||||
else:
|
||||
normalize_pattern = raw_pattern
|
||||
version_pattern = "vYYYY0M.BUILD[-RELEASE]"
|
||||
|
||||
if is_version_pattern_required:
|
||||
normalized_pattern = v2patterns.normalize_pattern(version_pattern, raw_pattern)
|
||||
else:
|
||||
normalized_pattern = raw_pattern
|
||||
|
||||
isatty = getattr(sys.stdout, 'isatty', lambda: False)
|
||||
|
||||
if isatty():
|
||||
colorama.init()
|
||||
try:
|
||||
_grep(normalize_pattern, files, color=True)
|
||||
_grep(normalized_pattern, files, color=True)
|
||||
finally:
|
||||
colorama.deinit()
|
||||
else:
|
||||
_grep(normalize_pattern, files, color=False)
|
||||
_grep(normalized_pattern, files, color=False)
|
||||
|
||||
|
||||
@cli.command()
|
||||
|
|
|
|||
|
|
@ -738,21 +738,14 @@ def test_grep(runner):
|
|||
#
|
||||
search_re = r"^\s+2:\s+Hello World v201701\.1002-alpha !"
|
||||
|
||||
result1 = runner.invoke(cli, ['grep', r"vYYYY0M.BUILD[-RELEASE]", "README.md"])
|
||||
cmd1 = r'grep "vYYYY0M.BUILD[-RELEASE]" README.md'
|
||||
result1 = runner.invoke(cli, shlex.split(cmd1))
|
||||
assert result1.exit_code == 0
|
||||
assert "README.md" in result1.output
|
||||
assert re.search(search_re, result1.output, flags=re.MULTILINE)
|
||||
|
||||
result2 = runner.invoke(
|
||||
cli,
|
||||
[
|
||||
'grep',
|
||||
"--version-pattern",
|
||||
r"vYYYY0M.BUILD[-RELEASE]",
|
||||
"{version}",
|
||||
"README.md",
|
||||
],
|
||||
)
|
||||
cmd2 = r'grep --version-pattern "vYYYY0M.BUILD[-RELEASE]" "{version}" README.md'
|
||||
result2 = runner.invoke(cli, shlex.split(cmd2))
|
||||
assert result2.exit_code == 0
|
||||
assert "README.md" in result2.output
|
||||
assert re.search(search_re, result2.output, flags=re.MULTILINE)
|
||||
|
|
@ -761,21 +754,16 @@ def test_grep(runner):
|
|||
|
||||
search_re = r"^\s+3:\s+\[aka\. 201701\.1002a0 \!\]"
|
||||
|
||||
result3 = runner.invoke(cli, ['grep', r"\[aka. YYYY0M.BLD[PYTAGNUM] \!\]", "README.md"])
|
||||
cmd3 = r'grep "\[aka. YYYY0M.BLD[PYTAGNUM] \!\]" README.md'
|
||||
result3 = runner.invoke(cli, shlex.split(cmd3))
|
||||
assert result3.exit_code == 0
|
||||
assert "README.md" in result3.output
|
||||
assert re.search(search_re, result3.output, flags=re.MULTILINE)
|
||||
|
||||
result4 = runner.invoke(
|
||||
cli,
|
||||
[
|
||||
'grep',
|
||||
"--version-pattern",
|
||||
r"vYYYY0M.BUILD[-RELEASE]",
|
||||
r"\[aka. {pep440_version} \!\]",
|
||||
"README.md",
|
||||
],
|
||||
cmd4 = (
|
||||
r'grep --version-pattern "vYYYY0M.BUILD[-RELEASE]" "\[aka. {pep440_version} \!\]" README.md'
|
||||
)
|
||||
result4 = runner.invoke(cli, shlex.split(cmd4))
|
||||
assert result4.exit_code == 0
|
||||
assert "README.md" in result4.output
|
||||
assert re.search(search_re, result4.output, flags=re.MULTILINE)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue