Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
diffoscope
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Reproducible Builds
diffoscope
Commits
a034a335
Commit
a034a335
authored
8 years ago
by
Ximin Luo
Browse files
Options
Downloads
Patches
Plain Diff
Ignore line numbers because different llvm-dis versions output extra metadata
parent
e3a4b348
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
diffoscope/comparators/utils.py
+7
-0
7 additions, 0 deletions
diffoscope/comparators/utils.py
tests/comparators/test_rlib.py
+3
-1
3 additions, 1 deletion
tests/comparators/test_rlib.py
with
10 additions
and
1 deletion
diffoscope/comparators/utils.py
+
7
−
0
View file @
a034a335
...
...
@@ -23,6 +23,7 @@ from io import BytesIO
from
itertools
import
starmap
# The following would be shutil.which in Python 3.3
import
os
import
re
from
stat
import
S_ISCHR
,
S_ISBLK
import
subprocess
from
threading
import
Thread
...
...
@@ -142,6 +143,12 @@ def get_compressed_content_name(path, expected_extension):
return
name
DIFF_LINE_NUMBERS_RE
=
re
.
compile
(
r
"
(^|\n)@@ -(\d+),(\d+) \+(\d+),(\d+) @@(?=\n|$)
"
)
def
diff_ignore_line_numbers
(
diff
):
return
DIFF_LINE_NUMBERS_RE
.
sub
(
r
"
\1@@ -XX,XX +XX,XX @@
"
,
diff
)
NO_COMMENT
=
None
...
...
This diff is collapsed.
Click to expand it.
tests/comparators/test_rlib.py
+
3
−
1
View file @
a034a335
...
...
@@ -26,6 +26,7 @@ from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
from
diffoscope.comparators.ar
import
ArFile
from
diffoscope.comparators.llvm
import
LlvmBitCodeFile
from
diffoscope.comparators.rust
import
RustObjectFile
from
diffoscope.comparators.utils
import
diff_ignore_line_numbers
from
diffoscope.config
import
Config
TEST_FILE1_PATH
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'
../data/test1.rlib
'
)
...
...
@@ -64,7 +65,8 @@ def test_item2_deflate_llvm_bitcode(differences):
assert
differences
[
2
].
source1
==
'
alloc_system-d16b8f0e.0.bytecode.deflate
'
assert
differences
[
2
].
source2
==
'
alloc_system-d16b8f0e.0.bytecode.deflate
'
expected_diff
=
open
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'
../data/rlib_llvm_dis_expected_diff
'
)).
read
()
assert
differences
[
2
].
details
[
0
].
details
[
1
].
unified_diff
==
expected_diff
actual_diff
=
differences
[
2
].
details
[
0
].
details
[
1
].
unified_diff
assert
diff_ignore_line_numbers
(
actual_diff
)
==
diff_ignore_line_numbers
(
expected_diff
)
def
test_compare_non_existing
(
monkeypatch
,
rlib1
):
monkeypatch
.
setattr
(
Config
.
general
,
'
new_file
'
,
True
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment