diff --git a/src/symbol_version/symbol_version.py b/src/symbol_version/symbol_version.py index d3076ca..f86afd0 100755 --- a/src/symbol_version/symbol_version.py +++ b/src/symbol_version/symbol_version.py @@ -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, @@ -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]], diff --git a/tests/conftest.py b/tests/conftest.py index 7b5c59c..ea6cb78 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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 """ @@ -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 @@ -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"]: @@ -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 diff --git a/tests/data/test_update/tc1.map b/tests/data/test_update/add.map similarity index 89% rename from tests/data/test_update/tc1.map rename to tests/data/test_update/add.map index 3b91b67..987ac9e 100644 --- a/tests/data/test_update/tc1.map +++ b/tests/data/test_update/add.map @@ -4,7 +4,6 @@ LIBTC1_1_0_0 { global: another_symbol; - symbol; local: *; } ; diff --git a/tests/data/test_update/tc1.out b/tests/data/test_update/add.outfile similarity index 90% rename from tests/data/test_update/tc1.out rename to tests/data/test_update/add.outfile index 4e63c3b..7ac0ece 100644 --- a/tests/data/test_update/tc1.out +++ b/tests/data/test_update/add.outfile @@ -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: *; } ; diff --git a/tests/data/test_update/add.stdout b/tests/data/test_update/add.stdout new file mode 100644 index 0000000..01db398 --- /dev/null +++ b/tests/data/test_update/add.stdout @@ -0,0 +1,3 @@ +Added: + symbol + diff --git a/tests/data/test_update/add.yaml b/tests/data/test_update/add.yaml new file mode 100644 index 0000000..7e46ada --- /dev/null +++ b/tests/data/test_update/add.yaml @@ -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: diff --git a/tests/data/test_update/tc5.12.out b/tests/data/test_update/baseless.outfile similarity index 100% rename from tests/data/test_update/tc5.12.out rename to tests/data/test_update/baseless.outfile diff --git a/tests/data/test_update/tc5.12.stdout b/tests/data/test_update/baseless.stdout similarity index 100% rename from tests/data/test_update/tc5.12.stdout rename to tests/data/test_update/baseless.stdout diff --git a/tests/data/test_update/tc5.yaml b/tests/data/test_update/broken_maps.yaml similarity index 82% rename from tests/data/test_update/tc5.yaml rename to tests/data/test_update/broken_maps.yaml index 6ee8db2..24d4533 100644 --- a/tests/data/test_update/tc5.yaml +++ b/tests/data/test_update/broken_maps.yaml @@ -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." @@ -44,7 +44,7 @@ stdout: warnings: exceptions: - - "Missing \'{\'" + - "Missing '{'" - input: args: @@ -74,7 +74,7 @@ stdout: warnings: exceptions: - - "Missing \';\' or \':\' after" + - "Missing ';' or ':' after" - input: args: @@ -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: @@ -121,7 +121,7 @@ stdout: warnings: exceptions: - - "Missing \';\'" + - "Missing ';'" - input: args: @@ -133,7 +133,7 @@ stdin: "symbol.in" output: file: - stdout: "tc5.8.stdout" + stdout: warnings: exceptions: - "Release 'LIBTC5_8_0_0' not found" @@ -148,7 +148,7 @@ stdin: "symbol.in" output: file: - stdout: "tc5.9.stdout" + stdout: warnings: - "Duplicated Release identifier 'LIBTC5_9_0_0'" exceptions: @@ -164,7 +164,7 @@ stdin: "symbol.in" output: file: - stdout: "tc5.10.stdout" + stdout: warnings: exceptions: - "Circular dependency detected!" @@ -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" @@ -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: - diff --git a/tests/data/test_update/tc5.1.out b/tests/data/test_update/duplicated.outfile similarity index 100% rename from tests/data/test_update/tc5.1.out rename to tests/data/test_update/duplicated.outfile diff --git a/tests/data/test_update/tc5.1.stdout b/tests/data/test_update/duplicated.stdout similarity index 100% rename from tests/data/test_update/tc5.1.stdout rename to tests/data/test_update/duplicated.stdout diff --git a/tests/data/test_update/missing_previous_closer.map b/tests/data/test_update/missing_previous_closer.map index 73a6ee9..7c655a4 100644 --- a/tests/data/test_update/missing_previous_closer.map +++ b/tests/data/test_update/missing_previous_closer.map @@ -4,7 +4,12 @@ LIBTC5_7_0_0 { global: other_symbol; +} LIBBASE_1_0_0 + +LIBBASE_1_0_0 +{ + global: + another_symbol; local: *; -} - +} ; diff --git a/tests/data/test_update/tc5.5.out b/tests/data/test_update/missing_visibility.outfile similarity index 100% rename from tests/data/test_update/tc5.5.out rename to tests/data/test_update/missing_visibility.outfile diff --git a/tests/data/test_update/tc5.5.stdout b/tests/data/test_update/missing_visibility.stdout similarity index 84% rename from tests/data/test_update/tc5.5.stdout rename to tests/data/test_update/missing_visibility.stdout index 1208d89..f0d4408 100644 --- a/tests/data/test_update/tc5.5.stdout +++ b/tests/data/test_update/missing_visibility.stdout @@ -3,6 +3,5 @@ Added: Removed: other_symbol - some_symbol Merging all symbols in a single new release diff --git a/tests/data/test_update/tc4.in b/tests/data/test_update/overwrite.in similarity index 100% rename from tests/data/test_update/tc4.in rename to tests/data/test_update/overwrite.in diff --git a/tests/data/test_update/tc4.map b/tests/data/test_update/overwrite.map similarity index 100% rename from tests/data/test_update/tc4.map rename to tests/data/test_update/overwrite.map diff --git a/tests/data/test_update/tc4.out b/tests/data/test_update/overwrite.out similarity index 100% rename from tests/data/test_update/tc4.out rename to tests/data/test_update/overwrite.out diff --git a/tests/data/test_update/tc4.stdout b/tests/data/test_update/overwrite.stdout similarity index 100% rename from tests/data/test_update/tc4.stdout rename to tests/data/test_update/overwrite.stdout diff --git a/tests/data/test_update/tc4.yaml b/tests/data/test_update/overwrite.yaml similarity index 51% rename from tests/data/test_update/tc4.yaml rename to tests/data/test_update/overwrite.yaml index 821de55..cdb6591 100644 --- a/tests/data/test_update/tc4.yaml +++ b/tests/data/test_update/overwrite.yaml @@ -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: diff --git a/tests/data/test_update/tc2.map b/tests/data/test_update/remove.map similarity index 100% rename from tests/data/test_update/tc2.map rename to tests/data/test_update/remove.map diff --git a/tests/data/test_update/tc2.out b/tests/data/test_update/remove.out similarity index 100% rename from tests/data/test_update/tc2.out rename to tests/data/test_update/remove.out diff --git a/tests/data/test_update/tc2.stdout b/tests/data/test_update/remove.stdout similarity index 100% rename from tests/data/test_update/tc2.stdout rename to tests/data/test_update/remove.stdout diff --git a/tests/data/test_update/tc2.yaml b/tests/data/test_update/remove.yaml similarity index 53% rename from tests/data/test_update/tc2.yaml rename to tests/data/test_update/remove.yaml index fe42254..5bc1e5a 100644 --- a/tests/data/test_update/tc2.yaml +++ b/tests/data/test_update/remove.yaml @@ -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: diff --git a/tests/data/test_update/tc3.in b/tests/data/test_update/symbols.in similarity index 100% rename from tests/data/test_update/tc3.in rename to tests/data/test_update/symbols.in diff --git a/tests/data/test_update/tc3.map b/tests/data/test_update/symbols.map similarity index 100% rename from tests/data/test_update/tc3.map rename to tests/data/test_update/symbols.map diff --git a/tests/data/test_update/tc3.out b/tests/data/test_update/symbols.out similarity index 100% rename from tests/data/test_update/tc3.out rename to tests/data/test_update/symbols.out diff --git a/tests/data/test_update/tc1.stdout b/tests/data/test_update/symbols.stdout similarity index 100% rename from tests/data/test_update/tc1.stdout rename to tests/data/test_update/symbols.stdout diff --git a/tests/data/test_update/symbols.yaml b/tests/data/test_update/symbols.yaml new file mode 100644 index 0000000..27a735c --- /dev/null +++ b/tests/data/test_update/symbols.yaml @@ -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: diff --git a/tests/data/test_update/tc1.in b/tests/data/test_update/tc1.in deleted file mode 100644 index 741e1a5..0000000 --- a/tests/data/test_update/tc1.in +++ /dev/null @@ -1 +0,0 @@ -new_symbol diff --git a/tests/data/test_update/tc1.yaml b/tests/data/test_update/tc1.yaml deleted file mode 100644 index 31de8fa..0000000 --- a/tests/data/test_update/tc1.yaml +++ /dev/null @@ -1,18 +0,0 @@ -# Testing add strategy -- - input: - args: - - "update" - - "--add" - - "--out" - - "tc1.map" - - "tc1.map" - stdin: "tc1.in" - output: - file: "tc1.out" - stdout: "tc1.stdout" - warnings: - - "Overwriting existing file 'tc1.map'" - - "Given paths in '--out' and 'file' are the same." - - "Moving 'tc1.map' to 'tc1.map.old'." - exceptions: diff --git a/tests/data/test_update/tc2.in b/tests/data/test_update/tc2.in deleted file mode 100644 index f159647..0000000 --- a/tests/data/test_update/tc2.in +++ /dev/null @@ -1 +0,0 @@ -symbol diff --git a/tests/data/test_update/tc3.stdout b/tests/data/test_update/tc3.stdout deleted file mode 100644 index f70c397..0000000 --- a/tests/data/test_update/tc3.stdout +++ /dev/null @@ -1,3 +0,0 @@ -Added: - new_symbol - diff --git a/tests/data/test_update/tc3.yaml b/tests/data/test_update/tc3.yaml deleted file mode 100644 index 255c920..0000000 --- a/tests/data/test_update/tc3.yaml +++ /dev/null @@ -1,18 +0,0 @@ -# Testing symbols strategy -- - input: - args: - - "update" - - "--symbols" - - "--out" - - "tc3.map" - - "tc3.map" - stdin: "tc3.in" - output: - file: "tc3.out" - stdout: "tc3.stdout" - warnings: - - "Overwriting existing file 'tc3.map'" - - "Given paths in '--out' and 'file' are the same." - - "Moving 'tc3.map' to 'tc3.map.old'." - exceptions: diff --git a/tests/data/test_update/tc5.10.stdout b/tests/data/test_update/tc5.10.stdout deleted file mode 100644 index 2adcd32..0000000 --- a/tests/data/test_update/tc5.10.stdout +++ /dev/null @@ -1,9 +0,0 @@ -Added: - symbol - -Removed: - one_symbol - three_symbol - two_symbol - zero_symbol - diff --git a/tests/data/test_update/tc5.8.stdout b/tests/data/test_update/tc5.8.stdout deleted file mode 100644 index 3c9588d..0000000 --- a/tests/data/test_update/tc5.8.stdout +++ /dev/null @@ -1,8 +0,0 @@ -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 deleted file mode 100644 index 00602b4..0000000 --- a/tests/data/test_update/tc5.9.stdout +++ /dev/null @@ -1,8 +0,0 @@ -Added: - symbol - -Removed: - another_symbol - one_more_symbol - other_symbol - diff --git a/tests/data/test_update/tc5.11.out b/tests/data/test_update/wildcard_warnings.outfile similarity index 100% rename from tests/data/test_update/tc5.11.out rename to tests/data/test_update/wildcard_warnings.outfile diff --git a/tests/data/test_update/tc5.11.stdout b/tests/data/test_update/wildcard_warnings.stdout similarity index 100% rename from tests/data/test_update/tc5.11.stdout rename to tests/data/test_update/wildcard_warnings.stdout