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
|
allow_failure: false
|
||||||
|
|
||||||
|
|
||||||
unit:
|
test:
|
||||||
# NOTE: Resource_group is conservative and can be disabled
|
# NOTE: Resource_group is conservative and can be disabled
|
||||||
# for simple tests. It should be enabled if the tests
|
# for simple tests. It should be enabled if the tests
|
||||||
# need exclusive access to some common resource. The
|
# need exclusive access to some common resource. The
|
||||||
|
|
@ -29,7 +29,6 @@ unit:
|
||||||
image: registry.gitlab.com/mbarkhau/pycalver/base
|
image: registry.gitlab.com/mbarkhau/pycalver/base
|
||||||
script:
|
script:
|
||||||
- make test
|
- make test
|
||||||
- make test_compat
|
|
||||||
coverage: '/^(TOTAL|src).*?(\d+\%)$/'
|
coverage: '/^(TOTAL|src).*?(\d+\%)$/'
|
||||||
artifacts:
|
artifacts:
|
||||||
reports:
|
reports:
|
||||||
|
|
@ -39,6 +38,18 @@ unit:
|
||||||
- reports/testcov/
|
- reports/testcov/
|
||||||
allow_failure: false
|
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:
|
pages:
|
||||||
stage: build
|
stage: build
|
||||||
|
|
|
||||||
|
|
@ -285,21 +285,23 @@ def grep(
|
||||||
)
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
if is_version_pattern_required:
|
version_pattern = "vYYYY0M.BUILD[-RELEASE]"
|
||||||
normalize_pattern = v2patterns.normalize_pattern(version_pattern, raw_pattern)
|
|
||||||
else:
|
if is_version_pattern_required:
|
||||||
normalize_pattern = raw_pattern
|
normalized_pattern = v2patterns.normalize_pattern(version_pattern, raw_pattern)
|
||||||
|
else:
|
||||||
|
normalized_pattern = raw_pattern
|
||||||
|
|
||||||
isatty = getattr(sys.stdout, 'isatty', lambda: False)
|
isatty = getattr(sys.stdout, 'isatty', lambda: False)
|
||||||
|
|
||||||
if isatty():
|
if isatty():
|
||||||
colorama.init()
|
colorama.init()
|
||||||
try:
|
try:
|
||||||
_grep(normalize_pattern, files, color=True)
|
_grep(normalized_pattern, files, color=True)
|
||||||
finally:
|
finally:
|
||||||
colorama.deinit()
|
colorama.deinit()
|
||||||
else:
|
else:
|
||||||
_grep(normalize_pattern, files, color=False)
|
_grep(normalized_pattern, files, color=False)
|
||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
|
|
|
||||||
|
|
@ -738,21 +738,14 @@ def test_grep(runner):
|
||||||
#
|
#
|
||||||
search_re = r"^\s+2:\s+Hello World v201701\.1002-alpha !"
|
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 result1.exit_code == 0
|
||||||
assert "README.md" in result1.output
|
assert "README.md" in result1.output
|
||||||
assert re.search(search_re, result1.output, flags=re.MULTILINE)
|
assert re.search(search_re, result1.output, flags=re.MULTILINE)
|
||||||
|
|
||||||
result2 = runner.invoke(
|
cmd2 = r'grep --version-pattern "vYYYY0M.BUILD[-RELEASE]" "{version}" README.md'
|
||||||
cli,
|
result2 = runner.invoke(cli, shlex.split(cmd2))
|
||||||
[
|
|
||||||
'grep',
|
|
||||||
"--version-pattern",
|
|
||||||
r"vYYYY0M.BUILD[-RELEASE]",
|
|
||||||
"{version}",
|
|
||||||
"README.md",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
assert result2.exit_code == 0
|
assert result2.exit_code == 0
|
||||||
assert "README.md" in result2.output
|
assert "README.md" in result2.output
|
||||||
assert re.search(search_re, result2.output, flags=re.MULTILINE)
|
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 \!\]"
|
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 result3.exit_code == 0
|
||||||
assert "README.md" in result3.output
|
assert "README.md" in result3.output
|
||||||
assert re.search(search_re, result3.output, flags=re.MULTILINE)
|
assert re.search(search_re, result3.output, flags=re.MULTILINE)
|
||||||
|
|
||||||
result4 = runner.invoke(
|
cmd4 = (
|
||||||
cli,
|
r'grep --version-pattern "vYYYY0M.BUILD[-RELEASE]" "\[aka. {pep440_version} \!\]" README.md'
|
||||||
[
|
|
||||||
'grep',
|
|
||||||
"--version-pattern",
|
|
||||||
r"vYYYY0M.BUILD[-RELEASE]",
|
|
||||||
r"\[aka. {pep440_version} \!\]",
|
|
||||||
"README.md",
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
|
result4 = runner.invoke(cli, shlex.split(cmd4))
|
||||||
assert result4.exit_code == 0
|
assert result4.exit_code == 0
|
||||||
assert "README.md" in result4.output
|
assert "README.md" in result4.output
|
||||||
assert re.search(search_re, result4.output, flags=re.MULTILINE)
|
assert re.search(search_re, result4.output, flags=re.MULTILINE)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue