From 4741f586d16edb90dffbd5930fa3e740c1a8d6ca Mon Sep 17 00:00:00 2001 From: Anderson Toshiyuki Sasaki Date: Wed, 11 Apr 2018 17:32:16 +0200 Subject: [PATCH] Add tests which generates warnings Add tests which checks warnings generated by the dependency finder and by the check() method (mostly about wildcard usage). --- src/symbol_version/symbol_version.py | 3 +- tests/data/test_update/baseless.map | 7 ++ .../data/test_update/circular_dependency.map | 28 ++++++ .../test_update/duplicated_dependency.map | 23 +++++ .../test_update/missing_previous_closer.map | 1 + .../test_update/non_existing_previous.map | 15 +++ tests/data/test_update/tc5.10.stdout | 9 ++ tests/data/test_update/tc5.11.out | 10 ++ tests/data/test_update/tc5.11.stdout | 9 ++ tests/data/test_update/tc5.12.out | 10 ++ tests/data/test_update/tc5.12.stdout | 7 ++ tests/data/test_update/tc5.8.stdout | 8 ++ tests/data/test_update/tc5.9.stdout | 8 ++ tests/data/test_update/tc5.yaml | 98 ++++++++++++++++++- tests/data/test_update/wildcard_warnings.map | 37 +++++++ 15 files changed, 268 insertions(+), 5 deletions(-) create mode 100644 tests/data/test_update/baseless.map create mode 100644 tests/data/test_update/circular_dependency.map create mode 100644 tests/data/test_update/duplicated_dependency.map create mode 100644 tests/data/test_update/non_existing_previous.map create mode 100644 tests/data/test_update/tc5.10.stdout create mode 100644 tests/data/test_update/tc5.11.out create mode 100644 tests/data/test_update/tc5.11.stdout create mode 100644 tests/data/test_update/tc5.12.out create mode 100644 tests/data/test_update/tc5.12.stdout create mode 100644 tests/data/test_update/tc5.8.stdout create mode 100644 tests/data/test_update/tc5.9.stdout create mode 100644 tests/data/test_update/wildcard_warnings.map diff --git a/src/symbol_version/symbol_version.py b/src/symbol_version/symbol_version.py index 1e0c927..d3076ca 100755 --- a/src/symbol_version/symbol_version.py +++ b/src/symbol_version/symbol_version.py @@ -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): @@ -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] + diff --git a/tests/data/test_update/baseless.map b/tests/data/test_update/baseless.map new file mode 100644 index 0000000..7b2bd28 --- /dev/null +++ b/tests/data/test_update/baseless.map @@ -0,0 +1,7 @@ +# Map without base release and without wildcard + +BASELESS_1_0_0 +{ + global: + one_symbol; +} ; diff --git a/tests/data/test_update/circular_dependency.map b/tests/data/test_update/circular_dependency.map new file mode 100644 index 0000000..a74b1b0 --- /dev/null +++ b/tests/data/test_update/circular_dependency.map @@ -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: + *; +} ; + diff --git a/tests/data/test_update/duplicated_dependency.map b/tests/data/test_update/duplicated_dependency.map new file mode 100644 index 0000000..8d8bc0b --- /dev/null +++ b/tests/data/test_update/duplicated_dependency.map @@ -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: + *; +} ; diff --git a/tests/data/test_update/missing_previous_closer.map b/tests/data/test_update/missing_previous_closer.map index f8497c3..73a6ee9 100644 --- a/tests/data/test_update/missing_previous_closer.map +++ b/tests/data/test_update/missing_previous_closer.map @@ -2,6 +2,7 @@ LIBTC5_7_0_0 { + global: other_symbol; local: *; diff --git a/tests/data/test_update/non_existing_previous.map b/tests/data/test_update/non_existing_previous.map new file mode 100644 index 0000000..2e39025 --- /dev/null +++ b/tests/data/test_update/non_existing_previous.map @@ -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: + *; +} ; diff --git a/tests/data/test_update/tc5.10.stdout b/tests/data/test_update/tc5.10.stdout new file mode 100644 index 0000000..2adcd32 --- /dev/null +++ b/tests/data/test_update/tc5.10.stdout @@ -0,0 +1,9 @@ +Added: + symbol + +Removed: + one_symbol + three_symbol + two_symbol + zero_symbol + diff --git a/tests/data/test_update/tc5.11.out b/tests/data/test_update/tc5.11.out new file mode 100644 index 0000000..9a90c73 --- /dev/null +++ b/tests/data/test_update/tc5.11.out @@ -0,0 +1,10 @@ +# This map file was automatically updated + +SCOPES_2_0_0 +{ + global: + symbol; + local: + *; +} ; + diff --git a/tests/data/test_update/tc5.11.stdout b/tests/data/test_update/tc5.11.stdout new file mode 100644 index 0000000..e4cfa51 --- /dev/null +++ b/tests/data/test_update/tc5.11.stdout @@ -0,0 +1,9 @@ +Added: + symbol + +Removed: + * + one_symbol + three_symbol + +Merging all symbols in a single new release diff --git a/tests/data/test_update/tc5.12.out b/tests/data/test_update/tc5.12.out new file mode 100644 index 0000000..f7264d6 --- /dev/null +++ b/tests/data/test_update/tc5.12.out @@ -0,0 +1,10 @@ +# This map file was automatically updated + +BASELESS_2_0_0 +{ + global: + symbol; + local: + *; +} ; + diff --git a/tests/data/test_update/tc5.12.stdout b/tests/data/test_update/tc5.12.stdout new file mode 100644 index 0000000..bda068c --- /dev/null +++ b/tests/data/test_update/tc5.12.stdout @@ -0,0 +1,7 @@ +Added: + symbol + +Removed: + one_symbol + +Merging all symbols in a single new release diff --git a/tests/data/test_update/tc5.8.stdout b/tests/data/test_update/tc5.8.stdout new file mode 100644 index 0000000..3c9588d --- /dev/null +++ b/tests/data/test_update/tc5.8.stdout @@ -0,0 +1,8 @@ +symbol +Added: + symbol + +Removed: + another_symbol + other_symbol + diff --git a/tests/data/test_update/tc5.9.stdout b/tests/data/test_update/tc5.9.stdout new file mode 100644 index 0000000..00602b4 --- /dev/null +++ b/tests/data/test_update/tc5.9.stdout @@ -0,0 +1,8 @@ +Added: + symbol + +Removed: + another_symbol + one_more_symbol + other_symbol + diff --git a/tests/data/test_update/tc5.yaml b/tests/data/test_update/tc5.yaml index 4845f41..6ee8db2 100644 --- a/tests/data/test_update/tc5.yaml +++ b/tests/data/test_update/tc5.yaml @@ -1,4 +1,4 @@ -# Testing broken map files +# Testing broken map files (some just give warnings) - input: args: @@ -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: diff --git a/tests/data/test_update/wildcard_warnings.map b/tests/data/test_update/wildcard_warnings.map new file mode 100644 index 0000000..880f45d --- /dev/null +++ b/tests/data/test_update/wildcard_warnings.map @@ -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: + *; +} ;