Test `test_item3_deflate_llvm_bitcode` fails with LLVM 7.1
While working on an update for diffoscope-185
for NixOS[1] I realized that the testcase test_item3_deflate_llvm_bitcode
is broken[2]:
[nix-shell:~/Projects/diffoscope]$ pytest tests/comparators/test_rlib.py
============================================================ test session starts =============================================================
platform linux -- Python 3.9.6, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
rootdir: /home/ma27/Projects/diffoscope, configfile: pytest.ini
collected 8 items
tests/comparators/test_rlib.py ......F. [100%]
================================================================== FAILURES ==================================================================
______________________________________________________ test_item3_deflate_llvm_bitcode _______________________________________________________
differences = [<Difference nm -s {} -- nm -s {} []>, <Difference alloc_system-d16b8f0e.0.o -- alloc_system-d16b8f0e.0.o [<Difference...canalyzer -dump {} []>, <Difference find {} -execdir llvm-dis -o - {} ; -- find {} -execdir llvm-dis -o - {} ; []>]>]>]
rlib_dis_expected_diff = '@@ -42,32 +42,32 @@\n entry-block:\n %out.i.i = alloca i8*, align 8\n %4 = icmp ult i64 %3, 17\n br i1 %4, labe...e i64 @__rust_reallocate_inplace(i8* nocapture readnone %0, i64 %1, i64 %2, i64 %3) unnamed_addr #1 {\n entry-block:\n'
@skip_unless_tools_exist("llvm-dis")
@skip_unless_tool_is_at_least("llvm-config", llvm_version, "3.8")
def test_item3_deflate_llvm_bitcode(differences, rlib_dis_expected_diff):
assert differences[3].source1 == "alloc_system-d16b8f0e.0.bytecode.deflate"
assert differences[3].source2 == "alloc_system-d16b8f0e.0.bytecode.deflate"
expected_diff = rlib_dis_expected_diff
actual_diff = differences[3].details[0].details[1].unified_diff
> assert diff_ignore_line_numbers(actual_diff) == diff_ignore_line_numbers(
expected_diff
)
E AssertionError: assert '@@ -XX,XX +X...ntry-block:\n' == '@@ -XX,XX +X...ntry-block:\n'
E Skipping 1855 identical leading characters in diff, use -v to show
E - e readnone %0, i64 %1, i64 %2, i64 %3) unnamed_addr #1 {
E ? --- --- --- ---
E + e readnone, i64, i64, i64) unnamed_addr #1 {
E entry-block:
tests/comparators/test_rlib.py:125: AssertionError
========================================================== short test summary info ===========================================================
FAILED tests/comparators/test_rlib.py::test_item3_deflate_llvm_bitcode - AssertionError: assert '@@ -XX,XX +X...ntry-block:\n' == '@@ -XX,X...
======================================================== 1 failed, 7 passed in 11.53s ========================================================
While performing a git bisect
, I found out that 953a599c appears to be the culprit. It seems as if the fixture rlib_llvm_dis_expected_diff_10
was selected even though our default LLVM version is 7.1. I worked around the problem temporarily like this: https://github.com/NixOS/nixpkgs/blob/589e03f109092a3ba97781fd0533110bf78a3f97/pkgs/tools/misc/diffoscope/fix-tests.patch
I haven't looked closely at the code, but I guess that it somehow trips over minor releases.
[1] https://github.com/NixOS/nixpkgs/commit/589e03f109092a3ba97781fd0533110bf78a3f97
[2] also confirmed that it's the case on 186 as well.