File: test_abi.py

package info (click to toggle)
gnome-subtitles 1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 103,144 kB
  • sloc: xml: 406,395; cs: 364,495; ansic: 3,104; perl: 1,477; sh: 769; python: 545; javascript: 500; makefile: 49
file content (28 lines) | stat: -rwxr-xr-x 749 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python3

import difflib
import sys
import shutil
import subprocess

reference_abi = subprocess.check_output(sys.argv[1]).decode().split("\n")
launcher = []
if shutil.which("mono"):
    launcher = ["mono", "--debug"]
csharp_abi = subprocess.check_output(launcher + [sys.argv[2]]).decode().split("\n")
print("Comparing output of %s and %s" % (sys.argv[1], sys.argv[2]))

res = 0
for line in difflib.unified_diff(reference_abi, csharp_abi):
    res = 1
    print(line)

if res:
    files = [(sys.argv[1] + ".res", reference_abi),
             (sys.argv[2] + 'res', csharp_abi)]

    for f, vals in files:
        with open(f, "w") as _f:
            print("Outputing results in " + f)
            _f.write("\n".join(vals))
sys.exit(res)