Skip to content

Commit

Permalink
Merge f5100a7 into 246a48e
Browse files Browse the repository at this point in the history
  • Loading branch information
ansasaki committed Aug 2, 2019
2 parents 246a48e + f5100a7 commit ec87f0a
Show file tree
Hide file tree
Showing 17 changed files with 162 additions and 16 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ matrix:
- python: '3.6'
env:
- TOXENV=3.6-nocov
- python: '3.7'
env:
- TOXENV=3.7-cover,report,coveralls,codecov
- python: '3.7'
env:
- TOXENV=3.7-nocov
- python: 'pypy-5.4'
env:
- TOXENV=pypy-cover,report,coveralls,codecov
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ python_versions =
3.4
3.5
3.6
3.7
pypy

coverage_flags =
Expand Down
6 changes: 3 additions & 3 deletions src/abimap/symver.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,9 +970,9 @@ def clean_symbols(symbols):
duplicates.add(previous)
previous = i
if duplicates:
dup_list = "".join((" " * 4 + dup + "\n" for dup in
dup_list = "".join((dup + ", " for dup in
sorted(duplicates)))
logger.warning("Duplicated symbols provided:\n%s", dup_list)
logger.warning("Duplicated symbols provided: %s", dup_list)

return clean

Expand Down Expand Up @@ -1009,7 +1009,7 @@ def check_files(out_arg, out_name, in_arg, in_name, dry):
# preserve the content
shutil.copy2(str(in_name), str(in_name) + ".old")
except Exception as e:
logger.error("Could no copy \'%s\' to \'%s.old\'."
logger.error("Could not copy \'%s\' to \'%s.old\'."
" Aborting.", str(in_name), str(in_name))
raise e

Expand Down
62 changes: 58 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import filecmp
import os
import re
from distutils import dir_util

import pytest
Expand Down Expand Up @@ -56,7 +57,8 @@ def testcases(datadir, capsys):
if file_type.lower() == ".yml" or file_type.lower() == ".yaml":
with open(str(test_input), 'r') as stream:
try:
all_tests.extend(yaml.load(stream))
all_tests.extend(yaml.load(stream,
Loader=yaml.FullLoader))
except yaml.YAMLError as e:
with capsys.disabled():
print(e)
Expand Down Expand Up @@ -87,6 +89,50 @@ def __exit__(self, etype, value, traceback):
os.chdir(self.saved_path)


def is_warning_in_log(expected, log):
"""
Search for a warning containing the expected message in the log. Returns
True if found; False otherwise.
:param expected: The regular expression
"param log: The input string
"""

# Escape possibly existing special characters
escaped = re.escape(expected)

regex = "WARNING.*" + escaped

to_match = re.compile(regex)
found = to_match.search(log)
if found:
return True

return False


def is_error_in_log(expected, log):
"""
Search for an error containing the expected message in the log. Returns
True if found; False otherwise.
:param expected: The regular expression
"param log: The input string
"""

# Escape possibly existing special characters
escaped = re.escape(expected)

regex = "ERROR.*" + escaped

to_match = re.compile(regex)
found = to_match.search(log)
if found:
return True

return False


def run_tc(tc, datadir, capsys, caplog):
"""
Run a command test case (for update and new commands)
Expand Down Expand Up @@ -166,10 +212,15 @@ class C(object):
# Fail
assert 0

# Check if the expected messages are in the log
# Check if the expected warning messages are in the log
if tc_out["warnings"]:
for expected in tc_out["warnings"]:
assert expected in caplog.text
assert is_warning_in_log(expected, caplog.text)

# Check if the expected error messages are in the log
if tc_out["errors"]:
for expected in tc_out["errors"]:
assert is_error_in_log(expected, caplog.text)

# If a log file was supposed to exist, check the content
if args.logfile:
Expand All @@ -178,7 +229,10 @@ class C(object):
logged = log.read()
if tc_out["warnings"]:
for expected in tc_out["warnings"]:
assert expected in logged
assert is_warning_in_log(expected, caplog.text)
if tc_out["errors"]:
for expected in tc_out["errors"]:
assert is_error_in_log(expected, caplog.text)
if tc_out["exceptions"]:
for expected in tc_out["exceptions"]:
assert expected in logged
Expand Down
6 changes: 6 additions & 0 deletions tests/data_template/test_new/guess_names.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
file:
stdout: "separated.stdout"
warnings:
errors:
exceptions:
-
input:
Expand All @@ -21,6 +22,7 @@
file:
stdout: "given_release.stdout"
warnings:
errors:
exceptions:
-
input:
Expand All @@ -33,6 +35,7 @@
file:
stdout: "release_and_version.stdout"
warnings:
errors:
exceptions:
-
input:
Expand All @@ -47,6 +50,7 @@
file:
stdout: "release_and_name.stdout"
warnings:
errors:
exceptions:
-
input:
Expand All @@ -61,5 +65,7 @@
- "Release provided is not well formed (a well formed release contain
the library identifier and the version information). \
Suggested: something like LIBNAME_1_2_3"
errors:
- "Please provide the release name."
exceptions:
- "Please provide the release name."
13 changes: 12 additions & 1 deletion tests/data_template/test_new/options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
file:
stdout: "sanity.stdout"
warnings:
errors:
exceptions:
-
input:
Expand All @@ -23,6 +24,7 @@
file:
stdout: "sanity_final.stdout"
warnings:
errors:
exceptions:
-
input:
Expand All @@ -37,6 +39,7 @@
file: "with_out.outfile"
stdout: ""
warnings:
errors:
exceptions:
-
input:
Expand All @@ -56,6 +59,7 @@
- "Overwriting existing file 'overwrite.in'"
- "Given paths in '--out' and '--in' are the same."
- "Moving 'overwrite.in' to 'overwrite.in.old'."
errors:
exceptions:
-
input:
Expand All @@ -75,6 +79,7 @@
warnings:
- "Overwriting existing file 'dry.in'"
- "Given paths in '--out' and '--in' are the same."
errors:
exceptions:
-
input:
Expand All @@ -90,6 +95,7 @@
stdout:
warnings:
- "No valid symbols provided. Nothing done."
errors:
exceptions:
-
input:
Expand All @@ -105,6 +111,8 @@
- "Release provided is not well formed (a well formed release contain \
the library identifier and the version information). \
Suggested: something like LIBNAME_1_2_3"
errors:
- "Please provide the release name."
exceptions:
- "Please provide the release name."
-
Expand All @@ -116,6 +124,8 @@
file:
stdout:
warnings:
errors:
- "It is necessary to provide either release name or name and version"
exceptions:
- "It is necessary to provide either release name or name and version"
-
Expand All @@ -129,5 +139,6 @@
file:
stdout: "duplicated_input.stdout"
warnings:
- "Duplicated symbols provided:\n a\n b\n\n"
- "Duplicated symbols provided: a, b"
errors:
exceptions:
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
- "Overwriting existing file 'overwrite_protected.in'"
- "Given paths in '--out' and '--in' are the same."
- "Moving 'overwrite_protected.in' to 'overwrite_protected.in.old'."
- "Could no copy 'overwrite_protected.in' to \
errors:
- "Could not copy 'overwrite_protected.in' to \
'overwrite_protected.in.old'. Aborting."
exceptions:
- "Permission denied: 'overwrite_protected.in.old'"
Expand Down
14 changes: 14 additions & 0 deletions tests/data_template/test_update/add.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
file:
stdout: "sanity_add.stdout"
warnings:
errors:
exceptions:
-
input:
Expand All @@ -23,6 +24,7 @@
file:
stdout: "add_final.stdout"
warnings:
errors:
exceptions:
-
input:
Expand All @@ -40,6 +42,7 @@
- "Overwriting existing file 'add.map'"
- "Given paths in '--out' and 'file' are the same."
- "Moving 'add.map' to 'add.map.old'."
errors:
exceptions:
-
input:
Expand All @@ -54,6 +57,7 @@
warnings:
- "The symbol 'symbol' is already present in a previous version. \
Keep the previous implementation to not break ABI."
errors:
exceptions:
-
input:
Expand All @@ -66,6 +70,7 @@
file:
stdout: "empty.stdout"
warnings:
errors:
exceptions:
-
input:
Expand All @@ -81,6 +86,7 @@
- "Duplicates found in release 'DUPLICATED_1_0_0':"
- " global:"
- " duplicated"
errors:
exceptions:
-
input:
Expand All @@ -98,6 +104,7 @@
- "The '*' wildcard was found in more than one place:"
- " WITH_WILDCARD_1_0_0: in 'global'"
- " WITH_WILDCARD_1_0_0: in 'local'"
errors:
exceptions:
-
input:
Expand All @@ -117,6 +124,7 @@
warnings:
- "Overwriting existing file 'dry.in'"
- "Given paths in '--out' and '--in' are the same."
errors:
exceptions:
-
input:
Expand All @@ -131,6 +139,7 @@
file:
stdout: "update_existing.stdout"
warnings:
errors:
exceptions:
-
input:
Expand All @@ -145,6 +154,8 @@
file:
stdout: "update_released.stdout"
warnings:
errors:
- "Released releases cannot be modified. Abort."
exceptions:
- "Released releases cannot be modified. Abort."
-
Expand All @@ -161,6 +172,7 @@
file:
stdout: "update_existing_final.stdout"
warnings:
errors:
exceptions:
-
input:
Expand All @@ -173,6 +185,7 @@
file:
stdout: "split.stdout"
warnings:
errors:
exceptions:
-
input:
Expand All @@ -185,4 +198,5 @@
file:
stdout: "missing_global.stdout"
warnings:
errors:
exceptions:
Loading

0 comments on commit ec87f0a

Please sign in to comment.