Skip to content

Commit

Permalink
Renamed tests to reflect what is being tested
Browse files Browse the repository at this point in the history
Fixed a bug which was making broken_maps tests to not run
  • Loading branch information
ansasaki committed Apr 11, 2018
1 parent 4741f58 commit 4f04082
Show file tree
Hide file tree
Showing 38 changed files with 107 additions and 118 deletions.
6 changes: 3 additions & 3 deletions src/symbol_version/symbol_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def parse(self, lines):
m = re.match(r':', line[column:])
if m is None:
msg = "".join(["Missing \';\' or \':\' after",
"\'", identifier, "\'"])
" \'", identifier, "\'"])
# In this case the current position is used
raise ParserError(self.filename,
lines[index], index, column,
Expand All @@ -418,9 +418,9 @@ def parse(self, lines):
v = ('global', [])
r.symbols.append(v)
msg = "".join(["Missing visibility scope",
"before \'", identifier, "\'.",
" before \'", identifier, "\'.",
" Symbols considered in",
"\'global:\'"])
" \'global:\'"])
# Non-critical, only warning
self.logger.warn(ParserError(self.filename,
lines[last[0]],
Expand Down
25 changes: 20 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def datadir(tmpdir, request):


@pytest.fixture
def testcases(datadir):
def testcases(datadir, capsys):
"""
Returns the test cases for a given test
"""
Expand All @@ -52,7 +52,9 @@ def testcases(datadir):
try:
all_tests.extend(yaml.load(stream))
except yaml.YAMLError as e:
print(e)
with capsys.disabled():
print(e)
raise e

return all_tests

Expand Down Expand Up @@ -105,16 +107,26 @@ def run_tc(tc, datadir, capsys, caplog):
else:
args.func(args)

# Capture stdout and stderr
out, err = capsys.readouterr()

# If there is an expected output file
if tc_out["file"]:
if args.out:
assert filecmp.cmp(args.out, tc_out["file"], shallow=False)
else:
with capsys.disabled():
print(tc)
# Fail
assert 0

# Capture stdout and stderr
out, err = capsys.readouterr()
else:
if args.out:
if os.path.isfile(args.out):
with capsys.disabled():
print(tc)
print("Unexpected output file created:\n" + args.out)
# Fail
assert 0

# If there is an expected output to stdout
if tc_out["stdout"]:
Expand All @@ -123,6 +135,9 @@ def run_tc(tc, datadir, capsys, caplog):
assert out == expected
else:
if out:
with capsys.disabled():
print(tc)
print("Unexpected output in stdout:\n" + out)
# Fail
assert 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ LIBTC1_1_0_0
{
global:
another_symbol;
symbol;
local:
*;
} ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
LIBTC1_1_1_0
{
global:
new_symbol;
symbol;
} LIBTC1_1_0_0;

LIBTC1_1_0_0
{
global:
another_symbol;
symbol;
local:
*;
} ;
Expand Down
3 changes: 3 additions & 0 deletions tests/data/test_update/add.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Added:
symbol

18 changes: 18 additions & 0 deletions tests/data/test_update/add.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Testing add strategy
-
input:
args:
- "update"
- "--add"
- "--out"
- "add.map"
- "add.map"
stdin: "symbol.in"
output:
file: "add.outfile"
stdout: "add.stdout"
warnings:
- "Overwriting existing file 'add.map'"
- "Given paths in '--out' and 'file' are the same."
- "Moving 'add.map' to 'add.map.old'."
exceptions:
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
- "duplicated.map"
stdin: "symbol.in"
output:
file: "tc5.1.out"
stdout: "tc5.1.stdout"
file: "duplicated.outfile"
stdout: "duplicated.stdout"
warnings:
- "Duplicated Release identifier"
- "ABI break detected: symbols were removed."
Expand All @@ -44,7 +44,7 @@
stdout:
warnings:
exceptions:
- "Missing \'{\'"
- "Missing '{'"
-
input:
args:
Expand Down Expand Up @@ -74,7 +74,7 @@
stdout:
warnings:
exceptions:
- "Missing \';\' or \':\' after"
- "Missing ';' or ':' after"
-
input:
args:
Expand All @@ -85,12 +85,12 @@
- "missing_visibility.map"
stdin: "symbol.in"
output:
file: "tc5.5.out"
stdout: "tc5.5.stdout"
file: "missing_visibility.outfile"
stdout: "missing_visibility.stdout"
warnings:
- "ABI break detected: symbols were removed."
- "Missing visibility scope before"
- "Symbols considered in \'global:\'"
- "Symbols considered in 'global:'"
exceptions:
-
input:
Expand Down Expand Up @@ -121,7 +121,7 @@
stdout:
warnings:
exceptions:
- "Missing \';\'"
- "Missing ';'"
-
input:
args:
Expand All @@ -133,7 +133,7 @@
stdin: "symbol.in"
output:
file:
stdout: "tc5.8.stdout"
stdout:
warnings:
exceptions:
- "Release 'LIBTC5_8_0_0' not found"
Expand All @@ -148,7 +148,7 @@
stdin: "symbol.in"
output:
file:
stdout: "tc5.9.stdout"
stdout:
warnings:
- "Duplicated Release identifier 'LIBTC5_9_0_0'"
exceptions:
Expand All @@ -164,7 +164,7 @@
stdin: "symbol.in"
output:
file:
stdout: "tc5.10.stdout"
stdout:
warnings:
exceptions:
- "Circular dependency detected!"
Expand All @@ -178,21 +178,21 @@
- "wildcard_warnings.map"
stdin: "symbol.in"
output:
file: "tc5.11.out"
stdout: "tc5.11.stdout"
file: "wildcard_warnings.outfile"
stdout: "wildcard_warnings.stdout"
warnings:
- "NOTBASE_1_1_0 should not contain the local wildcard because it is \
not the base version (it refers to version BASE_1_0_0 as its \
predecessor)"
- "GLOBAL_WILDCARD_1_2_0 contains the \'*\' wildcard in global scope. \
- "GLOBAL_WILDCARD_1_2_0 contains the '*' wildcard in global scope. \
It is probably exporting symbols it should not."
- "SCOPES_1_3_0contains unknown scope named scope (different from \
\'global\' and \'local\')"
- "The \'*\' wildcard was found in more than one place:"
- " NOTBASE_1_1_0: in \'local\'"
- " BASE_1_0_0: in \'local\'"
- " GLOBAL_WILDCARD_1_2_0: in \'global\'"
- " OTHER_BASE_1_0_0: in \'local\'"
'global' and 'local')"
- "The '*' wildcard was found in more than one place:"
- " NOTBASE_1_1_0: in 'local'"
- " BASE_1_0_0: in 'local'"
- " GLOBAL_WILDCARD_1_2_0: in 'global'"
- " OTHER_BASE_1_0_0: in 'local'"
- "More than one release seems the base version (contains the local \
wildcard and does not have a predecessor version):"
- " BASE_1_0_0"
Expand All @@ -209,10 +209,9 @@
- "baseless.map"
stdin: "symbol.in"
output:
file: "tc5.12.out"
stdout: "tc5.12.stdout"
file: "baseless.out"
stdout: "baseless.stdout"
warnings:
- "The \'*\' wildcard was not found"
- "The '*' wildcard was not found"
- "No base version release found"
exceptions:

File renamed without changes.
File renamed without changes.
9 changes: 7 additions & 2 deletions tests/data/test_update/missing_previous_closer.map
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ LIBTC5_7_0_0
{
global:
other_symbol;
} LIBBASE_1_0_0

LIBBASE_1_0_0
{
global:
another_symbol;
local:
*;
}

} ;
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ Added:

