Skip to content

Commit

Permalink
Add tests which generates warnings
Browse files Browse the repository at this point in the history
Add tests which checks warnings generated by the dependency finder and
by the check() method (mostly about wildcard usage).
  • Loading branch information
ansasaki committed Apr 11, 2018
1 parent 68b798a commit 4741f58
Show file tree
Hide file tree
Showing 15 changed files with 268 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/symbol_version/symbol_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,8 @@ def read(self, filename):
self.filename = filename
self.lines = f.readlines()
self.parse(self.lines)
# Check the map read
self.check()
self.init = True

def all_global_symbols(self):
Expand Down Expand Up @@ -564,7 +566,6 @@ def get_dependency(releases, head):
while dep:
# If the found dependency was already in the list
if dep in current:
print(self)
msg = "".join(["Circular dependency detected!\n",
" "] +
[i + "->" for i in current] +
Expand Down
7 changes: 7 additions & 0 deletions tests/data/test_update/baseless.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Map without base release and without wildcard

BASELESS_1_0_0
{
global:
one_symbol;
} ;
28 changes: 28 additions & 0 deletions tests/data/test_update/circular_dependency.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Broken map with circular dependency

LIBTC5_9_2_0
{
global:
one_symbol;
} LIBTC5_9_1_0;

LIBTC5_9_1_0
{
global:
two_symbol;
} LIBTC5_9_0_0;

LIBTC5_9_0_0
{
global:
three_symbol;
} LIBTC5_9_2_0;

LIBBASE_1_0_0
{
global:
zero_symbol;
local:
*;
} ;

23 changes: 23 additions & 0 deletions tests/data/test_update/duplicated_dependency.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Broken map with duplicated dependency

LIBTC5_9_1_0
{
global:
other_symbol;
} LIBTC5_9_0_0;

LIBTC5_9_0_0
{
global:
another_symbol;
local:
*;
} ;

LIBTC5_9_0_0
{
global:
one_more_symbol;
local:
*;
} ;
1 change: 1 addition & 0 deletions tests/data/test_update/missing_previous_closer.map
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

LIBTC5_7_0_0
{
global:
other_symbol;
local:
*;
Expand Down
15 changes: 15 additions & 0 deletions tests/data/test_update/non_existing_previous.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Broken map with non-existing dependency

LIBTC5_8_1_0
{
global:
other_symbol;
} LIBTC5_8_0_0;

LIBBASE_1_0_0
{
global:
another_symbol;
local:
*;
} ;
9 changes: 9 additions & 0 deletions tests/data/test_update/tc5.10.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Added:
symbol

Removed:
one_symbol
three_symbol
two_symbol
zero_symbol

10 changes: 10 additions & 0 deletions tests/data/test_update/tc5.11.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This map file was automatically updated

SCOPES_2_0_0
{
global:
symbol;
local:
*;
} ;

9 changes: 9 additions & 0 deletions tests/data/test_update/tc5.11.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Added:
symbol

Removed:
*
one_symbol
three_symbol

Merging all symbols in a single new release
10 changes: 10 additions & 0 deletions tests/data/test_update/tc5.12.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This map file was automatically updated

BASELESS_2_0_0
{
global:
symbol;
local:
*;
} ;

7 changes: 7 additions & 0 deletions tests/data/test_update/tc5.12.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Added:
symbol

Removed:
one_symbol

Merging all symbols in a single new release
8 changes: 8 additions & 0 deletions tests/data/test_update/tc5.8.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
symbol
Added:
symbol

Removed:
another_symbol
other_symbol

8 changes: 8 additions & 0 deletions tests/data/test_update/tc5.9.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Added:
symbol

Removed:
another_symbol
one_more_symbol
other_symbol

98 changes: 94 additions & 4 deletions tests/data/test_update/tc5.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Testing broken map files
# Testing broken map files (some just give warnings)
-
input:
args:
Expand Down Expand Up @@ -122,7 +122,97 @@
warnings:
exceptions:
- "Missing \';\'"



-
input:
args:
- "update"
- "--symbols"
- "--out"
- "non_existing_previous.out"
- "non_existing_previous.map"
stdin: "symbol.in"
output:
file:
stdout: "tc5.8.stdout"
warnings:
exceptions:
- "Release 'LIBTC5_8_0_0' not found"
-
input:
args:
- "update"
- "--symbols"
- "--out"
- "duplicated_dependency.out"
- "duplicated_dependency.map"
stdin: "symbol.in"
output:
file:
stdout: "tc5.9.stdout"
warnings:
- "Duplicated Release identifier 'LIBTC5_9_0_0'"
exceptions:
- "defined more than 1 release 'LIBTC5_9_0_0'"
-
input:
args:
- "update"
- "--symbols"
- "--out"
- "circular_dependency.out"
- "circular_dependency.map"
stdin: "symbol.in"
output:
file:
stdout: "tc5.10.stdout"
warnings:
exceptions:
- "Circular dependency detected!"
-
input:
args:
- "update"
- "--symbols"
- "--out"
- "wildcard_warnings.out"
- "wildcard_warnings.map"
stdin: "symbol.in"
output:
file: "tc5.11.out"
stdout: "tc5.11.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. \
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\'"
- "More than one release seems the base version (contains the local \
wildcard and does not have a predecessor version):"
- " BASE_1_0_0"
- " OTHER_BASE_1_0_0"
- "ABI break detected: symbols were removed."
exceptions:
-
input:
args:
- "update"
- "--symbols"
- "--out"
- "baseless.out"
- "baseless.map"
stdin: "symbol.in"
output:
file: "tc5.12.out"
stdout: "tc5.12.stdout"
warnings:
- "The \'*\' wildcard was not found"
- "No base version release found"
exceptions:

37 changes: 37 additions & 0 deletions tests/data/test_update/wildcard_warnings.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Broken map with various missuses of the '*' wildcard

NOTBASE_1_1_0
{
global:
one_symbol;
local:
*;
} BASE_1_0_0;

BASE_1_0_0
{
global:
one_symbol;
local:
*;
} ;

GLOBAL_WILDCARD_1_2_0
{
global:
*;
} BASE_1_0_0;

SCOPES_1_3_0
{
scope:
two_symbol;
} BASE_1_0_0;

OTHER_BASE_1_0_0
{
global:
three_symbol;
local:
*;
} ;

0 comments on commit 4741f58

Please sign in to comment.