Removed:
other_symbol
some_symbol

Merging all symbols in a single new release
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
- "update"
- "--symbols"
- "--out"
- "tc4.map"
- "tc4.map"
stdin: "tc4.in"
- "overwrite.map"
- "overwrite.map"
stdin: "overwrite.in"
output:
file: "tc4.out"
stdout: "tc4.stdout"
file: "overwrite.out"
stdout: "overwrite.stdout"
warnings:
- "Overwriting existing file 'tc4.map'"
- "Overwriting existing file 'overwrite.map'"
- "Given paths in '--out' and 'file' are the same."
- "Moving 'tc4.map' to 'tc4.map.old'."
- "Moving 'overwrite.map' to 'overwrite.map.old'."
- "ABI break detected: symbols were removed."
exceptions:
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
- "update"
- "--remove"
- "--out"
- "tc2.map"
- "tc2.map"
stdin: "tc2.in"
- "remove.map"
- "remove.map"
stdin: "symbol.in"
output:
file: "tc2.out"
stdout: "tc2.stdout"
file: "remove.out"
stdout: "remove.stdout"
warnings:
- "Overwriting existing file 'tc2.map'"
- "Overwriting existing file 'remove.map'"
- "Given paths in '--out' and 'file' are the same."
- "Moving 'tc2.map' to 'tc2.map.old'."
- "Moving 'remove.map' to 'remove.map.old'."
- "ABI break detected: symbols were removed."
exceptions:
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions tests/data/test_update/symbols.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Testing symbols strategy
-
input:
args:
- "update"
- "--symbols"
- "--out"
- "symbols.map"
- "symbols.map"
stdin: "symbols.in"
output:
file: "symbols.out"
stdout: "symbols.stdout"
warnings:
- "Overwriting existing file 'symbols.map'"
- "Given paths in '--out' and 'file' are the same."
- "Moving 'symbols.map' to 'symbols.map.old'."
exceptions:
1 change: 0 additions & 1 deletion tests/data/test_update/tc1.in

This file was deleted.

18 changes: 0 additions & 18 deletions tests/data/test_update/tc1.yaml

This file was deleted.

1 change: 0 additions & 1 deletion tests/data/test_update/tc2.in

This file was deleted.

3 changes: 0 additions & 3 deletions tests/data/test_update/tc3.stdout

This file was deleted.

18 changes: 0 additions & 18 deletions tests/data/test_update/tc3.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions tests/data/test_update/tc5.10.stdout

This file was deleted.

Loading

0 comments on commit 4f04082

Please sign in to comment.